Closed theferrit32 closed 1 year ago
Waiting until verified to work for Haplotype and Genotype
Are you able to make use of some of the Pydantic serializing tools? I guess this would be complicated to insert into generated code (maybe a custom jinja template or something? might get messy quick)
At the moment we aren't using any of the serializing functionality other than .model_dump(exclude_none=True)
.
I think we won't be using class generator anymore going forwards unless we also change how we note the identifier prefixes and keys for each Model class, so I'm not opposed to using other manually added annotations like these if they bring useful functionality. Since the ga4gh_serialize
function is in the ga4gh.core
namespace, and the models are in ga4gh.vrs
, it is nice that the Model classes carry with them all the necessary info to create identifiers and do the serialization, so there is no dependency from ga4gh.core -> ga4gh.vrs
(there used to be a dependency from ga4gh.core
to the VRS jsonschema file, but not anymore).
Implemented in 2-alpha
Discussion with @toneillbroad and @larrybabb today.
EDIT: will be updating this requirement spec
Since some objects like Genotype have fields which are key fields but which are not identifiable but which themselves have fields which are identifiable we need a more generic/broad approach to recursing to nested objects in the ga4gh_serialize function than just looking at the
<Model>.ga4gh_digest.keys
andga4gh.vrs.models.class_refatt_map
The presence of a
ga4gh_digest
property on a Model class will indicate that that Model is an identifiable type.The
keys
property inga4gh_digest
will indicate which fields on a Model object instance will be included in the canonicaljson used as input to its digest.The ga4gh_serialize recursion will be called on the value of any key field which is a Model or map type, or each element of a key field which is a non-map collection type (list, set, tuple, etc) (e.g.
Genotype.members
). The recursive base case will be to first check will be whether the input value is a map or Model object. If it is not, the input will be returned immediately. This will traverse the whole object structure instead of only traversing fields inclass_refatt_map
as was previously the case. (which will enable reachingGenotype.members[].variation
without special logic)