Skip to content

Commit eef8f1c

Browse files
authored
Merge pull request #2922 from plotly/fix/hash_function
Fixes hash_function and error handler missing call for multi
2 parents 870c661 + 3a179f4 commit eef8f1c

File tree

5 files changed

+12
-6
lines changed

5 files changed

+12
-6
lines changed

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ This project adheres to [Semantic Versioning](https://semver.org/).
77
## Added
88

99
- [#2881](https://github.com/plotly/dash/pull/2881) Add outputs_list to window.dash_clientside.callback_context. Fixes [#2877](https://github.com/plotly/dash/issues/2877).
10+
- [#2903](https://github.com/plotly/dash/pull/2903) Add callback on_error handler, either globally on Dash init or per callback basis. Receives the exception as first argument, can return output(s) or None for `no_update`. Access to original callback context is preserved and `set_props` works inside the error handler.
1011
- [#2936](https://github.com/plotly/dash/pull/2936) Adds support for TypeScript 5.5+.
1112
- [#2789](https://github.com/plotly/dash/pull/2789) Add library loading capacity to `_allow_dynamic_callbacks`
1213

@@ -17,6 +18,8 @@ This project adheres to [Semantic Versioning](https://semver.org/).
1718
- [#2896](https://github.com/plotly/dash/pull/2896) The tabIndex parameter of Div can accept number or string type. Fixes [#2891](https://github.com/plotly/dash/issues/2891)
1819
- [#2900](https://github.com/plotly/dash/pull/2900) Allow strings in layout list. Fixes [#2890](https://github.com/plotly/dash/issues/2890)
1920
- [#2908](https://github.com/plotly/dash/pull/2908) Fix when environment variables are ignored by Dash.run() at runtime. Fixes [#2902](https://github.com/plotly/dash/issues/2902)
21+
- [#2888](https://github.com/plotly/dash/pull/2888) Add id to dcc.Loading DOM. Fixes [#2878](https://github.com/plotly/dash/issues/2878)
22+
- [#2922](https://github.com/plotly/dash/pull/2922) Fix background callback hash_function when source is unavailable. Fixes [#1885](https://github.com/plotly/dash/issues/1885)
2023
- [#2915](https://github.com/plotly/dash/pull/2915) Fix 'AttributeError' when layout is a function that returns a list of components. Fixes [#2905](https://github.com/plotly/dash/issues/2905)
2124
- [#2956](https://github.com/plotly/dash/pull/2956) Add missing useEffect dependency to dcc.Loading component.
2225

dash/_callback.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,7 @@ def add_context(*args, **kwargs):
512512
if not multi:
513513
output_value = NoUpdate()
514514
else:
515-
output_value = [NoUpdate for _ in output_spec]
515+
output_value = [NoUpdate() for _ in output_spec]
516516
else:
517517
raise err
518518

dash/long_callback/managers/__init__.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,11 @@ def _make_set_props_key(key):
107107

108108
@staticmethod
109109
def hash_function(fn, callback_id=""):
110-
fn_source = inspect.getsource(fn)
111-
fn_str = fn_source
110+
try:
111+
fn_source = inspect.getsource(fn)
112+
fn_str = fn_source
113+
except OSError: # pylint: disable=too-broad-exception
114+
fn_str = getattr(fn, "__name__", "")
112115
return hashlib.sha256(
113116
callback_id.encode("utf-8") + fn_str.encode("utf-8")
114117
).hexdigest()

tests/integration/callbacks/test_arbitrary_callbacks.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ def no_output3(_):
8989
assert counter.value == 1
9090

9191

92-
def test_arb003_arbitrary_pages(dash_duo):
92+
def test_arb003_arbitrary_pages(dash_duo, clear_pages_state):
9393
app = Dash(use_pages=True, pages_folder="")
9494

9595
register_page(

tests/integration/test_integration.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ def render_content(tab):
366366
until(lambda: '"label": 3' in dash_duo.find_element("#graph2_info").text, timeout=3)
367367

368368

369-
def test_inin027_multi_page_without_pages_folder(dash_duo):
369+
def test_inin027_multi_page_without_pages_folder(dash_duo, clear_pages_state):
370370
app = Dash(__name__, pages_folder="")
371371

372372
# test for storing arbitrary keyword arguments: An `id` prop is defined for every page
@@ -473,7 +473,7 @@ def on_nested_click(n_clicks):
473473
dash_duo.wait_for_text_to_equal("#nested-output", "Clicked 1 times")
474474

475475

476-
def test_inin029_layout_as_list_with_pages(dash_duo):
476+
def test_inin029_layout_as_list_with_pages(dash_duo, clear_pages_state):
477477
app = Dash(use_pages=True, pages_folder="")
478478

479479
dash.register_page(

0 commit comments

Comments
 (0)