2023-02-09 11:40:11 +00:00
|
|
|
{ stdenv
|
|
|
|
, lib
|
2020-05-29 06:06:01 +00:00
|
|
|
, buildPythonPackage
|
|
|
|
, fetchFromGitHub
|
|
|
|
, isPy27
|
|
|
|
, numpy
|
2021-05-20 23:08:51 +00:00
|
|
|
, scikit-learn
|
2020-11-15 13:44:38 +00:00
|
|
|
, pytestCheckHook
|
2022-09-09 14:08:57 +00:00
|
|
|
, torch
|
2020-05-29 06:06:01 +00:00
|
|
|
, torchvision
|
|
|
|
, tqdm
|
2022-08-12 12:06:08 +00:00
|
|
|
, faiss
|
2020-05-29 06:06:01 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
buildPythonPackage rec {
|
|
|
|
pname = "pytorch-metric-learning";
|
2023-02-09 11:40:11 +00:00
|
|
|
version = "2.0.0";
|
2020-05-29 06:06:01 +00:00
|
|
|
|
|
|
|
disabled = isPy27;
|
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "KevinMusgrave";
|
|
|
|
repo = pname;
|
2022-08-12 12:06:08 +00:00
|
|
|
rev = "refs/tags/v${version}";
|
2023-02-09 11:40:11 +00:00
|
|
|
sha256 = "sha256-xarZvCRT/PhhB+ySv94XGz7uF/WiKbil6ohg7XbzOUs=";
|
2020-05-29 06:06:01 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
propagatedBuildInputs = [
|
|
|
|
numpy
|
2022-09-09 14:08:57 +00:00
|
|
|
torch
|
2021-05-20 23:08:51 +00:00
|
|
|
scikit-learn
|
2020-05-29 06:06:01 +00:00
|
|
|
torchvision
|
|
|
|
tqdm
|
|
|
|
];
|
|
|
|
|
2020-11-15 13:44:38 +00:00
|
|
|
preCheck = ''
|
|
|
|
export HOME=$TMP
|
|
|
|
export TEST_DEVICE=cpu
|
|
|
|
export TEST_DTYPES=float32,float64 # half-precision tests fail on CPU
|
|
|
|
'';
|
2022-08-12 12:06:08 +00:00
|
|
|
|
2020-11-15 13:44:38 +00:00
|
|
|
# package only requires `unittest`, but use `pytest` to exclude tests
|
2023-02-02 18:25:31 +00:00
|
|
|
nativeCheckInputs = [
|
2022-08-12 12:06:08 +00:00
|
|
|
faiss
|
|
|
|
pytestCheckHook
|
|
|
|
];
|
|
|
|
|
2020-11-15 13:44:38 +00:00
|
|
|
disabledTests = [
|
2022-08-12 12:06:08 +00:00
|
|
|
# TypeError: setup() missing 1 required positional argument: 'world_size'
|
|
|
|
"TestDistributedLossWrapper"
|
2020-11-15 13:44:38 +00:00
|
|
|
# require network access:
|
2022-08-12 12:06:08 +00:00
|
|
|
"TestInference"
|
2020-11-15 13:44:38 +00:00
|
|
|
"test_get_nearest_neighbors"
|
|
|
|
"test_tuplestoweights_sampler"
|
|
|
|
"test_untrained_indexer"
|
2021-05-20 23:08:51 +00:00
|
|
|
"test_metric_loss_only"
|
|
|
|
"test_pca"
|
|
|
|
# flaky
|
|
|
|
"test_distributed_classifier_loss_and_miner"
|
2023-02-09 11:40:11 +00:00
|
|
|
] ++ lib.optionals (stdenv.isLinux && stdenv.isAarch64) [
|
|
|
|
# RuntimeError: DataLoader worker (pid(s) <...>) exited unexpectedly
|
|
|
|
"test_global_embedding_space_tester"
|
|
|
|
"test_with_same_parent_label_tester"
|
2020-11-15 13:44:38 +00:00
|
|
|
];
|
|
|
|
|
2020-05-29 06:06:01 +00:00
|
|
|
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 ];
|
|
|
|
};
|
|
|
|
}
|