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

Try removing importlib - breaks multiprocess pickling #746

Merged
merged 2 commits into from
Jul 1, 2024

Conversation

rayg1234
Copy link
Collaborator

@rayg1234 rayg1234 commented Jun 28, 2024

importlib is breaking multiprocess pickling.

pytest locally works for tests that uses python multiprocess:
eg: pytest tests/core/common/test_gp_utils.py (from eq2_graph_parallel branch)

but on CI, which uses ./packages/fairchem-core/pyproject.toml was breaking with errors like:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/private/home/rgao/micromamba/envs/fair-chem/lib/python3.11/multiprocessing/spawn.py", line 122, in spawn_main
    exitcode = _main(fd, parent_sentinel)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/private/home/rgao/micromamba/envs/fair-chem/lib/python3.11/multiprocessing/spawn.py", line 132, in _main
    self = reduction.pickle.load(from_parent)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ModuleNotFoundError: No module named 'private'

I traced this back to the option --import-mode importlib in the pytest tool.pytest.ini_options config. This somehow prevents pickling python modules correctly. I tried disabling this seems have no effect on tests and creates more consistency between local development and CI.

@rayg1234 rayg1234 closed this Jun 28, 2024
@rayg1234 rayg1234 reopened this Jun 28, 2024
Copy link

codecov bot commented Jun 28, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

@rayg1234 rayg1234 requested review from kjmichel and lbluque June 28, 2024 22:30
@rayg1234 rayg1234 changed the title [Testing] try removing importlib Try removing importlib Jun 28, 2024
@rayg1234 rayg1234 changed the title Try removing importlib Try removing importlib - breaks multiprocess pickling Jun 28, 2024
Copy link
Collaborator

@lbluque lbluque left a comment

Choose a reason for hiding this comment

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

This looks good to me, as long as we keep in mind to keep all test module names unique.
https://docs.pytest.org/en/7.1.x/explanation/pythonpath.html

@rayg1234 rayg1234 added this pull request to the merge queue Jul 1, 2024
Merged via the queue into main with commit 8c3e6d1 Jul 1, 2024
5 checks passed
@rayg1234 rayg1234 deleted the rgao_remove_importlib branch July 1, 2024 15:56
levineds pushed a commit that referenced this pull request Jul 11, 2024
Co-authored-by: Luis Barroso-Luque <[email protected]>
misko pushed a commit that referenced this pull request Jan 17, 2025
Co-authored-by: Luis Barroso-Luque <[email protected]>
Former-commit-id: daf1b9a66ac99ee09abe0760f5f8088ebeb01eff
beomseok-kang pushed a commit to beomseok-kang/fairchem that referenced this pull request Jan 27, 2025
Co-authored-by: Luis Barroso-Luque <[email protected]>
Former-commit-id: d9f60668dc34c4ffad0328d21719d1913a8ce770
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.

2 participants