Skip to content
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

[Feature Request] Handle import exceptions in pages apps #2196

Closed
rredburn opened this issue Aug 16, 2022 · 1 comment · Fixed by #2226
Closed

[Feature Request] Handle import exceptions in pages apps #2196

rredburn opened this issue Aug 16, 2022 · 1 comment · Fixed by #2226

Comments

@rredburn
Copy link

rredburn commented Aug 16, 2022

In a large pages app (several dozen unrelated pages coded by different individuals) it would be helpful to not let an import exception in one page prevent the entire site from loading. We have hit cases where one developer has made assumptions that work in their local dev/test env but don't in production. It seems like _import_layouts_from_pages() could catch exceptions on import, print/log a message indicating which page is failing, and continue loading other pages.

A tangiential use case would be intentional prevention of page loading by simply throwing an import error, something like:

if app_enabled(__name__):
    dash.register_page(__name__, "/page1")
else:
    raise ImportError(f"{__name__} is currently not enabled")

Just guarding register_page is enough to preclude access but still loads unneeded resources from the file which an exception would prevent. My developers really only want to load the page(s) they're working on and ignore dozens of others for rapid test cycles. I'm sure there are many other solutions for conditional page import, this just seemed like one path requiring very little dash support aside from handling import expections (that doesn't involve moving/renaming files).

I can help with a PR if there is agreement on a path forward. Thanks.

@T4rk1n
Copy link
Contributor

T4rk1n commented Sep 8, 2022

Related/Duplicate #2193

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants