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