Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

avoid deprecated pkg_resources #173

Merged
merged 10 commits into from
Mar 18, 2024

Conversation

mashehu
Copy link
Contributor

@mashehu mashehu commented Jan 24, 2024

I think it is unrlated: but test are not running locally due to:

ImportError while loading conftest '/Users/matho180/ro-crate-py/test/conftest.py'.
test/conftest.py:24: in <module>
    from rocrate.utils import get_norm_value
rocrate/__init__.py:54: in <module>
    import arcp  # noqa
E   ModuleNotFoundError: No module named 'arcp'

(I can import the module if I start python manually)

@simleo
Copy link
Collaborator

simleo commented Mar 5, 2024

It is related, since without this PR tests run fine locally. I get a different error:

ImportError while loading conftest '/home/simleo/git/ro-crate-py/test/conftest.py'.
test/conftest.py:24: in <module>
    from rocrate.utils import get_norm_value
rocrate/__init__.py:57: in <module>
    from .model.metadata import Metadata  # noqa
rocrate/model/__init__.py:28: in <module>
    from .computationalworkflow import ComputationalWorkflow, WorkflowDescription, Workflow
rocrate/model/computationalworkflow.py:27: in <module>
    from .file import File
rocrate/model/file.py:28: in <module>
    from .file_or_dir import FileOrDir
rocrate/model/file_or_dir.py:24: in <module>
    from .data_entity import DataEntity
rocrate/model/data_entity.py:22: in <module>
    from .entity import Entity
rocrate/model/entity.py:25: in <module>
    from .. import vocabs
rocrate/vocabs.py:25: in <module>
    RO_CRATE = json.loads(importlib.resources.read_text(__name__, "data/ro-crate.jsonld"))
E   TypeError: 'rocrate.vocabs' is not a package

It's not just local tests that are broken, the rocrate executable is affected as well.

@simleo simleo closed this Mar 5, 2024
@simleo simleo reopened this Mar 5, 2024
@simleo
Copy link
Collaborator

simleo commented Mar 5, 2024

It turns out that automated tests also fail. However, the error is different:

ImportError while loading conftest '/home/runner/work/ro-crate-py/ro-crate-py/test/conftest.py'.
test/conftest.py:24: in <module>
    from rocrate.utils import get_norm_value
rocrate/__init__.py:57: in <module>
    from .model.metadata import Metadata  # noqa
rocrate/model/__init__.py:2[8](https://github.com/ResearchObject/ro-crate-py/actions/runs/8158453547/job/22300413292?pr=173#step:6:9): in <module>
    from .computationalworkflow import ComputationalWorkflow, WorkflowDescription, Workflow
rocrate/model/computationalworkflow.py:27: in <module>
    from .file import File
rocrate/model/file.py:28: in <module>
    from .file_or_dir import FileOrDir
rocrate/model/file_or_dir.py:24: in <module>
    from .data_entity import DataEntity
rocrate/model/data_entity.py:22: in <module>
    from .entity import Entity
rocrate/model/entity.py:25: in <module>
    from .. import vocabs
rocrate/vocabs.py:25: in <module>
    RO_CRATE = json.loads(importlib.resources.read_text(__name__, "data/ro-crate.jsonld"))
E   ValueError: 'data/ro-crate.jsonld' must be only a file name

rocrate/vocabs.py Outdated Show resolved Hide resolved
Co-authored-by: Eli Chadwick <eli.chadwick@manchester.ac.uk>
@elichad
Copy link
Contributor

elichad commented Mar 12, 2024

Agh, importlib.resources.files was only introduced in Python 3.9, but the older option of importlib.resources.read_text() doesn't support the .jsonld files being inside a directory. Possible solutions: we could move those files out of data/, or split the strategy for different Python versions, or just avoid making this change until Python 3.8 goes out of support later this year...

@simleo
Copy link
Collaborator

simleo commented Mar 12, 2024

I went for the split strategy but got unrelated errors in the CI

@simleo
Copy link
Collaborator

simleo commented Mar 14, 2024

The errors on the Mac instances are actually unrelated to any code change, see #176

@simleo
Copy link
Collaborator

simleo commented Mar 15, 2024

OK, it looks like this is finally working. @mashehu @elichad since you're both new contributors, before I merge I need you to update the authors section in CITATION.cff. I need also your copyright lines to update the headers -- @elichad in your case I think we already have it (University of Manchester).

@elichad
Copy link
Contributor

elichad commented Mar 18, 2024

@simleo I added my name, and yes my affiliation is already covered for the copyright.

.gitpod.yml Outdated
@@ -0,0 +1,10 @@
# This configuration file was automatically generated by Gitpod.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need this file? Looks like it might have been included by mistake

@simleo simleo merged commit 70f9cfe into ResearchObject:master Mar 18, 2024
12 checks passed
@mashehu mashehu deleted the replace-deprecated-pkg_resources branch March 20, 2024 07:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants