When I create an object according to the specifications in the yaml file, the optional slots (i.e., required: false) still show up as part of the object.
For example, in the nmdc schema, the class named thing is specified like so:
named thing:
description: "a databased entity or concept/class"
abstract: true
slots:
- id
- name
- description
- alternate identifiers
The alternative identifiers slots is specified like this:
Suppose, I create an instance of named thing using this code:
In [3]: import nmdc
In [5]: n1 = nmdc.NamedThing(id='id:1', name='object 1', description='test for named thing')
In [6]: n1
Out[6]: NamedThing(id='id:1', name='object 1', description='test for named thing', alternate_identifiers=[])
When I view the object, the alternative identifiers slot still shows up:
alternate_identifiers=[]
Do we want this slot to still be included in the instantiated object? I'm having to filter out the empty alternative identifier list when converting to a dict. E.g.:
In [4]: import jsonasobj
In [8]: jsonasobj.as_dict(n1)
Out[8]:
{'id': 'id:1',
'name': 'object 1',
'description': 'test for named thing',
'alternate_identifiers': []}
When I create an object according to the specifications in the yaml file, the optional slots (i.e., required: false) still show up as part of the object.
For example, in the nmdc schema, the class
named thing
is specified like so:The
alternative identifiers
slots is specified like this:Suppose, I create an instance of named thing using this code:
When I view the object, the alternative identifiers slot still shows up:
Do we want this slot to still be included in the instantiated object? I'm having to filter out the empty alternative identifier list when converting to a dict. E.g.: