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

pythonPackages.pysam: add libdeflate and enable tests #100823

Merged
merged 1 commit into from Oct 20, 2020

Conversation

unode
Copy link
Member

@unode unode commented Oct 17, 2020

Motivation for this change

Tests are currently not enabled and upstream is not always in sync with the latest samtools/htslib versions leading to some incompatibilities.
Tests that are known to fail have been reported upstream and disabled/deselected here.

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS linux)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.

@unode
Copy link
Member Author

unode commented Oct 17, 2020

This request goes along with #100812 and #100814 that also update all related dependencies to have a consistent version (1.11)

@unode
Copy link
Member Author

unode commented Oct 17, 2020

Can any of you test if the current commit succeeds on your end?
I applied the changes suggested above and I started getting:

    import pysam
pysam/__init__.py:5: in <module>
    from pysam.libchtslib import *
E   ModuleNotFoundError: No module named 'pysam.libchtslib'

I also got this failure while reviewing #100654 but @jonringer reported success there.
The build also includes pysam in pythonImportCheck so I don't understand why it worked. I assumed it was some misconfiguration on my side. This was also the reason why I decided to try to enable the tests here.

I now also made pysam use the nixpkgs htslib instead of the bundled one, but the error was already present before this change.

@unode unode force-pushed the pysam branch 2 times, most recently from 14768be to c7e0e55 Compare October 17, 2020 20:56
@jonringer
Copy link
Contributor

jonringer commented Oct 17, 2020

I also got this failure while reviewing #100654 but @jonringer reported success there.
The build also includes pysam in pythonImportCheck so I don't understand why it worked. I assumed it was some misconfiguration on my side. This was also the reason why I decided to try to enable the tests here.

sometimes if you have a local directory with the module name, ./pysam/, python will prefer to attempt to import from there, however, that's generally not what you want.

usually I do something like:

  preCheck = ''
    rm -r pysam
  '';

@unode
Copy link
Member Author

unode commented Oct 18, 2020

  preCheck = ''
    rm -r pysam
  '';

Added this and pytest stopped finding any test.

============================= test session starts ==============================
platform linux -- Python 3.8.6, pytest-5.4.3, py-1.9.0, pluggy-0.13.1 -- /nix/store/346skv0d24rqnf4npknbp9h5bs14j8zy-python3-3.8.6/bin/python3.8
cachedir: .pytest_cache
rootdir: /build/source, inifile: setup.cfg, testpaths: pysam, tests
collected 0 items                                                              

============================ no tests ran in 0.00s =============================
ERROR: file not found: pysam

Then adding pytestFlagsArray = [ "tests/" ]; fails with:

Traceback:
tests/test_samtools_python.py:1: in <module>
    import pysam
pysam.py:1: in <module>
    raise ImportError('''calling "import pysam" from the source directory is not supported - please import pysam from somewhere else.''')
E   ImportError: calling "import pysam" from the source directory is not supported - please import pysam from somewhere else.

This happens because tests are launched with ../python -m pytest ... and pysam seems to not like to be loaded this way.
Oddly enough running the exact same command with pytest ... instead of python -m pytest works.

I feel I'm getting deeper and deeper into rabbit holes with this... Can I somehow tell nix to use the pytest command instead of python -m pytest without overriding pytestCheckPhase and losing the benefits of disabledTests ?

@unode
Copy link
Member Author

unode commented Oct 18, 2020

Ok, I'm reverting the use of pytestCheckHook due to the two issues above:

  • pysam detecting how its loaded and raising an exception when loaded by pytest launched with python -m pytest.
  • disableTests ignoring more tests than the failing ones (52 instead of 11).

I'll revisit this in the future if pytestCheckHook adds additional mechanisms to customize how tests are executed.

Some tests still fail due to upstream reasons so we skip those.

Note also that we are not using nix's pytestCheckHook due to
pysam detecting how it's loaded which conflicts with how
pytestCheckHook runs tests. In addition, the selection mode used
by disabledTests causes more tests than the failing ones to be
skipped, which is undesired.
See the discussion in NixOS#100823
@unode
Copy link
Member Author

unode commented Oct 18, 2020

Thanks everyone and in particular @jonringer for detailed reviewing and lots of feedback and guidance.

Copy link
Contributor

@jonringer jonringer left a comment

Choose a reason for hiding this comment

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

LGTM

https://github.com/NixOS/nixpkgs/pull/100823
12 packages built:
deeptools lumpy python27Packages.HTSeq python27Packages.pysam python37Packages.HTSeq python37Packages.cnvkit python37Packages.pysam python38Packages.HTSeq python38Packages.cnvkit python38Packages.pysam tebreak truvari

@jonringer jonringer merged commit 0a41e3f into NixOS:master Oct 20, 2020
@unode unode deleted the pysam branch May 18, 2023 12:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants