Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

exception when calling get_default_metadata() #19

Open
gmabey opened this issue Jun 8, 2023 · 1 comment
Open

exception when calling get_default_metadata() #19

gmabey opened this issue Jun 8, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@gmabey
Copy link
Contributor

gmabey commented Jun 8, 2023

I don't use sigmf.validate.get_default_metadata() but it seems to be broken, in case someone wanted to use it:

glenm@glenm-OptiPlex-7070:~/src/sigmf-python$ ipython3 
Python 3.10.6 (main, May 29 2023, 11:10:38) [GCC 11.3.0]
Type 'copyright', 'credits' or 'license' for more information
IPython 7.31.1 -- An enhanced Interactive Python. Type '?' for help.

In [1]: import sigmf

In [2]: sigmf.validate.get_default_metadata()
---------------------------------------------------------------------------
ValidationError                           Traceback (most recent call last)
<ipython-input-2-16c967c76391> in <module>
----> 1 sigmf.validate.get_default_metadata()

~/src/sigmf-python/sigmf/validate.py in get_default_metadata(ref_schema)
     44     default = {}
     45     validator = extend_with_default(jsonschema.Draft7Validator)
---> 46     validator(ref_schema).validate(default)
     47     return default
     48 

/usr/lib/python3/dist-packages/jsonschema/validators.py in validate(self, *args, **kwargs)
    351         def validate(self, *args, **kwargs):
    352             for error in self.iter_errors(*args, **kwargs):
--> 353                 raise error
    354 
    355         def is_type(self, instance, type):

ValidationError: 'global' is a required property

or maybe I'm missing something here?

@Teque5
Copy link
Collaborator

Teque5 commented Jun 8, 2023

It says in the docstring for that function that it is currently broken. I believe the intent was to retrieve a vanilla metadata dictionary similar to how calling sigmf.SigMFFile() returns a basic dictionary:

SigMFFile({
    "global": {
        "core:num_channels": 1,
        "core:version": "1.1.1"
    },
    "captures": [],
    "annotations": []
})

In the validator the empty default should get filled with a more realistic default. Currently the above skeleton fails validation b/c it has no datatype defined, among other issues.

Perhaps get_default_metadata() should be removed.

@Teque5 Teque5 added the bug Something isn't working label Dec 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants