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

FIX: ignore bonus unrelated modules found in py310 walk #558

Merged
merged 2 commits into from
Jul 12, 2023

Conversation

ZLLentz
Copy link
Member

@ZLLentz ZLLentz commented Jul 12, 2023

Description

Fix an issue where the cli benchmark package walk could discover an anaconda tests module in addition to the expected typhos submodules.

Motivation and Context

I noticed that our python 3.10 integration tests started failing for typhos with nonsensical import errors like typhos.tests.conda_env. It turns out that we were picking up site-packages/tests in the package walk starting from typhos:

In [3]: import typhos, pkgutil

In [4]: list(pkgutil.walk_packages(typhos.__path__))
Out[4]:
[ModuleInfo(module_finder=FileFinder('/cds/home/z/zlentz/github/typhos/typhos'), name='__main__', ispkg=False),
 ModuleInfo(module_finder=FileFinder('/cds/home/z/zlentz/github/typhos/typhos'), name='alarm', ispkg=False),
 ModuleInfo(module_finder=FileFinder('/cds/home/z/zlentz/github/typhos/typhos'), name='app', ispkg=False),
 ModuleInfo(module_finder=FileFinder('/cds/home/z/zlentz/github/typhos/typhos'), name='benchmark', ispkg=True),
 ModuleInfo(module_finder=FileFinder('/cds/home/z/zlentz/github/typhos/typhos'), name='cache', ispkg=False),
 ModuleInfo(module_finder=FileFinder('/cds/home/z/zlentz/github/typhos/typhos'), name='cli', ispkg=False),
 ModuleInfo(module_finder=FileFinder('/cds/home/z/zlentz/github/typhos/typhos'), name='display', ispkg=False),
 ModuleInfo(module_finder=FileFinder('/cds/home/z/zlentz/github/typhos/typhos'), name='examples', ispkg=True),
 ModuleInfo(module_finder=FileFinder('/cds/home/z/zlentz/github/typhos/typhos'), name='func', ispkg=False),
 ModuleInfo(module_finder=FileFinder('/cds/home/z/zlentz/github/typhos/typhos'), name='jira', ispkg=False),
 ModuleInfo(module_finder=FileFinder('/cds/home/z/zlentz/github/typhos/typhos'), name='panel', ispkg=False),
 ModuleInfo(module_finder=FileFinder('/cds/home/z/zlentz/github/typhos/typhos'), name='plugins', ispkg=True),
 ModuleInfo(module_finder=FileFinder('/cds/home/z/zlentz/github/typhos/typhos'), name='positioner', ispkg=False),
 ModuleInfo(module_finder=FileFinder('/cds/home/z/zlentz/github/typhos/typhos'), name='related_display', ispkg=False),
 ModuleInfo(module_finder=FileFinder('/cds/home/z/zlentz/github/typhos/typhos'), name='status', ispkg=False),
 ModuleInfo(module_finder=FileFinder('/cds/home/z/zlentz/github/typhos/typhos'), name='suite', ispkg=False),
 ModuleInfo(module_finder=FileFinder('/cds/home/z/zlentz/github/typhos/typhos'), name='tests', ispkg=True),
 ModuleInfo(module_finder=FileFinder('/cds/home/z/zlentz/miniconda3/envs/pcds-6.0.0/lib/python3.10/site-packages/tests'), name='tests.conda_env', ispkg=True),
 ModuleInfo(module_finder=FileFinder('/cds/home/z/zlentz/miniconda3/envs/pcds-6.0.0/lib/python3.10/site-packages/tests/conda_env'), name='tests.conda_env.installers', ispkg=True),
 ModuleInfo(module_finder=FileFinder('/cds/home/z/zlentz/miniconda3/envs/pcds-6.0.0/lib/python3.10/site-packages/tests/conda_env/installers'), name='tests.conda_env.installers.test_pip', ispkg=False),
 ModuleInfo(module_finder=FileFinder('/cds/home/z/zlentz/miniconda3/envs/pcds-6.0.0/lib/python3.10/site-packages/tests/conda_env'), name='tests.conda_env.specs', ispkg=True),
 ModuleInfo(module_finder=FileFinder('/cds/home/z/zlentz/miniconda3/envs/pcds-6.0.0/lib/python3.10/site-packages/tests/conda_env/specs'), name='tests.conda_env.specs.test_base', ispkg=False),
 ModuleInfo(module_finder=FileFinder('/cds/home/z/zlentz/miniconda3/envs/pcds-6.0.0/lib/python3.10/site-packages/tests/conda_env/specs'), name='tests.conda_env.specs.test_binstar', ispkg=False),
 ModuleInfo(module_finder=FileFinder('/cds/home/z/zlentz/miniconda3/envs/pcds-6.0.0/lib/python3.10/site-packages/tests/conda_env/specs'), name='tests.conda_env.specs.test_requirements', ispkg=False),
 ModuleInfo(module_finder=FileFinder('/cds/home/z/zlentz/miniconda3/envs/pcds-6.0.0/lib/python3.10/site-packages/tests/conda_env/specs'), name='tests.conda_env.specs.test_yaml_file', ispkg=False),
 ModuleInfo(module_finder=FileFinder('/cds/home/z/zlentz/miniconda3/envs/pcds-6.0.0/lib/python3.10/site-packages/tests/conda_env'), name='tests.conda_env.test_cli', ispkg=False),
 ModuleInfo(module_finder=FileFinder('/cds/home/z/zlentz/miniconda3/envs/pcds-6.0.0/lib/python3.10/site-packages/tests/conda_env'), name='tests.conda_env.test_create', ispkg=False),
 ModuleInfo(module_finder=FileFinder('/cds/home/z/zlentz/miniconda3/envs/pcds-6.0.0/lib/python3.10/site-packages/tests/conda_env'), name='tests.conda_env.test_env', ispkg=False),
 ModuleInfo(module_finder=FileFinder('/cds/home/z/zlentz/miniconda3/envs/pcds-6.0.0/lib/python3.10/site-packages/tests/conda_env'), name='tests.conda_env.test_pip_util', ispkg=False),
 ModuleInfo(module_finder=FileFinder('/cds/home/z/zlentz/miniconda3/envs/pcds-6.0.0/lib/python3.10/site-packages/tests/conda_env'), name='tests.conda_env.utils', ispkg=False),
 ModuleInfo(module_finder=FileFinder('/cds/home/z/zlentz/github/typhos/typhos'), name='textedit', ispkg=False),
 ModuleInfo(module_finder=FileFinder('/cds/home/z/zlentz/github/typhos/typhos'), name='tools', ispkg=True),
 ModuleInfo(module_finder=FileFinder('/cds/home/z/zlentz/github/typhos/typhos'), name='tweakable', ispkg=False),
 ModuleInfo(module_finder=FileFinder('/cds/home/z/zlentz/github/typhos/typhos'), name='utils', ispkg=False),
 ModuleInfo(module_finder=FileFinder('/cds/home/z/zlentz/github/typhos/typhos'), name='variety', ispkg=False),
 ModuleInfo(module_finder=FileFinder('/cds/home/z/zlentz/github/typhos/typhos'), name='version', ispkg=False),
 ModuleInfo(module_finder=FileFinder('/cds/home/z/zlentz/github/typhos/typhos'), name='web', ispkg=False),
 ModuleInfo(module_finder=FileFinder('/cds/home/z/zlentz/github/typhos/typhos'), name='widgets', ispkg=False)]

This must be a pkgutil bug but I cba to do anything about it except switch to a better API for submodule discovery. I'm passively on the hunt for one now.

How Has This Been Tested?

Interactively by making the unit tests pass again and verifying that the function output still looks correct.

Where Has This Been Documented?

n/a

@ZLLentz ZLLentz requested review from klauer and tangkong July 12, 2023 00:23
@ZLLentz
Copy link
Member Author

ZLLentz commented Jul 12, 2023

Looking more closely, I think this only happens if the mysterious tests module gets installed. I'm not sure which package or packages provide this directory (intentionally or unintentionally).

As such, this shouldn't be reflected in the local test suite here at all- but I tested this offline with a full py310 pcds conda environment.

Copy link
Contributor

@tangkong tangkong left a comment

Choose a reason for hiding this comment

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

LGTM. I wonder if this was why my py3.10 tests were hanging for so long.

Copy link
Contributor

@klauer klauer left a comment

Choose a reason for hiding this comment

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

Interesting - it makes sense that the benchmarking code would pick up a package named 'tests', import it, and then pytest would see it and try to run its tests.

The fix looks good to me 👍

@ZLLentz ZLLentz merged commit ee4da32 into pcdshub:master Jul 12, 2023
7 of 9 checks passed
@ZLLentz ZLLentz deleted the fix_py310_benchmark branch July 12, 2023 16:13
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