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}:
18
19let
20 pname = "torchmetrics";
21 version = "1.2.0";
22in
23buildPythonPackage {
24 inherit pname version;
25
26 src = fetchFromGitHub {
27 owner = "PyTorchLightning";
28 repo = "metrics";
29 rev = "refs/tags/v${version}";
30 hash = "sha256-g5JuTbiRd8yWx2nM3UE8ejOhuZ0XpAQdS5AC9AlrSFY=";
31 };
32
33 disabled = pythonOlder "3.8";
34
35 propagatedBuildInputs = [
36 numpy
37 lightning-utilities
38 packaging
39 py-deprecate
40 ];
41
42 # Let the user bring their own instance
43 buildInputs = [
44 torch
45 ];
46
47 nativeCheckInputs = [
48 pytorch-lightning
49 scikit-learn
50 scikit-image
51 cloudpickle
52 psutil
53 pytestCheckHook
54 ];
55
56 # A cyclic dependency in: integrations/test_lightning.py
57 doCheck = false;
58 passthru.tests.check = torchmetrics.overridePythonAttrs (_: {
59 doCheck = true;
60 });
61
62 disabledTestPaths = [
63 # These require too many "leftpad-level" dependencies
64 "tests/text"
65 "tests/audio"
66 "tests/image"
67
68 # A few non-deterministic things like test_check_compute_groups_is_faster
69 "tests/bases/test_collections.py"
70 ];
71
72 pythonImportsCheck = [
73 "torchmetrics"
74 ];
75
76 meta = with lib; {
77 description = "Machine learning metrics for distributed, scalable PyTorch applications (used in pytorch-lightning)";
78 homepage = "https://torchmetrics.readthedocs.io";
79 license = licenses.asl20;
80 maintainers = with maintainers; [
81 SomeoneSerge
82 ];
83 };
84}
85