1{ lib
2, stdenv
3, buildPythonPackage
4, fetchPypi
5, pythonOlder
6, numpy
7, scikit-learn
8, scipy
9, tabulate
10, torch
11, tqdm
12, flaky
13, pandas
14, pytestCheckHook
15, safetensors
16, pythonAtLeast
17}:
18
19buildPythonPackage rec {
20 pname = "skorch";
21 version = "0.15.0";
22
23 src = fetchPypi {
24 inherit pname version;
25 hash = "sha256-39XVBlCmbg162z9uL84GZrU+v+M8waXbGdVV72ZYf84=";
26 };
27
28 disabled = pythonOlder "3.8";
29
30 propagatedBuildInputs = [
31 numpy
32 scikit-learn
33 scipy
34 tabulate
35 torch
36 tqdm
37 ];
38
39 nativeCheckInputs = [
40 flaky
41 pandas
42 pytestCheckHook
43 safetensors
44 ];
45
46 # patch out pytest-cov dep/invocation
47 postPatch = ''
48 substituteInPlace setup.cfg \
49 --replace "--cov=skorch" "" \
50 --replace "--cov-report=term-missing" "" \
51 --replace "--cov-config .coveragerc" ""
52 '';
53
54 disabledTests = [
55 # on CPU, these expect artifacts from previous GPU run
56 "test_load_cuda_params_to_cpu"
57 # failing tests
58 "test_pickle_load"
59 ] ++ lib.optionals stdenv.isDarwin [
60 # there is a problem with the compiler selection
61 "test_fit_and_predict_with_compile"
62 ] ++ lib.optionals (pythonAtLeast "3.11") [
63 # Python 3.11+ not yet supported for torch.compile
64 # https://github.com/pytorch/pytorch/blob/v2.0.1/torch/_dynamo/eval_frame.py#L376-L377
65 "test_fit_and_predict_with_compile"
66 ];
67
68 disabledTestPaths = [
69 # tries to import `transformers` and download HuggingFace data
70 "skorch/tests/test_hf.py"
71 ] ++ lib.optionals (stdenv.hostPlatform.system != "x86_64-linux") [
72 # torch.distributed is disabled by default in darwin
73 # aarch64-linux also failed these tests
74 "skorch/tests/test_history.py"
75 ];
76
77 pythonImportsCheck = [ "skorch" ];
78
79 meta = with lib; {
80 description = "Scikit-learn compatible neural net library using Pytorch";
81 homepage = "https://skorch.readthedocs.io";
82 changelog = "https://github.com/skorch-dev/skorch/blob/master/CHANGES.md";
83 license = licenses.bsd3;
84 maintainers = with maintainers; [ bcdarwin ];
85 };
86}