summaryrefslogtreecommitdiffstats
path: root/pkgs/development/python-modules/albumentationsx/default.nix
blob: 9f0390968f30bd3b37e1d0ca6af1f4ef3b6c9aeb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
{
  lib,
  buildPythonPackage,
  fetchFromGitHub,

  # build-system
  hatchling,

  # dependencies
  albucore,
  numpy,
  pydantic,
  pyyaml,
  scipy,
  typing-extensions,

  # optional-dependencies
  opencv-contrib-python,
  opencv-python,
  opencv-python-headless,
  huggingface-hub,
  pillow,
  torch,
  pyvips,

  # tests
  deepdiff,
  defusedxml,
  gitMinimal,
  hypothesis,
  pytest-mock,
  pytestCheckHook,
  scikit-image,
  scikit-learn,
  torchvision,
}:

buildPythonPackage (finalAttrs: {
  pname = "albumentationsx";
  version = "2.3.3";
  pyproject = true;
  __structuredAttrs = true;

  src = fetchFromGitHub {
    owner = "albumentations-team";
    repo = "AlbumentationsX";
    tag = finalAttrs.version;
    hash = "sha256-exCQwduQM29K5Omb48KYIqm2D4yfOKFFEr37zhIvACY=";
  };

  postPatch = ''
    substituteInPlace albumentations/core/analytics/settings.py \
      --replace-fail '"telemetry": True,' '"telemetry": False,'
  '';

  build-system = [
    hatchling
  ];

  dependencies = [
    albucore
    numpy
    pydantic
    pyyaml
    scipy
    typing-extensions
  ];

  optional-dependencies = {
    contrib = [
      opencv-contrib-python
    ];
    contrib-headless = [
      # opencv-contrib-python-headless
    ];
    gui = [
      opencv-python
    ];
    headless = [
      opencv-python-headless
    ];
    hub = [
      huggingface-hub
    ];
    pillow = [
      pillow
    ];
    pytorch = [
      torch
    ];
    pyvips = [
      pyvips
    ];
    text = [
      pillow
    ];
  };

  pythonImportsCheck = [ "albumentations" ];

  nativeCheckInputs = [
    deepdiff
    defusedxml
    gitMinimal
    hypothesis
    pillow
    pytest-mock
    pytestCheckHook
    scikit-image
    scikit-learn
    torch
    torchvision
  ];

  disabledTests = [
    # ImportError: cannot import name 'benchmark_coverage' from 'tools'
    "test_direct_script_ignores_unrelated_tools_package"

    # AssertionError: Arrays are not almost equal to 6 decimals
    "test_pca_inverse_transform"
  ];

  disabledTestPaths = [
    # Infinite recursion with albu-spec
    "tests/test_type_consistency.py"

    # Requires unfree google-docstring-parser
    "tests/test_docstrings.py"

    # Fails due to disabling telemetry in postPatch
    "tests/test_telemetry.py"
  ];

  meta = {
    description = "Python library for image augmentation";
    homepage = "https://github.com/albumentations-team/AlbumentationsX";
    changelog = "https://github.com/albumentations-team/AlbumentationsX/releases/tag/${finalAttrs.src.tag}";
    license = lib.licenses.agpl3Only;
    maintainers = with lib.maintainers; [ GaetanLepage ];
  };
})