Skip to content

Commit 046ace7

Browse files
authored
feat: add content type helpers (#243)
1 parent 53d95a1 commit 046ace7

File tree

1 file changed

+27
-19
lines changed

1 file changed

+27
-19
lines changed

src/posit/connect/content.py

Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -183,11 +183,7 @@ def render(self) -> Task:
183183
"""
184184
self.update()
185185

186-
if self.app_mode in {
187-
"rmd-static",
188-
"jupyter-static",
189-
"quarto-static",
190-
}:
186+
if self.is_rendered:
191187
variants = self._variants.find()
192188
variants = [variant for variant in variants if variant.is_default]
193189
if len(variants) != 1:
@@ -216,20 +212,7 @@ def restart(self) -> None:
216212
"""
217213
self.update()
218214

219-
if self.app_mode in {
220-
"api",
221-
"jupyter-voila",
222-
"python-api",
223-
"python-bokeh",
224-
"python-dash",
225-
"python-fastapi",
226-
"python-shiny",
227-
"python-streamlit",
228-
"quarto-shiny",
229-
"rmd-shiny",
230-
"shiny",
231-
"tensorflow-saved-model",
232-
}:
215+
if self.is_interactive:
233216
random_hash = secrets.token_hex(32)
234217
key = f"_CONNECT_RESTART_TMP_{random_hash}"
235218
self.environment_variables.create(key, random_hash)
@@ -523,6 +506,31 @@ def app_role(self) -> str:
523506
def tags(self) -> List[dict]:
524507
return self.get("tags", [])
525508

509+
@property
510+
def is_interactive(self) -> bool:
511+
return self.app_mode in {
512+
"api",
513+
"jupyter-voila",
514+
"python-api",
515+
"python-bokeh",
516+
"python-dash",
517+
"python-fastapi",
518+
"python-shiny",
519+
"python-streamlit",
520+
"quarto-shiny",
521+
"rmd-shiny",
522+
"shiny",
523+
"tensorflow-saved-model",
524+
}
525+
526+
@property
527+
def is_rendered(self) -> bool:
528+
return self.app_mode in {
529+
"rmd-static",
530+
"jupyter-static",
531+
"quarto-static",
532+
}
533+
526534

527535
class Content(Resources):
528536
"""Content resource.

0 commit comments

Comments
 (0)