Skip to content

Commit

Permalink
Removes unnecessary external_context.py, clean Makefile & update de…
Browse files Browse the repository at this point in the history
…pendencies. (mapping-commons#394)

* Removes unnecessary `external_context.py` and clean Makefile.

* Fixed get_external_jsonld_context()

* test change

* Moved scipy to extras

* Changed package dependencies from ^ to >= fixes mapping-commons#392

* flake8 ed

* ran poetry update and all work.
  • Loading branch information
hrshdhgd authored Jul 18, 2023
1 parent dc13f36 commit 70a14b1
Show file tree
Hide file tree
Showing 7 changed files with 671 additions and 404 deletions.
24 changes: 2 additions & 22 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ schema/cliquesummary.py: schema/cliquesummary.yaml
gen-py-classes $< > $@
schema/%.schema.json: .FORCE
wget $(SSSOM_JSON_SCHEMA) -O $@
schema/sssom.external.context.jsonld:
src/sssom/sssom.external.context.jsonld:
wget $(DEFAULT_PREFIX_MAP) -O $@
schema/%.context.jsonld: .FORCE
wget $(SSSOM_JSONLD_CONTEXT) -O $@
Expand All @@ -33,28 +33,8 @@ test:
tox
sh tests/tests.sh

src/sssom/external_context.py: schema/sssom.external.context.jsonld
echo "\"\"\"This module contains an autogenerated copy of the external SSSOM context.\"\"\"" > $@
echo "" >> $@
echo "# This is autogenerated and super hacky." >> $@
echo "sssom_external_context = \"\"\"" >> $@
cat $< >> $@
echo "\"\"\"" >> $@
black $@

src/sssom/internal_context.py: schema/sssom.context.jsonld
echo "\"\"\"This module contains an autogenerated copy of the internal SSSOM context.\"\"\"" > $@
echo "" >> $@
echo "sssom_context = \"\"\"" >> $@
cat $< >> $@
echo "\"\"\"" >> $@

deploy-dm: src/sssom/external_context.py src/sssom/internal_context.py
cp schema/sssom_datamodel.py src/sssom/
cp schema/sssom.context.jsonld src/sssom/
cp schema/sssom.external.context.jsonld src/sssom/
deploy-dm: src/sssom/sssom.external.context.jsonld


install:
pip install .[test,docs]

Expand Down
410 changes: 209 additions & 201 deletions poetry.lock

Large diffs are not rendered by default.

22 changes: 11 additions & 11 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,18 @@ python = "^3.8"
click = "*"
importlib-metadata = ">=4.8.0"
pyparsing = "^3.0.9"
bioregistry = "^0.9.43"
deprecation = "^2.1.0"
linkml-runtime = "^1.5.3"
networkx = "^3.1"
pandas = "^2.0.2"
bioregistry = ">=0.9.43"
deprecation = ">=2.1.0"
linkml-runtime = ">=1.5.3"
networkx = ">=3.1"
pandas = ">=2.0.2"
pansql = "^0.0.1"
pyyaml = "^6.0"
rdflib = "^6.3.2"
sparqlwrapper = "^2.0.0"
sssom-schema = "^0.13.0"
validators = "^0.20.0"
scipy = "*"
pyyaml = ">=6.0"
rdflib = ">=6.3.2"
sparqlwrapper = ">=2.0.0"
sssom-schema = ">=0.13.0"
validators = ">=0.20.0"
scipy = {version = "*", extras = ["scipy"]}

[tool.poetry.group.dev.dependencies]
pytest = {version = ">=7.1.2"}
Expand Down
1 change: 1 addition & 0 deletions src/sssom/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
HERE = pathlib.Path(__file__).parent.resolve()

SCHEMA_YAML = pkg_resources.resource_filename("sssom_schema", "schema/sssom_schema.yaml")
EXTERNAL_CONTEXT = HERE / "sssom.external.context.jsonld"

# SCHEMA_VIEW = package_schemaview("sssom_schema")

Expand Down
7 changes: 5 additions & 2 deletions src/sssom/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@

import pkg_resources

from .external_context import sssom_external_context
from sssom.constants import EXTERNAL_CONTEXT

from .typehints import Metadata, MetadataType, PrefixMap

# HERE = pathlib.Path(__file__).parent.resolve()
Expand Down Expand Up @@ -41,7 +42,9 @@ def get_external_jsonld_context():
:return: JSON-LD context
"""
return json.loads(sssom_external_context, strict=False)
with open(str(EXTERNAL_CONTEXT), "r") as f:
data = json.load(f, strict=False)
return data


def get_built_in_prefix_map() -> PrefixMap:
Expand Down
609 changes: 442 additions & 167 deletions src/sssom/external_context.py → src/sssom/sssom.external.context.jsonld

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion tests/test_parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def test_parse_obographs(self):
write_table(msdf, file)
self.assertEqual(
len(msdf.df),
9880,
9879,
f"{self.obographs_file} has the wrong number of mappings.",
)

Expand Down

0 comments on commit 70a14b1

Please sign in to comment.