31 buildPythonPackage rec {
36 disabled = pythonOlder "3.8";
38 src = fetchFromGitHub {
42 hash = "sha256-qW36/Xw5oaYKmaMfE5euzkED9CKkjl2O55aO0OpCkfI=";
46 substituteInPlace pyproject.toml \
47 --replace-fail "numpy>=2.0" "numpy"
67 optional-dependencies = {
77 # This pytest hook mocks and catches attempts at accessing the network
78 # tests that try to access the network will raise, get caught, be marked as skipped and tagged as xfailed.
79 conftestSkipNetworkErrors = writeText "conftest.py" ''
80 from _pytest.runner import pytest_runtest_makereport as orig_pytest_runtest_makereport
81 import urllib, requests, transformers
83 class NetworkAccessDeniedError(RuntimeError): pass
84 def deny_network_access(*a, **kw):
85 raise NetworkAccessDeniedError
87 requests.head = deny_network_access
88 requests.get = deny_network_access
89 urllib.request.urlopen = deny_network_access
90 urllib.request.Request = deny_network_access
91 transformers.AutoTokenizer.from_pretrained = deny_network_access
93 def pytest_runtest_makereport(item, call):
94 tr = orig_pytest_runtest_makereport(item, call)
95 if call.excinfo is not None and call.excinfo.type is NetworkAccessDeniedError:
96 tr.outcome = 'skipped'
97 tr.wasxfail = "reason: Requires network access."
103 # when importing the local copy the extension is not found
106 # Add pytest hook skipping tests that access network.
107 # These tests are marked as "Expected fail" (xfail)
108 cat ${conftestSkipNetworkErrors} >> tests/conftest.py
111 nativeCheckInputs = [
116 # optional dependencies, which only serve to enable more tests:
122 #torch # we already skip all its tests due to slowness, adding it does nothing
127 # Test startup hangs with 0.43.0 and Hydra ends with a timeout
130 disabledTestPaths = [
131 # The resulting plots look sane, but does not match pixel-perfectly with the baseline.
132 # Likely due to a matplotlib version mismatch, different backend, or due to missing fonts.
133 "tests/plots/test_summary.py" # FIXME: enable
137 # The same reason as above test_summary.py
138 "test_random_force_plot_negative_sign"
139 "test_random_force_plot_positive_sign"
140 "test_random_summary_layered_violin_with_data2"
141 "test_random_summary_violin_with_data2"
142 "test_simple_bar_with_cohorts_dict"
145 pythonImportsCheck = [ "shap" ];
148 description = "Unified approach to explain the output of any machine learning model";
149 homepage = "https://github.com/slundberg/shap";
150 changelog = "https://github.com/slundberg/shap/releases/tag/v${version}";
151 license = licenses.mit;
152 maintainers = with maintainers; [