From 3b353574ffaa411381de1620cce74fc2f7fa66ab Mon Sep 17 00:00:00 2001 From: maclandrol Date: Fri, 26 Jan 2024 14:39:07 -0500 Subject: [PATCH 1/4] add init file for very edge case --- medchem/data/__init__.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 medchem/data/__init__.py diff --git a/medchem/data/__init__.py b/medchem/data/__init__.py new file mode 100644 index 0000000..e69de29 From f21450391f3411125e3e8a55a464037e49c714d7 Mon Sep 17 00:00:00 2001 From: maclandrol Date: Fri, 26 Jan 2024 14:54:46 -0500 Subject: [PATCH 2/4] fix edge cases of data loader --- medchem/utils/loader.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/medchem/utils/loader.py b/medchem/utils/loader.py index e0e988f..464457b 100644 --- a/medchem/utils/loader.py +++ b/medchem/utils/loader.py @@ -4,8 +4,13 @@ import os import io +import sys import functools -import importlib.resources + +try: + import importlib.resources as importlib_resources +except ImportError: + import importlib_resources import fsspec @@ -14,7 +19,12 @@ def get_data_path(filename: str, module: str = "medchem.data"): """Return the filepath of an internal data file.""" - path = importlib.resources.files(module).joinpath(filename) + if sys.version_info < (3, 9, 0): + with importlib_resources.path(module, filename) as p: + path = p + else: + path = importlib_resources.files(module).joinpath(filename) + return str(path) @@ -29,7 +39,7 @@ def get_grammar( as_string: If True, return the grammar as a string. Defaults to False. """ if grammar is None: - _grammar = importlib.resources.files("medchem.data").joinpath("grammar.lark") + _grammar = get_data_path("grammar.lark") _grammar = str(_grammar) else: _grammar = str(grammar) From 82063acb3b850a10c0fb5e7d8e6574c5efe57a65 Mon Sep 17 00:00:00 2001 From: maclandrol Date: Fri, 26 Jan 2024 15:44:58 -0500 Subject: [PATCH 3/4] wip --- medchem/data/charge_assigner/__init__.py | 0 medchem/data/complexity/__init__.py | 0 medchem/data/queries/__init__.py | 0 medchem/utils/loader.py | 1 - 4 files changed, 1 deletion(-) create mode 100644 medchem/data/charge_assigner/__init__.py create mode 100644 medchem/data/complexity/__init__.py create mode 100644 medchem/data/queries/__init__.py diff --git a/medchem/data/charge_assigner/__init__.py b/medchem/data/charge_assigner/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/medchem/data/complexity/__init__.py b/medchem/data/complexity/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/medchem/data/queries/__init__.py b/medchem/data/queries/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/medchem/utils/loader.py b/medchem/utils/loader.py index 464457b..62b5b60 100644 --- a/medchem/utils/loader.py +++ b/medchem/utils/loader.py @@ -24,7 +24,6 @@ def get_data_path(filename: str, module: str = "medchem.data"): path = p else: path = importlib_resources.files(module).joinpath(filename) - return str(path) From a389c84d3fc1d2a1dfa4b5b1d60844d4403de2ef Mon Sep 17 00:00:00 2001 From: maclandrol Date: Fri, 26 Jan 2024 15:54:38 -0500 Subject: [PATCH 4/4] change matrix test to use 3.9 rather than 3.10 --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 082bf65..a9be2df 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -16,7 +16,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: ["3.10", "3.11"] + python-version: ["3.9", "3.11"] runs-on: "ubuntu-latest" timeout-minutes: 30