Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{
2 lib,
3 buildPythonPackage,
4 fetchFromGitHub,
5 pythonAtLeast,
6
7 # build system
8 setuptools,
9 setuptools-scm,
10
11 # dependencies
12 numpy,
13 scikit-image,
14 torchvision,
15 torch,
16 runstats,
17 pytorch-lightning,
18 h5py,
19 pyyaml,
20 torchmetrics,
21 pandas,
22
23 # tests
24 pytestCheckHook,
25}:
26
27buildPythonPackage (finalAttrs: {
28 pname = "fastmri";
29 version = "0.3.0";
30 pyproject = true;
31
32 src = fetchFromGitHub {
33 owner = "facebookresearch";
34 repo = "fastMRI";
35 tag = "v${finalAttrs.version}";
36 hash = "sha256-0IJV8OhY5kPWQwUYPKfmdI67TyYzDAPlwohdc0jWcV4=";
37 };
38
39 # banding_removal folder also has a subfolder named "fastmri"
40 # and np.product is substituted with np.prod in new numpy versions
41 postPatch = ''
42 substituteInPlace tests/test_math.py \
43 --replace-fail "np.product" "np.prod"
44 substituteInPlace tests/conftest.py \
45 --replace-fail "np.product" "np.prod"
46
47 rm -rf banding_removal
48 '';
49
50 build-system = [
51 setuptools
52 setuptools-scm
53 ];
54
55 dependencies = [
56 numpy
57 scikit-image
58 torchvision
59 torch
60 runstats
61 pytorch-lightning
62 h5py
63 pyyaml
64 torchmetrics
65 pandas
66 ];
67
68 nativeCheckInputs = [ pytestCheckHook ];
69
70 disabledTests = lib.optionals (pythonAtLeast "3.14") [
71 # AttributeError: '...' object has no attribute '__annotations__'.
72 "test_unet_scripting"
73 "test_varnet_scripting"
74 ];
75
76 disabledTestPaths = [
77 # much older version of pytorch-lightning is used
78 "tests/test_modules.py"
79 ];
80
81 pythonImportsCheck = [ "fastmri" ];
82
83 meta = {
84 description = "Pytorch-based MRI reconstruction tooling";
85 homepage = "https://github.com/facebookresearch/fastMRI";
86 changelog = "https://github.com/facebookresearch/fastMRI/releases/tag/${finalAttrs.src.tag}";
87 license = lib.licenses.mit;
88 maintainers = with lib.maintainers; [ osbm ];
89 };
90})