summaryrefslogtreecommitdiff
path: root/pkgs/development/python-modules/gradient-utils/default.nix
blob: ea5ae6585850c61c25ab5b1e14c331be15b838a2 (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
{
  lib,
  buildPythonPackage,
  fetchFromGitHub,
  hyperopt,
  mock,
  numpy,
  poetry-core,
  prometheus-client,
  pytestCheckHook,
  requests,
}:

buildPythonPackage rec {
  pname = "gradient-utils";
  version = "0.5.0";
  pyproject = true;

  src = fetchFromGitHub {
    owner = "Paperspace";
    repo = "gradient-utils";
    tag = "v${version}";
    hash = "sha256-swnl0phdOsBSP8AX/OySI/aYI9z60Ss3SsJox/mb9KY=";
  };

  nativeBuildInputs = [ poetry-core ];

  propagatedBuildInputs = [
    hyperopt
    prometheus-client
    numpy
  ];

  nativeCheckInputs = [
    mock
    requests
    pytestCheckHook
  ];

  postPatch = ''
    # https://github.com/Paperspace/gradient-utils/issues/68
    # https://github.com/Paperspace/gradient-utils/issues/72
    substituteInPlace pyproject.toml \
      --replace 'wheel = "^0.35.1"' 'wheel = "*"' \
      --replace 'prometheus-client = ">=0.8,<0.10"' 'prometheus-client = "*"' \
      --replace 'pymongo = "^3.11.0"' 'pymongo = ">=3.11.0"'
  '';

  preCheck = ''
    export HOSTNAME=myhost-experimentId
  '';

  disabledTestPaths = [
    # Requires a working Prometheus push gateway
    "tests/integration/test_metrics.py"
  ];

  pythonImportsCheck = [ "gradient_utils" ];

  meta = {
    description = "Python utils and helpers library for Gradient";
    homepage = "https://github.com/Paperspace/gradient-utils";
    license = lib.licenses.mit;
    maintainers = [ ];
    platforms = lib.platforms.unix;
  };
}