python312Packages.captum: init at 0.7.0 (#356087)

This commit is contained in:
Pol Dellaiera 2024-11-20 17:33:57 +01:00 committed by GitHub
commit c3f9d32635
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 91 additions and 0 deletions

View File

@ -0,0 +1,89 @@
{
lib,
stdenv,
fetchFromGitHub,
pythonOlder,
buildPythonPackage,
pytestCheckHook,
setuptools,
matplotlib,
numpy,
packaging,
torch,
tqdm,
flask,
flask-compress,
}:
buildPythonPackage rec {
pname = "captum";
version = "0.7.0";
pyproject = true;
build-system = [ setuptools ];
src = fetchFromGitHub {
owner = "pytorch";
repo = "captum";
rev = "refs/tags/v${version}";
hash = "sha256-1VOvPqxn6CNnmv7M8fl7JrqRfJQUH2tnXRCUqKnl7i0=";
};
dependencies = [
matplotlib
numpy
packaging
torch
tqdm
];
pythonImportsCheck = [ "captum" ];
nativeCheckInputs = [
pytestCheckHook
flask
flask-compress
];
disabledTestPaths =
[
# These tests requires `parametrized` module (https://pypi.org/project/parametrized/) which seem to be unavailable on Nix.
"tests/attr/test_dataloader_attr.py"
"tests/attr/test_interpretable_input.py"
"tests/attr/test_llm_attr.py"
"tests/influence/_core/test_dataloader.py"
"tests/influence/_core/test_tracin_aggregate_influence.py"
"tests/influence/_core/test_tracin_intermediate_quantities.py"
"tests/influence/_core/test_tracin_k_most_influential.py"
"tests/influence/_core/test_tracin_regression.py"
"tests/influence/_core/test_tracin_self_influence.py"
"tests/influence/_core/test_tracin_show_progress.py"
"tests/influence/_core/test_tracin_validation.py"
"tests/influence/_core/test_tracin_xor.py"
"tests/insights/test_contribution.py"
"tests/module/test_binary_concrete_stochastic_gates.py"
"tests/module/test_gaussian_stochastic_gates.py"
]
++ lib.optionals stdenv.hostPlatform.isDarwin [
# These tests are failing on macOS:
# > E AttributeError: module 'torch.distributed' has no attribute 'init_process_group'
"tests/attr/test_data_parallel.py"
]
++ lib.optionals (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isAarch64) [
# Issue reported upstream at https://github.com/pytorch/captum/issues/1447
"tests/concept/test_tcav.py"
];
disabledTests = [
# Failing tests
"test_softmax_classification_batch_multi_target"
"test_softmax_classification_batch_zero_baseline"
];
meta = {
description = "Model interpretability and understanding for PyTorch";
homepage = "https://github.com/pytorch/captum";
license = lib.licenses.bsd3;
maintainers = with lib.maintainers; [ drupol ];
};
}

View File

@ -2039,6 +2039,8 @@ self: super: with self; {
captcha = callPackage ../development/python-modules/captcha { };
captum = callPackage ../development/python-modules/captum { };
capturer = callPackage ../development/python-modules/capturer { };
carbon = callPackage ../development/python-modules/carbon { };