Skip to content

Commit

Permalink
Merge pull request #270 from rstudio/mbh-env-obj
Browse files Browse the repository at this point in the history
Use environment objects instead of dicts
  • Loading branch information
meatballhat authored Jun 25, 2020
2 parents c2b381c + 0b25106 commit f39153b
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions rsconnect_jupyter/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
make_notebook_source_bundle,
write_manifest,
)
from rsconnect.environment import Environment
from rsconnect.http_support import CookieJar

from ssl import SSLError
Expand Down Expand Up @@ -152,7 +153,7 @@ def post(self, action):
nb_path = unquote_plus(data["notebook_path"].strip("/"))
api_key = data["api_key"]
app_mode = data["app_mode"]
environment = data.get("environment")
environment_dict = data.get("environment")
disable_tls_check = data["disable_tls_check"]
cadata = data.get("cadata", None)
extra_files = data.get("files", [])
Expand All @@ -174,11 +175,11 @@ def post(self, action):
self.log.exception("Bundle creation failed")
raise web.HTTPError(500, u"Bundle creation failed: %s" % exc)
elif app_mode == "jupyter-static":
if not environment:
if not environment_dict:
raise web.HTTPError(400, "environment is required for jupyter-static app_mode")

try:
bundle = make_notebook_source_bundle(os_path, environment, extra_files)
bundle = make_notebook_source_bundle(os_path, Environment(**environment_dict), extra_files)
except Exception as exc:
self.log.exception("Bundle creation failed")
raise web.HTTPError(500, u"Bundle creation failed: %s" % exc)
Expand Down Expand Up @@ -252,13 +253,13 @@ def post(self, action):
return

if action == "write_manifest":
environment = data["environment"]
environment_dict = data["environment"]
nb_path = unquote_plus(data["notebook_path"].strip("/"))
relative_dir = dirname(nb_path)
os_path = self.contents_manager._get_os_path(nb_path)
output_dir = dirname(os_path)
nb_name = os.path.basename(os_path)
created, skipped = write_manifest(relative_dir, nb_name, environment, output_dir)
created, skipped = write_manifest(relative_dir, nb_name, Environment(**environment_dict), output_dir)
self.finish(json.dumps({"created": created, "skipped": skipped}))
return

Expand Down

0 comments on commit f39153b

Please sign in to comment.