fix: lazy-import panel in ccflow.utils.hydra#187
Merged
Conversation
Move 'import panel as pn' from module-level to ui_launcher_default() to avoid impacting import time for all hydra tool users. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: Pascal Tomecek <pascal.tomecek@cubistsystematic.com>
Contributor
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #187 +/- ##
==========================================
+ Coverage 95.85% 95.94% +0.09%
==========================================
Files 140 140
Lines 9580 9645 +65
Branches 551 562 +11
==========================================
+ Hits 9183 9254 +71
+ Misses 278 273 -5
+ Partials 119 118 -1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
ccflow/utils/hydra.pyimportspanel as pnat module level, which impacts import time for anything using the ccflow hydra tools — even when the panel UI functionality is never used.Solution
Move
import panel as pnfrom the top-leveltry/exceptblock intoui_launcher_default(), the only function that uses it. This follows the same lazy-import pattern already used inccflow/base.py.Changes
try: import panel as pn / except ImportError: pn = Noneimport panel as pninsideui_launcher_default()withImportErrorhandlingcfg_explain_cli()to usetry/except ImportErroraroundui_launcher_default()instead of the oldpn is not NonecheckTesting
import ccflow.utils.hydrano longer triggers a panel import