-
-
Notifications
You must be signed in to change notification settings - Fork 531
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
Simplify determining whether script is executed as application #4252
Conversation
Codecov Report
@@ Coverage Diff @@
## main #4252 +/- ##
==========================================
- Coverage 82.70% 82.69% -0.01%
==========================================
Files 237 237
Lines 34276 34283 +7
==========================================
+ Hits 28347 28350 +3
- Misses 5929 5933 +4
Flags with carried forward coverage won't be shown. Click here to find out more.
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
I also use it a lot and would prefer this method over it. 👍 For name suggestions: |
What about .served, .is_served or .in_served_context? |
Thanks @MarcSkovMadsen, decided |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about .served, .is_served or .in_served_context?
I had in mind exactly these alternatives :) Happy with .served
!
It is sometimes useful to write a Panel application in a script and also do some things that have side-effects such as setting
pn.config
options. If you also want this module to be importable without any side-effects you currently have to write something like this:This is ugly and weird since it looks like magic and it's a Panel app not a bokeh app. Therefore I think we should provide a helper that makes it easy to determine if we are in a
panel serve
execution context. Therefore I propose introducingpn.state.served
:Ping @MarcSkovMadsen since you are the main person I've seen use this pattern. I don't love the
in_app
naming so am very eager to hear suggestions.