nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 stdenv,
4 buildPythonPackage,
5 fetchFromGitHub,
6
7 # build-system
8 setuptools,
9
10 # dependencies
11 numpy,
12 packaging,
13 torch,
14 typing-extensions,
15
16 # tests
17 onnx,
18 pytestCheckHook,
19 torchvision,
20 pythonAtLeast,
21}:
22
23buildPythonPackage (finalAttrs: {
24 pname = "pytorch-pfn-extras";
25 version = "0.8.4";
26 pyproject = true;
27
28 src = fetchFromGitHub {
29 owner = "pfnet";
30 repo = "pytorch-pfn-extras";
31 tag = "v${finalAttrs.version}";
32 hash = "sha256-OrUYO0V5fWqkIjHiYkhvjeFy0YX8CxeRqzrw3NfGK2A=";
33 };
34
35 build-system = [ setuptools ];
36
37 dependencies = [
38 numpy
39 packaging
40 torch
41 typing-extensions
42 ];
43
44 nativeCheckInputs = [
45 onnx
46 pytestCheckHook
47 torchvision
48 ];
49
50 pytestFlags = [
51 "-Wignore::DeprecationWarning"
52 ];
53
54 pythonImportsCheck = [ "pytorch_pfn_extras" ];
55
56 disabledTestMarks = [
57 # Requires CUDA access which is not possible in the nix environment.
58 "gpu"
59 "mpi"
60 ];
61
62 disabledTests = [
63 # AssertionError: assert 4 == 0
64 # where 4 = <MagicMock id='140733587469184'>.call_count
65 "test_lr_scheduler_wait_for_first_optimizer_step"
66 ]
67 ++ lib.optionals (pythonAtLeast "3.13") [
68 # RuntimeError: Dynamo is not supported on Python 3.13+
69 "test_register"
70 ]
71 ++ lib.optionals (pythonAtLeast "3.14") [
72 # AttributeError: 'Ensure' object has no attribute '__annotations__'. Did you mean: '__annotate_func__'?
73 "test_torchscript_module"
74
75 # TypeError: cannot pickle '_contextvars.Context' object
76 "test_record_iterable_with_multiprocessing"
77
78 # TypeError: cannot pickle '_thread.lock' object
79 "test_report_from_other_process"
80
81 # AssertionError: assert 'foo' in {}
82 "test_global_summary"
83 ]
84 ++ lib.optionals stdenv.hostPlatform.isDarwin [
85 # torch.distributed was not available on darwin at one point; revisit
86 "test_create_distributed_evaluator"
87 "test_distributed_evaluation"
88 "test_distributed_evaluator_progress_bar"
89 ];
90
91 disabledTestPaths = [
92 # Requires optuna which is currently (2022-02-16) marked as broken.
93 "tests/pytorch_pfn_extras_tests/test_config_types.py"
94
95 # requires onnxruntime which was removed because of poor maintainability
96 # See https://github.com/NixOS/nixpkgs/pull/105951 https://github.com/NixOS/nixpkgs/pull/155058
97 "tests/pytorch_pfn_extras_tests/onnx_tests/test_annotate.py"
98 "tests/pytorch_pfn_extras_tests/onnx_tests/test_as_output.py"
99 "tests/pytorch_pfn_extras_tests/onnx_tests/test_export.py"
100 "tests/pytorch_pfn_extras_tests/onnx_tests/test_export_testcase.py"
101 "tests/pytorch_pfn_extras_tests/onnx_tests/test_helper.py"
102 "tests/pytorch_pfn_extras_tests/onnx_tests/test_lax.py"
103 "tests/pytorch_pfn_extras_tests/onnx_tests/test_load_model.py"
104 "tests/pytorch_pfn_extras_tests/onnx_tests/test_torchvision.py"
105 "tests/pytorch_pfn_extras_tests/onnx_tests/utils.py"
106
107 # RuntimeError: No Op registered for Gradient with domain_version of 9
108 "tests/pytorch_pfn_extras_tests/onnx_tests/test_grad.py"
109
110 # torch._dynamo.exc.BackendCompilerFailed: backend='compiler_fn' raised:
111 # AttributeError: module 'torch.fx.experimental.proxy_tensor' has no attribute 'maybe_disable_fake_tensor_mode'
112 "tests/pytorch_pfn_extras_tests/dynamo_tests/test_compile.py"
113 ]
114 ++ lib.optionals (stdenv.hostPlatform.isDarwin) [
115 # torch.distributed was not available on darwin at one point; revisit
116 "tests/pytorch_pfn_extras_tests/distributed_tests/test_distributed_validation_sampler.py"
117 "tests/pytorch_pfn_extras_tests/nn_tests/parallel_tests/test_distributed.py"
118 "tests/pytorch_pfn_extras_tests/profiler_tests/test_record.py"
119 "tests/pytorch_pfn_extras_tests/profiler_tests/test_time_summary.py"
120 "tests/pytorch_pfn_extras_tests/training_tests/extensions_tests/test_accumulate.py"
121 "tests/pytorch_pfn_extras_tests/training_tests/extensions_tests/test_sharded_snapshot.py"
122 ]
123 ++ lib.optionals (stdenv.hostPlatform.isLinux && stdenv.hostPlatform.isAarch64) [
124 # RuntimeError: internal error
125 # convolution (e.g. F.conv3d) causes runtime error
126 "tests/pytorch_pfn_extras_tests/nn_tests/modules_tests/test_lazy_conv.py"
127 ];
128
129 meta = {
130 description = "Supplementary components to accelerate research and development in PyTorch";
131 homepage = "https://github.com/pfnet/pytorch-pfn-extras";
132 changelog = "https://github.com/pfnet/pytorch-pfn-extras/releases/tag/${finalAttrs.src.tag}";
133 license = lib.licenses.mit;
134 maintainers = with lib.maintainers; [ samuela ];
135 badPlatforms = [
136 # test_profile_report is broken on darwin
137 lib.systems.inspect.patterns.isDarwin
138 ];
139 };
140})