Comments (7)
Oh, the error message of SchemaError
is empty, I guess that's why nothing is printed. We should change that.
from jams.
Oh, the error message of SchemaError is empty, I guess that's why nothing is printed.
That should never happen. Can you post a complete example that causes this?
A couple of weeks ago, every time I tried to validate a non-valid JAMS file I got an error reporting the exact source of the problem.
Nothing should have changed, except for the exception type; the same message should propagate through.
from jams.
Here you have the jams file that causes this.
from jams.
Interesting. On python 3 (where raise_from
is well-defined), it works as expected:
In [2]: J = jams.load('/home/bmcfee/Desktop/bad_jams.jams')
---------------------------------------------------------------------------
ValidationError Traceback (most recent call last)
/home/bmcfee/git/jams/jams/pyjams.py in validate(self, strict)
776 for rec in records:
--> 777 jsonschema.validate(rec, schema)
778
/home/bmcfee/miniconda/envs/test_env/lib/python3.4/site-packages/jsonschema/validators.py in validate(instance, schema, cls, *args, **kwargs)
427 cls.check_schema(schema)
--> 428 cls(schema, *args, **kwargs).validate(instance)
/home/bmcfee/miniconda/envs/test_env/lib/python3.4/site-packages/jsonschema/validators.py in validate(self, *args, **kwargs)
116 for error in self.iter_errors(*args, **kwargs):
--> 117 raise error
118
ValidationError: 'C#:modal' does not match '^N|([A-G][b#]?)(:(major|minor|ionian|dorian|phrygian|lydian|mixolydian|aeolian|locrian))?$'
Failed validating 'pattern' in schema['properties']['value']:
{'pattern': '^N|([A-G][b#]?)(:(major|minor|ionian|dorian|phrygian|lydian|mixolydian|aeolian|locrian))?$',
'type': 'string'}
On instance['value']:
'C#:modal'
The above exception was the direct cause of the following exception:
SchemaError Traceback (most recent call last)
<ipython-input-2-927dac142e95> in <module>()
----> 1 J = jams.load('/home/bmcfee/Desktop/bad_jams.jams')
/home/bmcfee/git/jams/jams/pyjams.py in load(filepath, validate, strict)
115
116 if validate:
--> 117 jam.validate(strict=strict)
118
119 return jam
/home/bmcfee/git/jams/jams/pyjams.py in validate(self, strict)
1122
1123 for ann in self.annotations:
-> 1124 valid &= ann.validate(strict=strict)
1125
1126 return valid
/home/bmcfee/git/jams/jams/pyjams.py in validate(self, strict)
779 except jsonschema.ValidationError as invalid:
780 if strict:
--> 781 six.raise_from(SchemaError, invalid)
782 else:
783 warnings.warn(str(invalid))
/home/bmcfee/miniconda/envs/test_env/lib/python3.4/site-packages/six.py in raise_from(value, from_value)
On python2, only the SchemaError
exception makes it through:
In [2]: J = jams.load('bad_jams.jams')
---------------------------------------------------------------------------
SchemaError Traceback (most recent call last)
<ipython-input-2-3e7d9e363c07> in <module>()
----> 1 J = jams.load('bad_jams.jams')
/home/bmcfee/git/jams/jams/pyjams.pyc in load(filepath, validate, strict)
115
116 if validate:
--> 117 jam.validate(strict=strict)
118
119 return jam
/home/bmcfee/git/jams/jams/pyjams.pyc in validate(self, strict)
1122
1123 for ann in self.annotations:
-> 1124 valid &= ann.validate(strict=strict)
1125
1126 return valid
/home/bmcfee/git/jams/jams/pyjams.pyc in validate(self, strict)
779 except jsonschema.ValidationError as invalid:
780 if strict:
--> 781 six.raise_from(SchemaError, invalid)
782 else:
783 warnings.warn(str(invalid))
/usr/local/lib/python2.7/dist-packages/six.pyc in raise_from(value, from_value)
690 else:
691 def raise_from(value, from_value):
--> 692 raise value
693
694
SchemaError:
But if you run it with strict=False
on py2, the warning shows up as expected:
In [3]: J = jams.load('bad_jams.jams', strict=False)
/home/bmcfee/git/jams/jams/pyjams.py:783: UserWarning: u'C#:modal' does not match u'^N|([A-G][b#]?)(:(major|minor|ionian|dorian|phrygian|lydian|mixolydian|aeolian|locrian))?$'
Failed validating u'pattern' in schema[u'properties'][u'value']:
{u'pattern': u'^N|([A-G][b#]?)(:(major|minor|ionian|dorian|phrygian|lydian|mixolydian|aeolian|locrian))?$',
u'type': u'string'}
On instance[u'value']:
u'C#:modal'
warnings.warn(str(invalid))
I'll investigate.
from jams.
Thanks titan.
from jams.
f284a75 ought to fix this
from jams.
Yay! Thanks!
from jams.
Related Issues (20)
- jam.validate() is True, but jam.save(path) crashes. Bug? HOT 2
- Feature Request: jams.convert(a, 'namespace'): from 'note_midi' to 'pitch_contour' HOT 7
- Support Decimal format/Quantization HOT 4
- notebook rendering does not work in jupyterlab HOT 3
- sed_eval bindings? HOT 6
- sortedcontainers updates
- display(meta=False) by default? HOT 2
- support jsonschema >= 3.0 HOT 3
- load jams mapping error? HOT 5
- More than one curator? HOT 13
- on possible (minor) tweaks to Annotation.to_samples HOT 6
- jams.load does not seem to work with one of your example files HOT 3
- support pytest 4.0
- `jams.Annotation.trim()` doesn't include events with 0 duration that's on the trim boundary HOT 4
- __get_dtype fails when type is list
- Global observations: avoid time/duration HOT 8
- tag_medleydb_instruments points to a 404 error HOT 3
- Next generation jams HOT 6
- display.events labels and lines are misaligned HOT 1
- Install fails on Python 3.12: `imp` Module Missing HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jams.