1{
2 lib,
3 stdenv,
4 buildPythonPackage,
5 fetchFromGitHub,
6
7 # build-system
8 setuptools,
9
10 # dependencies
11 alembic,
12 colorlog,
13 numpy,
14 packaging,
15 sqlalchemy,
16 tqdm,
17 pyyaml,
18
19 # optional-dependencies
20 boto3,
21 cmaes,
22 fvcore,
23 google-cloud-storage,
24 grpcio,
25 matplotlib,
26 pandas,
27 plotly,
28 protobuf,
29 redis,
30 scikit-learn,
31 scipy,
32
33 # tests
34 addBinToPathHook,
35 fakeredis,
36 kaleido,
37 moto,
38 pytest-xdist,
39 pytestCheckHook,
40 torch,
41 versionCheckHook,
42}:
43
44buildPythonPackage rec {
45 pname = "optuna";
46 version = "4.5.0";
47 pyproject = true;
48
49 src = fetchFromGitHub {
50 owner = "optuna";
51 repo = "optuna";
52 tag = "v${version}";
53 hash = "sha256-qaCOpqKRepm/a1Nh98PV6RcRkadLK5E429pn1zaWQDA=";
54 };
55
56 build-system = [
57 setuptools
58 ];
59
60 dependencies = [
61 alembic
62 colorlog
63 numpy
64 packaging
65 sqlalchemy
66 tqdm
67 pyyaml
68 ];
69
70 optional-dependencies = {
71 optional = [
72 boto3
73 cmaes
74 fvcore
75 google-cloud-storage
76 grpcio
77 matplotlib
78 pandas
79 plotly
80 protobuf
81 redis
82 scikit-learn
83 scipy
84 ];
85 };
86
87 # grpc tests are racy
88 preCheck = ''
89 sed -i '/"grpc",/d' optuna/testing/storages.py
90 '';
91
92 nativeCheckInputs = [
93 addBinToPathHook
94 fakeredis
95 kaleido
96 moto
97 pytest-xdist
98 pytestCheckHook
99 torch
100 versionCheckHook
101 ]
102 ++ fakeredis.optional-dependencies.lua
103 ++ optional-dependencies.optional;
104 versionCheckProgramArg = "--version";
105
106 disabledTests = [
107 # ValueError: Transform failed with error code 525: error creating static canvas/context for image server
108 "test_get_pareto_front_plot"
109 # too narrow time limit
110 "test_get_timeline_plot_with_killed_running_trials"
111 # times out under load
112 "test_optimize_with_progbar_timeout"
113 ]
114 ++ lib.optionals stdenv.hostPlatform.isDarwin [
115 # ValueError: Failed to start Kaleido subprocess. Error stream
116 # kaleido/executable/kaleido: line 5: 5956 Illegal instruction: 4 ./bin/kaleido $@
117 "test_get_optimization_history_plot"
118 "test_plot_intermediate_values"
119 "test_plot_rank"
120 "test_plot_terminator_improvement"
121
122 # Fatal Python error: Aborted
123 # matplotlib/backend_bases.py", line 2654 in create_with_canvas
124 "test_edf_plot_no_trials"
125 "test_get_timeline_plot"
126 "test_plot_contour"
127 "test_plot_contour_customized_target_name"
128 "test_plot_edf_with_multiple_studies"
129 "test_plot_edf_with_target"
130 "test_plot_parallel_coordinate"
131 "test_plot_parallel_coordinate_customized_target_name"
132 "test_plot_param_importances"
133 "test_plot_param_importances_customized_target_name"
134 "test_plot_param_importances_multiobjective_all_objectives_displayed"
135 "test_plot_slice"
136 "test_plot_slice_customized_target_name"
137 "test_target_is_none_and_study_is_multi_obj"
138 "test_visualizations_with_single_objectives"
139 ];
140
141 __darwinAllowLocalNetworking = true;
142
143 pythonImportsCheck = [ "optuna" ];
144
145 meta = {
146 description = "Hyperparameter optimization framework";
147 homepage = "https://optuna.org/";
148 changelog = "https://github.com/optuna/optuna/releases/tag/${src.tag}";
149 license = lib.licenses.mit;
150 maintainers = with lib.maintainers; [ natsukium ];
151 mainProgram = "optuna";
152 };
153}