Skip to content

Commit

Permalink
python3Packages.torcheval: init at 0.0.7
Browse files Browse the repository at this point in the history
  • Loading branch information
Benjamin Sparks committed Feb 10, 2025
1 parent b721076 commit 0effacd
Show file tree
Hide file tree
Showing 2 changed files with 89 additions and 0 deletions.
87 changes: 87 additions & 0 deletions pkgs/development/python-modules/torcheval/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
{
lib,
buildPythonPackage,
fetchFromGitHub,

# build-system
setuptools,

# dependencies
torchtnt,
typing-extensions,

# tests
numpy,
pytestCheckHook,
pytest-timeout,
scikit-learn,
torchvision,
cython_0,
}:
let
pname = "torcheval";
version = "0.0.7";
in
buildPythonPackage {
inherit pname version;
pyproject = true;

src = fetchFromGitHub {
owner = "pytorch";
repo = "torcheval";
rev = "f1bc22fc67ec2c77ee519aa4af8079f4fdaa41bb";
hash = "sha256-aVr4qKKE+dpBcJEi1qZJBljFLUl8d7D306Dy8uOojJE=";
};

# Patches are only applied to usages of numpy within tests,
# which are only used for testing purposes (see dev-requirements.txt)
postPatch =
# numpy's `np.NAN` was changed to `np.nan` when numpy 2 was released
''
substituteInPlace tests/metrics/classification/test_accuracy.py tests/metrics/functional/classification/test_accuracy.py \
--replace-fail "np.NAN" "np.nan"
'';

build-system = [ setuptools ];

dependencies = [ typing-extensions ];

pythonImportsCheck = [ "torcheval" ];

nativeCheckInputs = [
pytestCheckHook
numpy
torchtnt
torchvision
pytest-timeout
cython_0
scikit-learn
];

pytestFlagsArray = [
"tests/"

# -- tests/tools/test_module_summary.py --
# models.alexnet(pretrained=True) -> PermissionError: [Errno 13] Permission denied: '/homeless-shelter'
# Touch filesystem and require network access.
# "--deselect=tests/tools/test_module_summary.py::ModuleSummaryTest::test_alexnet_print"
# "--deselect=tests/tools/test_module_summary.py::ModuleSummaryTest::test_alexnet_with_input_tensor"
# "--deselect=tests/tools/test_module_summary.py::ModuleSummaryTest::test_forward_elapsed_time"
# "--deselect=tests/tools/test_module_summary.py::ModuleSummaryTest::test_resnet_max_depth"

# -- tests/metrics/functional/text/test_perplexity.py --
# AssertionError: Scalars are not close!
# Expected 3.537154912949 but got 3.53715443611145
"--deselect=tests/metrics/functional/text/test_perplexity.py::Perplexity::test_perplexity_with_ignore_index"
];

meta = {
description = "Rich collection of performant PyTorch model metrics and tools for PyTorch model evaluations";
homepage = "https://pytorch.org/torcheval";
changelog = "https://github.com/pytorch/torcheval/releases/tag/${version}";

platforms = lib.platforms.linux;
license = with lib.licenses; [ bsd3 ];
maintainers = with lib.maintainers; [ bengsparks ];
};
}
2 changes: 2 additions & 0 deletions pkgs/top-level/python-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -16415,6 +16415,8 @@ self: super: with self; {

torchdiffeq = callPackage ../development/python-modules/torchdiffeq { };

torcheval = callPackage ../development/python-modules/torcheval { };

torchmetrics = callPackage ../development/python-modules/torchmetrics { };

torchio = callPackage ../development/python-modules/torchio { };
Expand Down

0 comments on commit 0effacd

Please sign in to comment.