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

some tests failed on macOS #154

Closed
natsukium opened this issue May 12, 2023 · 3 comments
Closed

some tests failed on macOS #154

natsukium opened this issue May 12, 2023 · 3 comments

Comments

@natsukium
Copy link

Hi, thanks for developing this awesome project.

Version :

4.0.0

Describe the bug :

I tried to use truvari on macOS, and when I ran the test, I got the following error.

error log
test_anno_grm ran in 2 sec with 34/0 lines to STDERR/OUT
 FAIL EXIT CODE (LINE 59)
-->     expected EX_OK, observed Unknown code: 1
    data = pd.concat(chunks, ignore_index=True)
  File "/nix/store/jhjlf5yy6ar5g7jl363pxzk6fqxwzj5s-python3.10-pandas-1.5.3/lib/python3.10/site-packages/pandas/util/_decorators.py", line 331, in wrapper
    return func(*args, **kwargs)
  File "/nix/store/jhjlf5yy6ar5g7jl363pxzk6fqxwzj5s-python3.10-pandas-1.5.3/lib/python3.10/site-packages/pandas/core/reshape/concat.py", line 368, in concat
    op = _Concatenator(
  File "/nix/store/jhjlf5yy6ar5g7jl363pxzk6fqxwzj5s-python3.10-pandas-1.5.3/lib/python3.10/site-packages/pandas/core/reshape/concat.py", line 422, in __init__
    objs = list(objs)
  File "/nix/store/v6f6y9mwmqj9v1jffiy4g96ili4pj5la-python3-3.10.11/lib/python3.10/multiprocessing/pool.py", line 873, in next
    raise value
AttributeError: 'types.SimpleNamespace' object has no attribute 'ref_filename'

test_anno_grm ran in 0 sec with 5/0 lines to STDERR/OUT
 FAIL EXIT CODE (LINE 48)
-->     expected EX_OK, observed Unknown code: 1
Traceback (most recent call last):
  File "<string>", line 4, in <module>
  File "/nix/store/kwv7hx63pw3djbd5ryk8365v25lh1ka6-python3.10-joblib-1.2.0/lib/python3.10/site-packages/joblib/numpy_pickle.py", line 650, in load
    with open(filename, 'rb') as f:
FileNotFoundError: [Errno 2] No such file or directory: 'test_results/grm.jl'

test_anno_trf ran in 2 sec with 26/0 lines to STDERR/OUT
 FAIL EXIT CODE (LINE 72)
-->     expected EX_OK, observed Unknown code: 1
    main()
  File "/private/tmp/nix-build-truvari-4.0.0.drv-0/source/truvari/__main__.py", line 102, in main
    TOOLS[args.cmd](args.options)
  File "/private/tmp/nix-build-truvari-4.0.0.drv-0/source/truvari/anno.py", line 59, in anno_main
    ANNOS[args.cmd][1](args.options)
  File "/private/tmp/nix-build-truvari-4.0.0.drv-0/source/truvari/annotations/trf.py", line 658, in trf_main
    for i in chunks:
  File "/nix/store/v6f6y9mwmqj9v1jffiy4g96ili4pj5la-python3-3.10.11/lib/python3.10/multiprocessing/pool.py", line 873, in next
    raise value
AttributeError: 'types.SimpleNamespace' object has no attribute 'args'

test_anno_trf_reg ran in 2 sec with 26/0 lines to STDERR/OUT
 FAIL EXIT CODE (LINE 83)
-->     expected EX_OK, observed Unknown code: 1
    main()
  File "/private/tmp/nix-build-truvari-4.0.0.drv-0/source/truvari/__main__.py", line 102, in main
    TOOLS[args.cmd](args.options)
  File "/private/tmp/nix-build-truvari-4.0.0.drv-0/source/truvari/anno.py", line 59, in anno_main
    ANNOS[args.cmd][1](args.options)
  File "/private/tmp/nix-build-truvari-4.0.0.drv-0/source/truvari/annotations/trf.py", line 658, in trf_main
    for i in chunks:
  File "/nix/store/v6f6y9mwmqj9v1jffiy4g96ili4pj5la-python3-3.10.11/lib/python3.10/multiprocessing/pool.py", line 873, in next
    raise value
AttributeError: 'types.SimpleNamespace' object has no attribute 'args'

After a bit of research, I found out that it is caused by how the process is started in the multiprocessing module.
(ref: https://docs.python.org/3/library/multiprocessing.html#contexts-and-start-methods)
I changed it from the macOS default of spawn to the Linux default of fork, and the tests passed.

To Reproduce :

Run bash repo_utils/truvari_sshtests.sh on macOS.

Expected behavior :

All tests pass.

Example Data :

Additional context :

The full log is here.
https://hydra.nixos.org/build/219117259/log

ACEnglish added a commit that referenced this issue May 12, 2023
@ACEnglish
Copy link
Owner

Thank you for reporting this. I'm sure it wasn't easy to solve. I was able to recreate the issue and confirm that having multiprocessing.set_start_method('fork') before with multiprocessing.Pool.. calls can get tests to pass.

However, I don't think changing the set_start_method is a viable solution. The python docs state:

Changed in version 3.8: On macOS, the spawn start method is now the default. The fork start method should be considered unsafe as it can lead to crashes of the subprocess. See bpo-33725.

Possible solutions:

  • Make it clear that some truvari anno commands will fail on macOS
  • Make it clear that truvari is designed on/for unix and recommend docker (which is how I run truvari tests on my mac).
  • Change design pattern to not depending on 'fork' sharing semantics. Specifically it's the global namespace.

And as I'm digging deeper into bpo-33725 and the issues it references, I'm thinking changing the code might need to be the solution as this non-explicit sharing may become not possible in a future python version.. maybe.

ACEnglish added a commit that referenced this issue May 12, 2023
No longer using global simplenamespace to pass around arguments in trf.
GRM will need more testing to ensure BwaAligner is fine being initialized per-thread.
@natsukium
Copy link
Author

Thanks for your response.

However, I don't think changing the set_start_method is a viable solution.

Yes, I don't think using set_start_method is a good way to fix it.

and thank you for starting the fix as quickly.
Let me know if I can help in any way.

ACEnglish added a commit that referenced this issue May 13, 2023
`repo_utils/truvari_ssshtests.sh test_anno_grm` passes on mac
@ACEnglish
Copy link
Owner

Functional tests off of develop now pass on mac. If you're still seeing a problem, please re-open this ticket.

These changes will be present in v4.1. However It'll be some time before that release is cut as there's at least two more features to add and a lot of user testing happening for a publication tied to the next version.

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

No branches or pull requests

2 participants