Skip to content

Input type issues in using Translator to translate from VRS #489

Description

@jsstevenson

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    VRS translatorIssues relating to translation of other expressions to/from VRSbugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions