1{ 2 lib, 3 buildPythonPackage, 4 fetchFromGitHub, 5 pythonOlder, 6 numpy, 7 lightning-utilities, 8 cloudpickle, 9 scikit-learn, 10 scikit-image, 11 packaging, 12 pretty-errors, 13 psutil, 14 py-deprecate, 15 torch, 16 pytestCheckHook, 17 torchmetrics, 18 pytorch-lightning, 19 pytest-doctestplus, 20 pytest-xdist, 21}: 22 23let 24 pname = "torchmetrics"; 25 version = "1.4.0.post0"; 26in 27buildPythonPackage { 28 inherit pname version; 29 pyproject = true; 30 31 disabled = pythonOlder "3.8"; 32 33 src = fetchFromGitHub { 34 owner = "Lightning-AI"; 35 repo = "torchmetrics"; 36 rev = "refs/tags/v${version}"; 37 hash = "sha256-tQqlLfdk8rSJqwR3rC7kqnM+pLFYZSPHfI7RmIi2Iq4="; 38 }; 39 40 dependencies = [ 41 numpy 42 lightning-utilities 43 packaging 44 pretty-errors 45 py-deprecate 46 ]; 47 48 # Let the user bring their own instance 49 buildInputs = [ torch ]; 50 51 nativeCheckInputs = [ 52 pytorch-lightning 53 scikit-learn 54 scikit-image 55 cloudpickle 56 psutil 57 pytestCheckHook 58 pytest-doctestplus 59 pytest-xdist 60 ]; 61 62 # A cyclic dependency in: integrations/test_lightning.py 63 doCheck = false; 64 passthru.tests.check = torchmetrics.overridePythonAttrs (_: { 65 pname = "${pname}-check"; 66 doCheck = true; 67 # We don't have to install because the only purpose 68 # of this passthru test is to, well, test. 69 # This fixes having to set `catchConflicts` to false. 70 dontInstall = true; 71 }); 72 73 disabledTests = [ 74 # `IndexError: list index out of range` 75 "test_metric_lightning_log" 76 ]; 77 78 disabledTestPaths = [ 79 # These require too many "leftpad-level" dependencies 80 # Also too cross-dependent 81 "tests/unittests" 82 83 # A trillion import path mismatch errors 84 "src/torchmetrics" 85 ]; 86 87 pythonImportsCheck = [ "torchmetrics" ]; 88 89 meta = with lib; { 90 description = "Machine learning metrics for distributed, scalable PyTorch applications (used in pytorch-lightning)"; 91 homepage = "https://lightning.ai/docs/torchmetrics/"; 92 changelog = "https://github.com/Lightning-AI/torchmetrics/releases/tag/v${version}"; 93 license = licenses.asl20; 94 maintainers = with maintainers; [ SomeoneSerge ]; 95 }; 96}