Merge pull request #318385 from mweinelt/pytorch-metric-learning

python311Packages.pytorch-metric-learning: refactor
This commit is contained in:
Martin Weinelt
2024-07-03 12:41:24 +02:00
committed by GitHub
2 changed files with 62 additions and 27 deletions
@@ -4,19 +4,30 @@
buildPythonPackage,
fetchFromGitHub,
isPy27,
# build-system
setuptools,
# dependencies
numpy,
scikit-learn,
pytestCheckHook,
torch,
torchvision,
tqdm,
# optional-dependencies
faiss,
tensorboard,
# tests
cudaSupport,
pytestCheckHook,
torchvision
}:
buildPythonPackage rec {
pname = "pytorch-metric-learning";
version = "2.5.0";
format = "setuptools";
pyproject = true;
disabled = isPy27;
@@ -27,14 +38,30 @@ buildPythonPackage rec {
hash = "sha256-1y7VCnzgwFOMeMloVdYyszNhf/zZlBJUjuF4qgA5c0A=";
};
propagatedBuildInputs = [
build-system = [
setuptools
];
dependencies = [
numpy
torch
scikit-learn
torchvision
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
@@ -43,29 +70,35 @@ buildPythonPackage rec {
# package only requires `unittest`, but use `pytest` to exclude tests
nativeCheckInputs = [
faiss
pytestCheckHook
];
torchvision
] ++ lib.flatten (lib.attrValues optional-dependencies);
disabledTests =
[
# TypeError: setup() missing 1 required positional argument: 'world_size'
"TestDistributedLossWrapper"
# require network access:
"TestInference"
"test_get_nearest_neighbors"
"test_tuplestoweights_sampler"
"test_untrained_indexer"
"test_metric_loss_only"
"test_pca"
# flaky
"test_distributed_classifier_loss_and_miner"
]
++ lib.optionals (stdenv.isLinux && stdenv.isAarch64) [
# RuntimeError: DataLoader worker (pid(s) <...>) exited unexpectedly
"test_global_embedding_space_tester"
"test_with_same_parent_label_tester"
];
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";
+3 -1
View File
@@ -12779,7 +12779,9 @@ self: super: with self; {
pytorch-lightning = callPackage ../development/python-modules/pytorch-lightning { };
pytorch-metric-learning = callPackage ../development/python-modules/pytorch-metric-learning { };
pytorch-metric-learning = callPackage ../development/python-modules/pytorch-metric-learning {
inherit (pkgs.config) cudaSupport;
};
pytorch-msssim = callPackage ../development/python-modules/pytorch-msssim { };