def deserialize(workspace, data, oid, invalid=IGNORE):
    """
    Load a python dict as a GitModel instance.

    model: the model class representing the data

    data: a valid JSON string

    invalid: If a field cannot be coerced into its respective data type, a
             ``ValidationError`` will be raised. When ``invalid`` is ``ABORT``,
             this exception is re-raised. ``SET_EMPTY`` causes the value to be
             set to an empty value. ``IGNORE`` simply uses the raw value.
    """
    attrs = {'oid': oid}
    try:
        model = workspace.models[data['model']]
    except __HOLE__:
        raise ModelNotFound(data['model'])
    for field in model._meta.fields:
        value = data['fields'].get(field.name)
        # field.deserialize() calls field.to_python(). If a serialized value
        # cannot be coerced into the correct type for its field, just assign
        # the raw value.
        try:
            value = field.deserialize(data, value)
        except ValidationError:
            if invalid == SET_EMPTY:
                value = field.empty_value
            elif invalid == ABORT:
                raise
        attrs[field.name] = value
    return model(**attrs)
dataset/ETHPy150Open bendavis78/python-gitmodel/gitmodel/serializers/python.py/deserialize