Skip to content

Commit

Permalink
feat: add content type helpers (#243)
Browse files Browse the repository at this point in the history
  • Loading branch information
tdstein authored Jul 29, 2024
1 parent 53d95a1 commit 046ace7
Showing 1 changed file with 27 additions and 19 deletions.
46 changes: 27 additions & 19 deletions src/posit/connect/content.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,11 +183,7 @@ def render(self) -> Task:
"""
self.update()

if self.app_mode in {
"rmd-static",
"jupyter-static",
"quarto-static",
}:
if self.is_rendered:
variants = self._variants.find()
variants = [variant for variant in variants if variant.is_default]
if len(variants) != 1:
Expand Down Expand Up @@ -216,20 +212,7 @@ def restart(self) -> None:
"""
self.update()

if self.app_mode in {
"api",
"jupyter-voila",
"python-api",
"python-bokeh",
"python-dash",
"python-fastapi",
"python-shiny",
"python-streamlit",
"quarto-shiny",
"rmd-shiny",
"shiny",
"tensorflow-saved-model",
}:
if self.is_interactive:
random_hash = secrets.token_hex(32)
key = f"_CONNECT_RESTART_TMP_{random_hash}"
self.environment_variables.create(key, random_hash)
Expand Down Expand Up @@ -523,6 +506,31 @@ def app_role(self) -> str:
def tags(self) -> List[dict]:
return self.get("tags", [])

@property
def is_interactive(self) -> bool:
return self.app_mode in {
"api",
"jupyter-voila",
"python-api",
"python-bokeh",
"python-dash",
"python-fastapi",
"python-shiny",
"python-streamlit",
"quarto-shiny",
"rmd-shiny",
"shiny",
"tensorflow-saved-model",
}

@property
def is_rendered(self) -> bool:
return self.app_mode in {
"rmd-static",
"jupyter-static",
"quarto-static",
}


class Content(Resources):
"""Content resource.
Expand Down

0 comments on commit 046ace7

Please sign in to comment.