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