Skip to content

Commit

Permalink
Merge pull request #2922 from plotly/fix/hash_function
Browse files Browse the repository at this point in the history
Fixes hash_function and error handler missing call for multi
  • Loading branch information
T4rk1n authored Aug 28, 2024
2 parents 870c661 + 3a179f4 commit eef8f1c
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 6 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ This project adheres to [Semantic Versioning](https://semver.org/).
## Added

- [#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).
- [#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.
- [#2936](https://github.com/plotly/dash/pull/2936) Adds support for TypeScript 5.5+.
- [#2789](https://github.com/plotly/dash/pull/2789) Add library loading capacity to `_allow_dynamic_callbacks`

Expand All @@ -17,6 +18,8 @@ This project adheres to [Semantic Versioning](https://semver.org/).
- [#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)
- [#2900](https://github.com/plotly/dash/pull/2900) Allow strings in layout list. Fixes [#2890](https://github.com/plotly/dash/issues/2890)
- [#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)
- [#2888](https://github.com/plotly/dash/pull/2888) Add id to dcc.Loading DOM. Fixes [#2878](https://github.com/plotly/dash/issues/2878)
- [#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)
- [#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)
- [#2956](https://github.com/plotly/dash/pull/2956) Add missing useEffect dependency to dcc.Loading component.

Expand Down
2 changes: 1 addition & 1 deletion dash/_callback.py
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,7 @@ def add_context(*args, **kwargs):
if not multi:
output_value = NoUpdate()
else:
output_value = [NoUpdate for _ in output_spec]
output_value = [NoUpdate() for _ in output_spec]
else:
raise err

Expand Down
7 changes: 5 additions & 2 deletions dash/long_callback/managers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,11 @@ def _make_set_props_key(key):

@staticmethod
def hash_function(fn, callback_id=""):
fn_source = inspect.getsource(fn)
fn_str = fn_source
try:
fn_source = inspect.getsource(fn)
fn_str = fn_source
except OSError: # pylint: disable=too-broad-exception
fn_str = getattr(fn, "__name__", "")
return hashlib.sha256(
callback_id.encode("utf-8") + fn_str.encode("utf-8")
).hexdigest()
2 changes: 1 addition & 1 deletion tests/integration/callbacks/test_arbitrary_callbacks.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def no_output3(_):
assert counter.value == 1


def test_arb003_arbitrary_pages(dash_duo):
def test_arb003_arbitrary_pages(dash_duo, clear_pages_state):
app = Dash(use_pages=True, pages_folder="")

register_page(
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ def render_content(tab):
until(lambda: '"label": 3' in dash_duo.find_element("#graph2_info").text, timeout=3)


def test_inin027_multi_page_without_pages_folder(dash_duo):
def test_inin027_multi_page_without_pages_folder(dash_duo, clear_pages_state):
app = Dash(__name__, pages_folder="")

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


def test_inin029_layout_as_list_with_pages(dash_duo):
def test_inin029_layout_as_list_with_pages(dash_duo, clear_pages_state):
app = Dash(use_pages=True, pages_folder="")

dash.register_page(
Expand Down

0 comments on commit eef8f1c

Please sign in to comment.