Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{
2 lib,
3 stdenv,
4 buildPythonPackage,
5 fetchFromGitHub,
6
7 # build-system
8 setuptools,
9
10 # dependencies
11 absl-py,
12 distutils,
13 h5py,
14 ml-dtypes,
15 namex,
16 numpy,
17 tf2onnx,
18 onnxruntime,
19 optree,
20 packaging,
21 pythonAtLeast,
22 rich,
23 scikit-learn,
24 tensorflow,
25
26 # tests
27 dm-tree,
28 jax,
29 pandas,
30 pydot,
31 pytestCheckHook,
32 tf-keras,
33 torch,
34 writableTmpDirAsHomeHook,
35}:
36
37buildPythonPackage rec {
38 pname = "keras";
39 version = "3.11.1";
40 pyproject = true;
41
42 src = fetchFromGitHub {
43 owner = "keras-team";
44 repo = "keras";
45 tag = "v${version}";
46 hash = "sha256-jyNOL5u+XVVqChD7Fs3yJCcW14bTvitiQa4H4DTeja0=";
47 };
48
49 build-system = [
50 setuptools
51 ];
52
53 dependencies = [
54 absl-py
55 h5py
56 ml-dtypes
57 namex
58 numpy
59 tf2onnx
60 onnxruntime
61 optree
62 packaging
63 rich
64 scikit-learn
65 tensorflow
66 ]
67 ++ lib.optionals (pythonAtLeast "3.12") [ distutils ];
68
69 pythonImportsCheck = [
70 "keras"
71 "keras._tf_keras"
72 ];
73
74 nativeCheckInputs = [
75 dm-tree
76 jax
77 pandas
78 pydot
79 pytestCheckHook
80 tf-keras
81 torch
82 writableTmpDirAsHomeHook
83 ];
84
85 disabledTests = [
86 # Require unpackaged `grain`
87 "test_fit_with_data_adapter_grain_dataloader"
88 "test_fit_with_data_adapter_grain_datast"
89 "test_fit_with_data_adapter_grain_datast_with_len"
90
91 # Tries to install the package in the sandbox
92 "test_keras_imports"
93
94 # TypeError: this __dict__ descriptor does not support '_DictWrapper' objects
95 "test_reloading_default_saved_model"
96 ]
97 ++ lib.optionals (stdenv.hostPlatform.isLinux && stdenv.hostPlatform.isAarch64) [
98 # Hangs forever
99 "test_fit_with_data_adapter"
100 ];
101
102 disabledTestPaths = [
103 # Require unpackaged `grain`
104 "keras/src/trainers/data_adapters/grain_dataset_adapter_test.py"
105
106 # These tests succeed when run individually, but crash within the full test suite:
107 # ImportError: /nix/store/4bw0x7j3wfbh6i8x3plmzknrdwdzwfla-abseil-cpp-20240722.1/lib/libabsl_cord_internal.so.2407.0.0:
108 # undefined symbol: _ZN4absl12lts_2024072216strings_internal13StringifySink6AppendESt17basic_string_viewIcSt11char_traitsIcEE
109 "keras/src/export/onnx_test.py"
110
111 # Require internet access
112 "integration_tests/dataset_tests"
113 "keras/src/applications/applications_test.py"
114
115 # TypeError: test_custom_fit.<locals>.CustomModel.train_step() missing 1 required positional argument: 'data'
116 "integration_tests/jax_custom_fit_test.py"
117
118 # RuntimeError: Virtual devices cannot be modified after being initialized
119 "integration_tests/tf_distribute_training_test.py"
120
121 # AttributeError: 'CustomModel' object has no attribute 'zero_grad'
122 "integration_tests/torch_custom_fit_test.py"
123
124 # Fails for an unclear reason:
125 # self.assertLen(list(net.parameters()), 2
126 # AssertionError: 0 != 2
127 "integration_tests/torch_workflow_test.py"
128
129 # TypeError: this __dict__ descriptor does not support '_DictWrapper' objects
130 "keras/src/backend/tensorflow/saved_model_test.py"
131 ];
132
133 meta = {
134 description = "Multi-backend implementation of the Keras API, with support for TensorFlow, JAX, and PyTorch";
135 homepage = "https://keras.io";
136 changelog = "https://github.com/keras-team/keras/releases/tag/v${version}";
137 license = lib.licenses.mit;
138 maintainers = with lib.maintainers; [ GaetanLepage ];
139 };
140}