Skip to content

Fix dev only resource filtering #3298

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 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/).

## Fixed
- [#3279](https://github.com/plotly/dash/pull/3279) Fix an issue where persisted values were incorrectly pruned when updated via callback. Now, callback returned values are correctly stored in the persistence storage. Fix [#2678](https://github.com/plotly/dash/issues/2678)
- [#3298](https://github.com/plotly/dash/pull/3298) Fix dev_only resources filtering.

## Added
- [#3294](https://github.com/plotly/dash/pull/3294) Added the ability to pass `allow_optional` to Input and State to allow callbacks to work even if these components are not in the dash layout.
Expand Down
11 changes: 9 additions & 2 deletions dash/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"asset_path": str,
"external_only": bool,
"filepath": str,
"dev_only": bool,
},
total=False,
)
Expand Down Expand Up @@ -52,6 +53,7 @@ def _filter_resources(
filtered_resources = []
for s in all_resources:
filtered_resource = {}
valid_resource = True
if "dynamic" in s:
filtered_resource["dynamic"] = s["dynamic"]
if "async" in s:
Expand All @@ -78,12 +80,16 @@ def _filter_resources(
)
if "namespace" in s:
filtered_resource["namespace"] = s["namespace"]

if "external_url" in s and (
s.get("external_only") or not self.config.serve_locally
):
filtered_resource["external_url"] = s["external_url"]
elif "dev_package_path" in s and (dev_bundles or s.get("dev_only")):
filtered_resource["relative_package_path"] = s["dev_package_path"]
if dev_bundles:
filtered_resource["relative_package_path"] = s["dev_package_path"]
else:
valid_resource = False
elif "relative_package_path" in s:
filtered_resource["relative_package_path"] = s["relative_package_path"]
elif "absolute_path" in s:
Expand Down Expand Up @@ -113,7 +119,8 @@ def _filter_resources(
"""
)

filtered_resources.append(filtered_resource)
if valid_resource:
filtered_resources.append(filtered_resource)

return filtered_resources

Expand Down