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

Fixes determining resource path #811

Merged
merged 6 commits into from
Nov 18, 2021
Merged

Conversation

jasonb5
Copy link
Collaborator

@jasonb5 jasonb5 commented Nov 16, 2021

Adds a function to return a path to the package resources.
The function checks the following locations in order.

  1. Under CONDA_PREFIX (checks if path exists or continues)
  2. Using pkg_resources
  3. Current directory

@jasonb5 jasonb5 requested review from lee1043 and acordonez November 16, 2021 23:54
@jasonb5
Copy link
Collaborator Author

jasonb5 commented Nov 16, 2021

@acordonez After we merge this we can add a patch to the staged recipe.

@lee1043
Copy link
Contributor

lee1043 commented Nov 17, 2021

@jasonb5 thanks for the PR. The github action build test fails with following message, could you please check?

Traceback:
/usr/share/miniconda/envs/pcmdi_metrics_dev/lib/python3.9/importlib/__init__.py:127: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
tests/test_resources.py:4: in <module>
    from pcmdi_metrics import resources
E   ModuleNotFoundError: No module named 'pcmdi_metrics'

@jasonb5
Copy link
Collaborator Author

jasonb5 commented Nov 17, 2021

pytest fails while python -m pytest works, I'm guessing it's an issue with sys.path.

@tomvothecoder any idea why this might not be working, the workflow looks identical to xcdat's which works using just pytest.

- Fixes import issues with `test_resources.py`
- Remove `test_placeholder.py`
@tomvothecoder
Copy link
Collaborator

tomvothecoder commented Nov 17, 2021

@jasonb5 The tests directory was missing an __init__.py file so it was throwing ModuleNotFoundError.

I made a PR fix on your fork (jasonb5#1) to merge to this branch, which should fix the build on this PR.

@jasonb5
Copy link
Collaborator Author

jasonb5 commented Nov 17, 2021

@tomvothecoder Ah totally missed that, makes sense now. thanks

jasonb5 and others added 2 commits November 17, 2021 14:18
Copy link
Collaborator

@acordonez acordonez left a comment

Choose a reason for hiding this comment

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

Thank you Jason! The jupyter notebook demos all ran smoothly for me with this change.

@lee1043 lee1043 merged commit 811b939 into PCMDI:main Nov 18, 2021
@jasonb5 jasonb5 deleted the fix_pkg_resources branch November 18, 2021 01:06
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.

4 participants