Skip to content

Commit

Permalink
feat: add content type helpers
Browse files Browse the repository at this point in the history
  • Loading branch information
tdstein committed Jul 26, 2024
1 parent 2132431 commit ef1cf63
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 @@ -185,11 +185,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 @@ -218,20 +214,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 @@ -527,6 +510,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 ef1cf63

Please sign in to comment.