about summary refs log tree commit diff
path: root/pkgs/development/python-modules/manifest-ml/default.nix
blob: 4465066682c9a11fa3ea762b4f225ba613a4f264 (plain) (blame)
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
{ lib
, accelerate
, aiohttp
, buildPythonPackage
, fastapi
, fetchFromGitHub
, flask
, numpy
, pg8000
, pillow
, pydantic
, pytestCheckHook
, pythonOlder
, pythonRelaxDepsHook
, redis
, requests
, sentence-transformers
, setuptools
, sqlalchemy
, sqlitedict
, tenacity
, tiktoken
, torch
, transformers
, uvicorn
, xxhash
}:

buildPythonPackage rec {
  pname = "manifest-ml";
  version = "0.1.9";
  pyproject = true;

  disabled = pythonOlder "3.8";

  src = fetchFromGitHub {
    owner = "HazyResearch";
    repo = "manifest";
    rev = "refs/tags/v${version}";
    hash = "sha256-6m1XZOXzflBYyq9+PinbrW+zqvNGFN/aRDHH1b2Me5E=";
  };

  __darwinAllowLocalNetworking = true;

  pythonRelaxDeps = [
    "pydantic"
  ];

  build-system = [
    pythonRelaxDepsHook
    setuptools
  ];

  dependencies = [
    numpy
    pydantic
    redis
    requests
    aiohttp
    sqlitedict
    tenacity
    tiktoken
    xxhash
  ];

  passthru.optional-dependencies = {
    api = [
      accelerate
      # deepspeed
      # diffusers
      flask
      sentence-transformers
      torch
      transformers
    ];
    app = [
      fastapi
      uvicorn
    ];
    diffusers = [
      pillow
    ];
    gcp = [
      pg8000
      # cloud-sql-python-connector
      sqlalchemy
    ];
  };

  nativeCheckInputs = [
    pytestCheckHook
  ] ++ lib.flatten (lib.attrValues passthru.optional-dependencies);

  preCheck = ''
    export HOME=$TMPDIR
  '';

  pytestFlagsArray = [
    # this file tries importing `deepspeed`, which is not yet packaged in nixpkgs
    "--ignore=tests/test_huggingface_api.py"
  ];

  disabledTests = [
    # Tests require DB access
    "test_init"
    "test_key_get_and_set"
    "test_get"
    # Tests require network access
    "test_abatch_run"
    "test_batch_run"
    "test_retry_handling"
    "test_run_chat"
    "test_run"
    "test_score_run"
    # Test is time-senstive
    "test_timing"
  ];

  pythonImportsCheck = [
    "manifest"
  ];

  meta = with lib; {
    description = "Manifest for Prompting Foundation Models";
    homepage = "https://github.com/HazyResearch/manifest";
    changelog = "https://github.com/HazyResearch/manifest/releases/tag/v${version}";
    license = licenses.asl20;
    maintainers = with maintainers; [ natsukium ];
  };
}