Skip to content
This repository was archived by the owner on Nov 13, 2024. It is now read-only.

Commit f39153b

Browse files
authored
Merge pull request #270 from rstudio/mbh-env-obj
Use environment objects instead of dicts
2 parents c2b381c + 0b25106 commit f39153b

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

rsconnect_jupyter/__init__.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
make_notebook_source_bundle,
2525
write_manifest,
2626
)
27+
from rsconnect.environment import Environment
2728
from rsconnect.http_support import CookieJar
2829

2930
from ssl import SSLError
@@ -152,7 +153,7 @@ def post(self, action):
152153
nb_path = unquote_plus(data["notebook_path"].strip("/"))
153154
api_key = data["api_key"]
154155
app_mode = data["app_mode"]
155-
environment = data.get("environment")
156+
environment_dict = data.get("environment")
156157
disable_tls_check = data["disable_tls_check"]
157158
cadata = data.get("cadata", None)
158159
extra_files = data.get("files", [])
@@ -174,11 +175,11 @@ def post(self, action):
174175
self.log.exception("Bundle creation failed")
175176
raise web.HTTPError(500, u"Bundle creation failed: %s" % exc)
176177
elif app_mode == "jupyter-static":
177-
if not environment:
178+
if not environment_dict:
178179
raise web.HTTPError(400, "environment is required for jupyter-static app_mode")
179180

180181
try:
181-
bundle = make_notebook_source_bundle(os_path, environment, extra_files)
182+
bundle = make_notebook_source_bundle(os_path, Environment(**environment_dict), extra_files)
182183
except Exception as exc:
183184
self.log.exception("Bundle creation failed")
184185
raise web.HTTPError(500, u"Bundle creation failed: %s" % exc)
@@ -252,13 +253,13 @@ def post(self, action):
252253
return
253254

254255
if action == "write_manifest":
255-
environment = data["environment"]
256+
environment_dict = data["environment"]
256257
nb_path = unquote_plus(data["notebook_path"].strip("/"))
257258
relative_dir = dirname(nb_path)
258259
os_path = self.contents_manager._get_os_path(nb_path)
259260
output_dir = dirname(os_path)
260261
nb_name = os.path.basename(os_path)
261-
created, skipped = write_manifest(relative_dir, nb_name, environment, output_dir)
262+
created, skipped = write_manifest(relative_dir, nb_name, Environment(**environment_dict), output_dir)
262263
self.finish(json.dumps({"created": created, "skipped": skipped}))
263264
return
264265

0 commit comments

Comments
 (0)