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

Ddk eager flag fix #985

Closed
wants to merge 14 commits into from
Closed

Ddk eager flag fix #985

wants to merge 14 commits into from

Conversation

Marc-Andre-Rivet
Copy link
Contributor

Fixes #984 - delays (reevaluates) Css and Scripts at the moment when the server is ready instead of doing so during initialization.

This should allow us to handle both (1) app.run_server and (2) gunicorn / multi-page apps correctly.

dash/dash.py Outdated

# static files from the packages
self.css = Css(self.css.config.serve_locally)
self.scripts = Scripts(self.scripts.config.serve_locally, eager_loading)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to recreate these here? Wouldn't it be sufficient to just say

self.scripts.config.eager_loading = eager_loading

or even

for module_name in ComponentRegistry.registry:
    module = sys.modules[module_name]
    if getattr(module, '_force_eager_loading', False):
        self.scripts.config.eager_loading = True
        break

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah! I think you're right. I think I misunderstood how/when this got evaluated. But the filter only gets called later.

dash/dash.py Outdated
if self.config.include_assets_files:
self._walk_assets_directory()

self._validate_layout()

self._generate_scripts_html()
self._generate_css_dist_html()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like we need these for their side-effects, or perhaps recreating self.scripts and self.css was the problem? Regardless, I don't see any harm bringing this back.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. Undoing this.

@Marc-Andre-Rivet
Copy link
Contributor Author

@alexcjohnson Closing this in favor of #986 as the baseline was master and caused a bunch of artifact files to be included..

@alexcjohnson alexcjohnson deleted the ddk-eager-flag-fix branch July 28, 2021 17:22
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 this pull request may close these issues.

[BUG] _force_eager_loading depends on import/instantiation order
2 participants