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
|
{
stdenv,
lib,
buildPythonPackage,
fetchFromGitHub,
isPy27,
config,
# build-system
setuptools,
# dependencies
numpy,
scikit-learn,
torch,
tqdm,
# optional-dependencies
faiss,
tensorboard,
# tests
cudaSupport ? config.cudaSupport,
pytestCheckHook,
torchvision
}:
buildPythonPackage rec {
pname = "pytorch-metric-learning";
version = "2.5.0";
pyproject = true;
disabled = isPy27;
src = fetchFromGitHub {
owner = "KevinMusgrave";
repo = pname;
rev = "refs/tags/v${version}";
hash = "sha256-1y7VCnzgwFOMeMloVdYyszNhf/zZlBJUjuF4qgA5c0A=";
};
build-system = [
setuptools
];
dependencies = [
numpy
torch
scikit-learn
tqdm
];
optional-dependencies = {
with-hooks = [
# TODO: record-keeper
faiss
tensorboard
];
with-hooks-cpu = [
# TODO: record-keeper
faiss
tensorboard
];
};
preCheck = ''
export HOME=$TMP
export TEST_DEVICE=cpu
export TEST_DTYPES=float32,float64 # half-precision tests fail on CPU
'';
# package only requires `unittest`, but use `pytest` to exclude tests
nativeCheckInputs = [
pytestCheckHook
torchvision
] ++ lib.flatten (lib.attrValues optional-dependencies);
disabledTests = [
# network access
"test_tuplestoweights_sampler"
"test_metric_loss_only"
"test_add_to_indexer"
"test_get_nearest_neighbors"
"test_list_of_text"
"test_untrained_indexer"
] ++ lib.optionals stdenv.isDarwin [
# AttributeError: module 'torch.distributed' has no attribute 'init_process_group'
"test_single_proc"
] ++ lib.optionals cudaSupport [
# crashes with SIGBART
"test_accuracy_calculator_and_faiss_with_torch_and_numpy"
"test_accuracy_calculator_large_k"
"test_custom_knn"
"test_global_embedding_space_tester"
"test_global_two_stream_embedding_space_tester"
"test_index_type"
"test_k_warning"
"test_many_tied_distances"
"test_query_within_reference"
"test_tied_distances"
"test_with_same_parent_label_tester"
];
meta = {
description = "Metric learning library for PyTorch";
homepage = "https://github.com/KevinMusgrave/pytorch-metric-learning";
changelog = "https://github.com/KevinMusgrave/pytorch-metric-learning/releases/tag/v${version}";
license = lib.licenses.mit;
maintainers = with lib.maintainers; [ bcdarwin ];
};
}
|