biolink / biolinkml

DEPRECATED: replaced by linkml
https://github.com/linkml/linkml
Creative Commons Zero v1.0 Universal
23 stars 12 forks source link

Create prefixmapgen and update jsonldcontextgen #262

Closed rajshruti18 closed 3 years ago

rajshruti18 commented 4 years ago

Relates to https://github.com/biolink/biolink-model/issues/397. Updates jsonldcontextgen.py output and creates prefixmapgen.py which outputs prefixes mapping.

jiaola commented 4 years ago

@rajshruti18 You included many local venv and pyenv files in the PR. Can you clean them up and exclude them from the PR? Feel free to add them to .gitignore if necessary.

balhoff commented 4 years ago

@rajshruti18 rather than deleting the files here that already existed: https://github.com/biolink/biolinkml/pull/262/commits/f560524fecbdde2da0e9941f88c8c727b1e9860f

we need to revert to how they were before this PR.

balhoff commented 4 years ago

Don't merge yet — @rajshruti18 is working on modifying the prefix-map-gen output to be a simple map.

hsolbrig commented 4 years ago

See https://github.com/biolink/biolinkml/issues/230 for a bit more on the pyld transition

balhoff commented 4 years ago

@hsolbrig is there any downside to just outputting @prefix in all cases? It simplifies the code vs. needing to check the final character. Do we need a command-level option to be able to output a context without any @prefix tags (i.e. JSON-LD 1.0-compatible)? I would rather avoid that if there is no call for it.

hsolbrig commented 4 years ago

The down side is that it renders the context unreadable for the vast majority of the use cases that do conform to the specification to support the "edge cases" that don't. (Quotes because it appears that "http://..../ABC_" as a prefix is often used in the bio space, but almost never appears anywhere else)

I would much prefer mostly readable and not a speed bump for them that follow the rules.

How about an option: escape_uris -- Always, when needed, never? Be happy to tweak the code to do it

cmungall commented 3 years ago

any update on this?

balhoff commented 3 years ago

It would really help if someone could take it the last mile. Shruti will not be working for the next few weeks.

deepakunni3 commented 3 years ago

@hsolbrig @RichardBruskiewich Any thoughts on the recent changes?

hsolbrig commented 3 years ago

prefixmapgen.py fails when no default namespace is supplied. I'll catch this and try again

Warning: The following errors were encountered in the schema
======================================================================
ERROR: test_minimal_model (tests.test_issues.test_tccm_issues.TCCMTestCase)
Test to make the absolute minimal model work
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/runner/work/biolinkml/biolinkml/tests/test_issues/test_tccm_issues.py", line 66, in test_minimal_model
    env.generate_single_file(['issue_tccm', 'minimalmodel.' + generator.valid_formats[0]],
  File "/home/runner/work/biolinkml/biolinkml/tests/utils/test_environment.py", line 219, in generate_single_file
    actual = generator()
  File "/home/runner/work/biolinkml/biolinkml/tests/test_issues/test_tccm_issues.py", line 67, in <lambda>
    lambda: generator(env.input_path('issue_tccm', 'minimalmodel.yaml'),
  File "/home/runner/work/biolinkml/biolinkml/biolinkml/utils/generator.py", line 113, in serialize
    self.visit_schema(**kwargs)
  File "/home/runner/work/biolinkml/biolinkml/biolinkml/generators/prefixmapgen.py", line 50, in visit_schema
    default_uri = self.namespaces[self.default_ns]
  File "/home/runner/.local/share/virtualenvs/biolinkml-_uQ39J6a/lib/python3.8/site-packages/requests/structures.py", line 54, in __getitem__
    return self._store[key.lower()][1]
AttributeError: 'NoneType' object has no attribute 'lower'