Sage-Bionetworks / schematic

Package for biomedical data model and metadata ingress management
https://schematicpy.readthedocs.io/en/stable/cli_reference.html
MIT License
22 stars 25 forks source link

schematic model validate -js flag does not work #886

Open afwillia opened 2 years ago

afwillia commented 2 years ago

Describe the bug schematic model validate ignores the jsonld file provided by the -js flag. Instead, it always uses the model specified in the config file.

To Reproduce Steps to reproduce the behavior:

  1. Copy the data model in schematic/tests/data/example.model.jsonld to example.model.2.jsonld
  2. Create a mock Patient manifest
  3. Run schematic model --config ../config.yml validate -mp ../patient_manifest.csv -dt Patient -js example.model.2.jsonld

Priority (select one)

vpchung commented 2 years ago

For me, I also get the following error whenever I use the -js or --json_schema flag:

Traceback (most recent call last):
  File "/Users/vchung/Desktop/data_curator/.venv/bin/schematic", line 8, in <module>
    sys.exit(main())
  File "/Users/vchung/Desktop/data_curator/.venv/lib/python3.8/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/Users/vchung/Desktop/data_curator/.venv/lib/python3.8/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/Users/vchung/Desktop/data_curator/.venv/lib/python3.8/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Users/vchung/Desktop/data_curator/.venv/lib/python3.8/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Users/vchung/Desktop/data_curator/.venv/lib/python3.8/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Users/vchung/Desktop/data_curator/.venv/lib/python3.8/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/Users/vchung/Desktop/data_curator/.venv/lib/python3.8/site-packages/click/decorators.py", line 33, in new_func
    return f(get_current_context().obj, *args, **kwargs)
  File "/Users/vchung/Desktop/data_curator/.venv/lib/python3.8/site-packages/schematic/models/commands.py", line 224, in validate_manifest
    errors, warnings = metadata_model.validateModelManifest(
  File "/Users/vchung/Desktop/data_curator/.venv/lib/python3.8/site-packages/schematic/models/metadata.py", line 254, in validateModelManifest
    errors, warnings, manifest = validate_all(self, errors, warnings, manifest, manifestPath, self.sg, jsonSchema, restrict_rules, project_scope)
  File "/Users/vchung/Desktop/data_curator/.venv/lib/python3.8/site-packages/schematic/models/validate_manifest.py", line 273, in validate_all
    vmv_errors, vmv_warnings = vm.validate_manifest_values(manifest, jsonSchema)
  File "/Users/vchung/Desktop/data_curator/.venv/lib/python3.8/site-packages/schematic/models/validate_manifest.py", line 244, in validate_manifest_values
    v = Draft7Validator(jsonSchema)
  File "/Users/vchung/Desktop/data_curator/.venv/lib/python3.8/site-packages/jsonschema/validators.py", line 285, in __init__
    resolver = RefResolver.from_schema(schema, id_of=id_of)
  File "/Users/vchung/Desktop/data_curator/.venv/lib/python3.8/site-packages/jsonschema/validators.py", line 682, in from_schema
    return cls(base_uri=id_of(schema), referrer=schema, *args, **kwargs)
  File "/Users/vchung/Desktop/data_curator/.venv/lib/python3.8/site-packages/jsonschema/validators.py", line 156, in _id_of
    return schema.get(u"$id", u"")
AttributeError: 'str' object has no attribute 'get'

I'm on Python 3.8.1 and schematicpy 22.8.1.