Unverified Commit 3aab2bc4 authored by Madoura's avatar Madoura
Browse files

python3Packages.torchmetrics: work around tests duplicate package issue

The repo was moved from PyTorchLightning/metrics to Lightning-AI/torchmetrics
parent 77ab93a3
Loading
Loading
Loading
Loading
+22 −9
Original line number Diff line number Diff line
@@ -14,6 +14,8 @@
, pytestCheckHook
, torchmetrics
, pytorch-lightning
, pytest-doctestplus
, pytest-xdist
}:

let
@@ -22,10 +24,11 @@ let
in
buildPythonPackage {
  inherit pname version;
  pyproject = true;

  src = fetchFromGitHub {
    owner = "PyTorchLightning";
    repo = "metrics";
    owner = "Lightning-AI";
    repo = "torchmetrics";
    rev = "refs/tags/v${version}";
    hash = "sha256-g5JuTbiRd8yWx2nM3UE8ejOhuZ0XpAQdS5AC9AlrSFY=";
  };
@@ -51,22 +54,33 @@ buildPythonPackage {
    cloudpickle
    psutil
    pytestCheckHook
    pytest-doctestplus
    pytest-xdist
  ];

  # A cyclic dependency in: integrations/test_lightning.py
  doCheck = false;
  passthru.tests.check = torchmetrics.overridePythonAttrs (_: {
    pname = "${pname}-check";
    doCheck = true;
    # We don't have to install because the only purpose
    # of this passthru test is to, well, test.
    # This fixes having to set `catchConflicts` to false.
    dontInstall = true;
  });

  disabledTests = [
    # `IndexError: list index out of range`
    "test_metric_lightning_log"
  ];

  disabledTestPaths = [
    # These require too many "leftpad-level" dependencies
    "tests/text"
    "tests/audio"
    "tests/image"
    # Also too cross-dependent
    "tests/unittests"

    # A few non-deterministic things like test_check_compute_groups_is_faster
    "tests/bases/test_collections.py"
    # A trillion import path mismatch errors
    "src/torchmetrics"
  ];

  pythonImportsCheck = [
@@ -75,11 +89,10 @@ buildPythonPackage {

  meta = with lib; {
    description = "Machine learning metrics for distributed, scalable PyTorch applications (used in pytorch-lightning)";
    homepage = "https://torchmetrics.readthedocs.io";
    homepage = "https://lightning.ai/docs/torchmetrics/";
    license = licenses.asl20;
    maintainers = with maintainers; [
      SomeoneSerge
    ];
  };
}