summaryrefslogtreecommitdiff
path: root/pkgs/development/python-modules/optuna/default.nix
blob: 32ed3ccd3d5e7f19891045e1295f3fe92e14c446 (about) (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
142
143
144
145
146
147
148
149
150
151
{
  lib,
  stdenv,
  buildPythonPackage,
  fetchFromGitHub,

  # build-system
  setuptools,

  # dependencies
  alembic,
  colorlog,
  numpy,
  packaging,
  sqlalchemy,
  tqdm,
  pyyaml,

  # optional-dependencies
  boto3,
  cmaes,
  fvcore,
  google-cloud-storage,
  grpcio,
  matplotlib,
  pandas,
  plotly,
  protobuf,
  redis,
  scikit-learn,
  scipy,

  # tests
  addBinToPathHook,
  fakeredis,
  kaleido,
  moto,
  pytest-xdist,
  pytestCheckHook,
  torch,
  versionCheckHook,
}:

buildPythonPackage rec {
  pname = "optuna";
  version = "4.2.1";
  pyproject = true;

  src = fetchFromGitHub {
    owner = "optuna";
    repo = "optuna";
    tag = "v${version}";
    hash = "sha256-WLrdHrdfCtCZMW2J375N8vmod7FcKCMwQPGKicRA878=";
  };

  build-system = [
    setuptools
  ];

  dependencies = [
    alembic
    colorlog
    numpy
    packaging
    sqlalchemy
    tqdm
    pyyaml
  ];

  optional-dependencies = {
    optional = [
      boto3
      cmaes
      fvcore
      google-cloud-storage
      grpcio
      matplotlib
      pandas
      plotly
      protobuf
      redis
      scikit-learn
      scipy
    ];
  };

  # grpc tests are racy
  preCheck = ''
    sed -i '/"grpc",/d' optuna/testing/storages.py
  '';

  nativeCheckInputs =
    [
      addBinToPathHook
      fakeredis
      kaleido
      moto
      pytest-xdist
      pytestCheckHook
      torch
      versionCheckHook
    ]
    ++ fakeredis.optional-dependencies.lua
    ++ optional-dependencies.optional;
  versionCheckProgramArg = "--version";

  disabledTests =
    [
      # ValueError: Transform failed with error code 525: error creating static canvas/context for image server
      "test_get_pareto_front_plot"
      # too narrow time limit
      "test_get_timeline_plot_with_killed_running_trials"
    ]
    ++ lib.optionals stdenv.hostPlatform.isDarwin [
      # ValueError: Failed to start Kaleido subprocess. Error stream
      # kaleido/executable/kaleido: line 5:  5956 Illegal instruction: 4  ./bin/kaleido $@
      "test_get_optimization_history_plot"
      "test_plot_intermediate_values"
      "test_plot_rank"
      "test_plot_terminator_improvement"

      # Fatal Python error: Aborted
      # matplotlib/backend_bases.py", line 2654 in create_with_canvas
      "test_edf_plot_no_trials"
      "test_get_timeline_plot"
      "test_plot_contour"
      "test_plot_contour_customized_target_name"
      "test_plot_edf_with_multiple_studies"
      "test_plot_edf_with_target"
      "test_plot_parallel_coordinate"
      "test_plot_parallel_coordinate_customized_target_name"
      "test_plot_param_importances"
      "test_plot_param_importances_customized_target_name"
      "test_plot_param_importances_multiobjective_all_objectives_displayed"
      "test_plot_slice"
      "test_plot_slice_customized_target_name"
      "test_target_is_none_and_study_is_multi_obj"
      "test_visualizations_with_single_objectives"
    ];

  pythonImportsCheck = [ "optuna" ];

  meta = {
    description = "Hyperparameter optimization framework";
    homepage = "https://optuna.org/";
    changelog = "https://github.com/optuna/optuna/releases/tag/${version}";
    license = lib.licenses.mit;
    maintainers = with lib.maintainers; [ natsukium ];
    mainProgram = "optuna";
  };
}