This code here tries to subscript into models, which is a module, on line 132. This obviously leads to an error:
|
def _from_vrs(self, var): |
|
"""Convert from dict representation of VRS JSON to VRS object""" |
|
if not isinstance(var, Mapping): |
|
return None |
|
if "type" not in var: |
|
return None |
|
try: |
|
model = models[var["type"]] |
|
except KeyError: |
|
return None |
|
return model(**var) |
I think a bigger problem is inconsistency about expected inputs. The other translators take variant expressions as strings, but translating from VRS seems to try to handle either dicts or Pydantic objects (realistically, probably actually PythonJsonSchemaObjects, not Pydantic). I think it'd be better to maybe expect input to be a JSON object serialized into a string, just to remain consistent and avoid these kinds of issues.
This code here tries to subscript into
models, which is a module, on line 132. This obviously leads to an error:vrs-python/src/ga4gh/vrs/extras/translator.py
Lines 125 to 135 in f38cbca
I think a bigger problem is inconsistency about expected inputs. The other translators take variant expressions as strings, but translating from VRS seems to try to handle either dicts or Pydantic objects (realistically, probably actually PythonJsonSchemaObjects, not Pydantic). I think it'd be better to maybe expect input to be a JSON object serialized into a string, just to remain consistent and avoid these kinds of issues.