From 967c1618f204e73f4669532dd6c1abd5bdf02234 Mon Sep 17 00:00:00 2001 From: natsukium Date: Sun, 9 Jul 2023 14:38:02 +0900 Subject: python310Packages.slicer: fix build --- pkgs/development/python-modules/slicer/default.nix | 26 ++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/pkgs/development/python-modules/slicer/default.nix b/pkgs/development/python-modules/slicer/default.nix index 7228c7914619c..8cda4a5e76580 100644 --- a/pkgs/development/python-modules/slicer/default.nix +++ b/pkgs/development/python-modules/slicer/default.nix @@ -1,5 +1,7 @@ { lib , buildPythonPackage +, dos2unix +, fetchpatch , fetchPypi , isPy27 , pytestCheckHook @@ -18,6 +20,30 @@ buildPythonPackage rec { sha256 = "f5d5f7b45f98d155b9c0ba6554fa9770c6b26d5793a3e77a1030fb56910ebeec"; }; + prePatch = '' + dos2unix slicer/* + ''; + + patches = [ + # these patches add support for numpy>=1.24 + (fetchpatch { + url = "https://github.com/interpretml/slicer/commit/028e09e639c4a3c99abe1d537cce30af2eebb081.patch"; + hash = "sha256-jh/cbz7cx2ks6jMNh1gI1n5RS/OHBtSIDZRxUGyrl/I="; + }) + (fetchpatch { + url = "https://github.com/interpretml/slicer/commit/d4bb09f136d7e1f64711633c16a37e7bee738696.patch"; + hash = "sha256-9rh99s4JWF4iKClZ19jvqSeRulL32xB5Use8PGkh/SA="; + }) + (fetchpatch { + url = "https://github.com/interpretml/slicer/commit/74b3683a5a7bd982f9eaaf8d8d665dfdaf2c6604.patch"; + hash = "sha256-R3zsC3udYPFUT93eRhb6wyc9S5n2wceiOunWJ8K+648="; + }) + ]; + + nativeBuildInputs = [ + dos2unix + ]; + nativeCheckInputs = [ pytestCheckHook pandas torch scipy ]; disabledTests = [ -- cgit 1.4.1 From e17146ced5716c3e6027852df68fbd3ea1bfb8be Mon Sep 17 00:00:00 2001 From: natsukium Date: Sun, 9 Jul 2023 14:41:26 +0900 Subject: python310Packages.slicer: refactor - use SRI hash - set `format` - change required python version --- pkgs/development/python-modules/slicer/default.nix | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pkgs/development/python-modules/slicer/default.nix b/pkgs/development/python-modules/slicer/default.nix index 8cda4a5e76580..f678dfb2eaa20 100644 --- a/pkgs/development/python-modules/slicer/default.nix +++ b/pkgs/development/python-modules/slicer/default.nix @@ -3,8 +3,8 @@ , dos2unix , fetchpatch , fetchPypi -, isPy27 , pytestCheckHook +, pythonOlder , pandas , torch , scipy @@ -13,11 +13,12 @@ buildPythonPackage rec { pname = "slicer"; version = "0.0.7"; - disabled = isPy27; + format = "setuptools"; + disabled = pythonOlder "3.6"; src = fetchPypi { inherit pname version; - sha256 = "f5d5f7b45f98d155b9c0ba6554fa9770c6b26d5793a3e77a1030fb56910ebeec"; + hash = "sha256-9dX3tF+Y0VW5wLplVPqXcMaybVeTo+d6EDD7VpEOvuw="; }; prePatch = '' -- cgit 1.4.1 From 04722887b4c7d981ea9011e5bb2316046c997f9c Mon Sep 17 00:00:00 2001 From: natsukium Date: Tue, 11 Jul 2023 12:25:28 +0900 Subject: python310Packages.shap: 0.41.0 -> 0.42.0 Diff: https://github.com/slundberg/shap/compare/refs/tags/v0.41.0...v0.42.0 Changelog: https://github.com/slundberg/shap/releases/tag/v0.42.0 --- pkgs/development/python-modules/shap/default.nix | 45 ++++++++++-------------- 1 file changed, 18 insertions(+), 27 deletions(-) diff --git a/pkgs/development/python-modules/shap/default.nix b/pkgs/development/python-modules/shap/default.nix index 96c9c1f952acd..ed37be606df1f 100644 --- a/pkgs/development/python-modules/shap/default.nix +++ b/pkgs/development/python-modules/shap/default.nix @@ -2,6 +2,7 @@ , buildPythonPackage , fetchFromGitHub , writeText +, fetchpatch , isPy27 , pytestCheckHook , pytest-mpl @@ -27,16 +28,24 @@ buildPythonPackage rec { pname = "shap"; - version = "0.41.0"; + version = "0.42.0"; disabled = isPy27; src = fetchFromGitHub { owner = "slundberg"; repo = pname; rev = "refs/tags/v${version}"; - hash = "sha256-rYVWQ3VRvIObSQPwDRsxhTOGOKNkYkLtiHzVwoB3iJ0="; + hash = "sha256-VGlswr9ywHk4oKSmmAzEC7+E0V2XEFlg19zXVktUdhc="; }; + patches = [ + (fetchpatch { + name = "fix-circular-import-error.patch"; + url = "https://github.com/slundberg/shap/commit/ce118526b19b4a206cf8b496c2cd2b215ef7a91b.patch"; + hash = "sha256-n2yFjFgc2VSFKb4ZJx775HblULWfnQSEnqjfPa8AOt0="; + }) + ]; + propagatedBuildInputs = [ numpy scipy @@ -58,7 +67,7 @@ buildPythonPackage rec { # tests that try to access the network will raise, get caught, be marked as skipped and tagged as xfailed. conftestSkipNetworkErrors = writeText "conftest.py" '' from _pytest.runner import pytest_runtest_makereport as orig_pytest_runtest_makereport - import urllib, requests + import urllib, requests, transformers class NetworkAccessDeniedError(RuntimeError): pass def deny_network_access(*a, **kw): @@ -68,6 +77,7 @@ buildPythonPackage rec { requests.get = deny_network_access urllib.request.urlopen = deny_network_access urllib.request.Request = deny_network_access + transformers.AutoTokenizer.from_pretrained = deny_network_access def pytest_runtest_makereport(item, call): tr = orig_pytest_runtest_makereport(item, call) @@ -81,14 +91,11 @@ buildPythonPackage rec { # when importing the local copy the extension is not found rm -r shap - # coverage testing is a waste considering how much we have to skip - substituteInPlace pytest.ini \ - --replace "--cov=shap --cov-report=term-missing" "" - # Add pytest hook skipping tests that access network. # These tests are marked as "Expected fail" (xfail) cat ${conftestSkipNetworkErrors} >> tests/conftest.py ''; + nativeCheckInputs = [ pytestCheckHook pytest-mpl @@ -106,30 +113,17 @@ buildPythonPackage rec { sentencepiece ]; disabledTestPaths = [ - # takes forever without GPU acceleration - "tests/explainers/test_deep.py" - "tests/explainers/test_gradient.py" - # requires GPU. We skip here instead of having pytest repeatedly check for GPU - "tests/explainers/test_gpu_tree.py" # The resulting plots look sane, but does not match pixel-perfectly with the baseline. # Likely due to a matplotlib version mismatch, different backend, or due to missing fonts. "tests/plots/test_summary.py" # FIXME: enable - # 100% of the tests in these paths require network - "tests/explainers/test_explainer.py" - "tests/explainers/test_exact.py" - "tests/explainers/test_partition.py" - "tests/maskers/test_fixed_composite.py" - "tests/maskers/test_text.py" - "tests/models/test_teacher_forcing_logits.py" - "tests/models/test_text_generation.py" ]; disabledTests = [ - # unstable. A xgboost-enabled test. possibly related: https://github.com/slundberg/shap/issues/2480 - "test_provided_background_tree_path_dependent" + # The same reason as above test_summary.py + "test_simple_bar_with_cohorts_dict" + "test_random_summary_violin_with_data2" + "test_random_summary_layered_violin_with_data2" ]; - #pytestFlagsArray = ["-x" "-W" "ignore"]; # uncomment this to debug - pythonImportsCheck = [ "shap" "shap.explainers" @@ -150,8 +144,5 @@ buildPythonPackage rec { license = licenses.mit; maintainers = with maintainers; [ evax ]; platforms = platforms.unix; - # No support for scikit-learn > 1.2 - # https://github.com/slundberg/shap/issues/2866 - broken = true; }; } -- cgit 1.4.1 From c4618e062299160a94f813d42ae6a5de0ec51413 Mon Sep 17 00:00:00 2001 From: natsukium Date: Tue, 11 Jul 2023 14:26:37 +0900 Subject: python310Packages.shap: refactor - sort items in alphabetical order - set format - change required python version etc. --- pkgs/development/python-modules/shap/default.nix | 73 +++++++++++++----------- 1 file changed, 41 insertions(+), 32 deletions(-) diff --git a/pkgs/development/python-modules/shap/default.nix b/pkgs/development/python-modules/shap/default.nix index ed37be606df1f..9284d645215b4 100644 --- a/pkgs/development/python-modules/shap/default.nix +++ b/pkgs/development/python-modules/shap/default.nix @@ -1,39 +1,43 @@ { lib , buildPythonPackage , fetchFromGitHub -, writeText , fetchpatch -, isPy27 , pytestCheckHook -, pytest-mpl +, pythonOlder +, writeText +, catboost +, cloudpickle +, ipython +, lightgbm +, lime +, matplotlib +, nose +, numba , numpy -, scipy -, scikit-learn -, pandas -, transformers , opencv4 -, lightgbm -, catboost +, pandas , pyspark +, pytest-mpl +, scikit-learn +, scipy , sentencepiece -, tqdm +, setuptools , slicer -, numba -, matplotlib -, nose -, lime -, cloudpickle -, ipython +, tqdm +, transformers +, xgboost }: buildPythonPackage rec { pname = "shap"; version = "0.42.0"; - disabled = isPy27; + format = "pyproject"; + + disabled = pythonOlder "3.7"; src = fetchFromGitHub { owner = "slundberg"; - repo = pname; + repo = "shap"; rev = "refs/tags/v${version}"; hash = "sha256-VGlswr9ywHk4oKSmmAzEC7+E0V2XEFlg19zXVktUdhc="; }; @@ -46,15 +50,19 @@ buildPythonPackage rec { }) ]; + nativeBuildInputs = [ + setuptools + ]; + propagatedBuildInputs = [ + cloudpickle + numba numpy - scipy - scikit-learn pandas - tqdm + scikit-learn + scipy slicer - numba - cloudpickle + tqdm ]; passthru.optional-dependencies = { @@ -97,26 +105,28 @@ buildPythonPackage rec { ''; nativeCheckInputs = [ - pytestCheckHook - pytest-mpl + ipython matplotlib nose - ipython + pytest-mpl + pytestCheckHook # optional dependencies, which only serve to enable more tests: - opencv4 - #pytorch # we already skip all its tests due to slowness, adding it does nothing - transformers - #xgboost # numerically unstable? xgboost tests randomly fails pending on nixpkgs revision - lightgbm catboost + lightgbm + opencv4 pyspark sentencepiece + #torch # we already skip all its tests due to slowness, adding it does nothing + transformers + xgboost ]; + disabledTestPaths = [ # The resulting plots look sane, but does not match pixel-perfectly with the baseline. # Likely due to a matplotlib version mismatch, different backend, or due to missing fonts. "tests/plots/test_summary.py" # FIXME: enable ]; + disabledTests = [ # The same reason as above test_summary.py "test_simple_bar_with_cohorts_dict" @@ -143,6 +153,5 @@ buildPythonPackage rec { changelog = "https://github.com/slundberg/shap/releases/tag/v${version}"; license = licenses.mit; maintainers = with maintainers; [ evax ]; - platforms = platforms.unix; }; } -- cgit 1.4.1