marl / jams

A JSON Annotated Music Specification for Reproducible MIR Research
ISC License
186 stars 27 forks source link

Refactoring schema functionality? #49

Closed bmcfee closed 9 years ago

bmcfee commented 9 years ago

What do people think about moving all schema management functionality into a single submodule? We currently have the ns module for handling dynamic namespace schemata, and the core jams schema is handled directly in pyjams.

Since these two things are not entirely independent -- validation code needs to touch both, for example -- I'm thinking it would be simpler if we move jams.ns to jams.schema and then have all schema loading/manipulation done from there.

The reason to do this comes from the validation method for annotations, which has to supply the schema for a SparseObservation object to the namespace schema constructor. This is the only value ever passed in to ns.schema(), so it's silly to have a parameter and condition checking for it. We can't just hard-wire the current implementation though, since it would introduce a circular dependency in the submodules.

Moving pyjams.__SCHEMA__ to reside in the same submodule fixes the dependency cycle and simplifies some api and internal logic. Also, in case we do decide to include other schemata later on (eg, collections), having a catch-all submodule for schema handling makes a lot of sense.

From the end-user perspective, nothing important should change.

Some of the internals to pyjams will need to change if we do this, but it's simply a matter of pointing to the new location of the schema object. Similarly, tests and docs will have to change, but that's pretty trivial.

Opinions?

bmcfee commented 9 years ago

.. and while we're at it, how about renaming jams.pyjams to jams.core?

justinsalamon commented 9 years ago

sounds sensible on both accounts

bmcfee commented 9 years ago

Ok. I'll hack it in a branch and then we can reconvene when it's done.

urinieto commented 9 years ago

+1 to all.

On Wed, Jul 15, 2015 at 2:04 PM, Brian McFee notifications@github.com wrote:

Ok. I'll hack it in a branch and then we can reconvene when it's done.

— Reply to this email directly or view it on GitHub https://github.com/marl/jams/issues/49#issuecomment-121695295.

bmcfee commented 9 years ago

50 implements this. It all went pretty smoothly, I think.