blob: 4241d2c794602773a9e5e922f3a0905b66163dce (
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
|
{
lib,
immich,
python3,
nixosTests,
stdenv,
}:
let
python = python3.override {
self = python;
};
in
python.pkgs.buildPythonApplication rec {
pname = "immich-machine-learning";
inherit (immich) version;
src = "${immich.src}/machine-learning";
pyproject = true;
pythonRelaxDeps = [
"onnx"
];
build-system = with python.pkgs; [
hatchling
];
dependencies =
with python.pkgs;
[
aiocache
fastapi
gunicorn
huggingface-hub
numpy
onnx
opencv-python-headless
orjson
pillow
pydantic
pydantic-settings
python-multipart
rich
tokenizers
uvicorn
rapidocr
]
++ uvicorn.optional-dependencies.standard;
# aarch64-linux tries to get cpu information from /sys, which isn't available
# inside the nix build sandbox.
doCheck = stdenv.buildPlatform.system != "aarch64-linux";
nativeCheckInputs = with python.pkgs; [
httpx
pytest-asyncio
pytest-mock
pytestCheckHook
];
postInstall = ''
mkdir -p $out/share/immich
cp immich_ml/log_conf.json $out/share/immich
cp -r ann $out/${python.sitePackages}/
makeWrapper ${lib.getExe python.pkgs.gunicorn} "''${!outputBin}"/bin/machine-learning \
--prefix PYTHONPATH : "$out/${python.sitePackages}:${python.pkgs.makePythonPath dependencies}" \
--set-default MACHINE_LEARNING_WORKERS 1 \
--set-default MACHINE_LEARNING_WORKER_TIMEOUT 120 \
--set-default MACHINE_LEARNING_CACHE_FOLDER /var/cache/immich \
--set-default IMMICH_HOST "[::]" \
--set-default IMMICH_PORT 3003 \
--add-flags "immich_ml.main:app -k immich_ml.config.CustomUvicornWorker \
-w \"\$MACHINE_LEARNING_WORKERS\" \
-b \"\$IMMICH_HOST:\$IMMICH_PORT\" \
-t \"\$MACHINE_LEARNING_WORKER_TIMEOUT\"
--log-config-json $out/share/immich/log_conf.json"
'';
passthru.tests = {
inherit (nixosTests) immich;
};
meta = {
description = "${immich.meta.description} (machine learning component)";
homepage = "https://github.com/immich-app/immich/tree/main/machine-learning";
mainProgram = "machine-learning";
inherit (immich.meta) license maintainers platforms;
};
}
|