From 5e71eb334ebc3707ff06d3222f7f169fc2be6de3 Mon Sep 17 00:00:00 2001 From: Bincheng Wu Date: Thu, 26 May 2022 11:28:42 -0400 Subject: [PATCH 01/11] revert parameters to optional for rsc-jupyter --- rsconnect/bundle.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/rsconnect/bundle.py b/rsconnect/bundle.py index 50dc8cb0..531334f7 100644 --- a/rsconnect/bundle.py +++ b/rsconnect/bundle.py @@ -182,9 +182,9 @@ def write_manifest( nb_name: str, environment: Environment, output_dir: str, - hide_all_input: bool, - hide_tagged_input: bool, - image: str, + hide_all_input: bool = False, + hide_tagged_input: bool = False, + image: str = None, ) -> typing.Tuple[list, list]: """Create a manifest for source publishing the specified notebook. @@ -259,10 +259,10 @@ def iter_files(): def make_notebook_source_bundle( file: str, environment: Environment, - image: str, extra_files: typing.List[str], - hide_all_input: bool, - hide_tagged_input: bool, + hide_all_input: bool = False, + hide_tagged_input: bool = False, + image: str = None, ) -> typing.IO[bytes]: """Create a bundle containing the specified notebook and python environment. @@ -366,10 +366,10 @@ def make_html_manifest( def make_notebook_html_bundle( filename: str, python: str, - image: str, - hide_all_input: bool, - hide_tagged_input: bool, - check_output: typing.Callable, # used to default to subprocess.check_output + hide_all_input: bool = False, + hide_tagged_input: bool = False, + image: str = False, + check_output: typing.Callable = subprocess.check_output, # used to default to subprocess.check_output ) -> typing.IO[bytes]: # noinspection SpellCheckingInspection if check_output is None: From 5145510680cd75ad2ec134708363267c591ebed1 Mon Sep 17 00:00:00 2001 From: Bincheng Wu Date: Thu, 26 May 2022 11:38:40 -0400 Subject: [PATCH 02/11] revert some parameters in actions --- rsconnect/actions.py | 15 +++++++++++---- rsconnect/bundle.py | 2 +- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/rsconnect/actions.py b/rsconnect/actions.py index 016c9c7e..dcc39ed1 100644 --- a/rsconnect/actions.py +++ b/rsconnect/actions.py @@ -1492,10 +1492,10 @@ def create_notebook_deployment_bundle( app_mode: AppMode, python: str, environment: Environment, - image: str, extra_files_need_validating: bool, - hide_all_input: bool, - hide_tagged_input: bool, + hide_all_input: bool = False, + hide_tagged_input: bool = False, + image: str = None, ) -> typing.IO[bytes]: """ Create an in-memory bundle, ready to deploy. @@ -1523,7 +1523,14 @@ def create_notebook_deployment_bundle( if app_mode == AppModes.STATIC: try: - return make_notebook_html_bundle(file_name, python, image, hide_all_input, hide_tagged_input, None) + return make_notebook_html_bundle( + file_name, + python, + hide_all_input=hide_all_input, + hide_tagged_input=hide_tagged_input, + image=image, + check_output=None, + ) except subprocess.CalledProcessError as exc: # Jupyter rendering failures are often due to # user code failing, vs. an internal failure of rsconnect-python. diff --git a/rsconnect/bundle.py b/rsconnect/bundle.py index 531334f7..2653c337 100644 --- a/rsconnect/bundle.py +++ b/rsconnect/bundle.py @@ -368,7 +368,7 @@ def make_notebook_html_bundle( python: str, hide_all_input: bool = False, hide_tagged_input: bool = False, - image: str = False, + image: str = None, check_output: typing.Callable = subprocess.check_output, # used to default to subprocess.check_output ) -> typing.IO[bytes]: # noinspection SpellCheckingInspection From e8e7046c1ddff83c0e6890282d1b3e51084692b3 Mon Sep 17 00:00:00 2001 From: Bincheng Wu Date: Thu, 26 May 2022 11:43:11 -0400 Subject: [PATCH 03/11] revert more actions --- rsconnect/actions.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/rsconnect/actions.py b/rsconnect/actions.py index dcc39ed1..2ebd06fb 100644 --- a/rsconnect/actions.py +++ b/rsconnect/actions.py @@ -625,7 +625,15 @@ def deploy_jupyter_notebook( force_generate=force_generate, ) bundle = create_notebook_deployment_bundle( - file_name, extra_files, app_mode, python, environment, image, True, hide_all_input, hide_tagged_input + file_name, + extra_files, + app_mode, + python, + environment, + True, + hide_all_input=hide_all_input, + hide_tagged_input=hide_tagged_input, + image=image, ) return _finalize_deploy( connect_server, @@ -1537,7 +1545,12 @@ def create_notebook_deployment_bundle( raise api.RSConnectException(str(exc)) else: return make_notebook_source_bundle( - file_name, environment, image, extra_files, hide_all_input, hide_tagged_input + file_name, + environment, + extra_files, + hide_all_input=hide_all_input, + hide_tagged_input=hide_tagged_input, + image=image, ) From 98bac97dfbf240debf4443bf95d14cae7b57cada Mon Sep 17 00:00:00 2001 From: Bincheng Wu Date: Thu, 26 May 2022 11:50:29 -0400 Subject: [PATCH 04/11] update tests --- tests/test_actions.py | 4 ++-- tests/test_bundle.py | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/tests/test_actions.py b/tests/test_actions.py index 667f8f5c..4cb60a1f 100644 --- a/tests/test_actions.py +++ b/tests/test_actions.py @@ -240,10 +240,10 @@ def test_gather_basic_deployment_info_for_api_validates(self): def test_create_notebook_deployment_bundle_validates(self): file_name = get_dir(join("pip1", "requirements.txt")) with self.assertRaises(RSConnectException): - create_notebook_deployment_bundle(file_name, [], None, None, None, None, True, False, False) + create_notebook_deployment_bundle(file_name, [], None, None, None, None) file_name = get_dir(join("pip1", "dummy.ipynb")) with self.assertRaises(RSConnectException): - create_notebook_deployment_bundle(file_name, ["bogus"], None, None, None, None, True, False, False) + create_notebook_deployment_bundle(file_name, ["bogus"], None, None, None, None) def test_create_api_deployment_bundle_validates(self): directory = get_api_path("flask") diff --git a/tests/test_bundle.py b/tests/test_bundle.py index a4f47827..ee25ecb8 100644 --- a/tests/test_bundle.py +++ b/tests/test_bundle.py @@ -115,7 +115,10 @@ def test_source_bundle2(self): environment = detect_environment(directory) with make_notebook_source_bundle( - nb_path, environment, "rstudio/connect:bionic", ["data.csv"], False, False + nb_path, + environment, + ["data.csv"], + image="rstudio/connect:bionic", ) as bundle, tarfile.open(mode="r:gz", fileobj=bundle) as tar: names = sorted(tar.getnames()) From 81dcc58e9dbbe8b669985a844cee50adef3ff5f4 Mon Sep 17 00:00:00 2001 From: Bincheng Wu Date: Thu, 26 May 2022 12:03:49 -0400 Subject: [PATCH 05/11] update test_actions --- tests/test_actions.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/test_actions.py b/tests/test_actions.py index 4cb60a1f..6732c5f5 100644 --- a/tests/test_actions.py +++ b/tests/test_actions.py @@ -240,10 +240,14 @@ def test_gather_basic_deployment_info_for_api_validates(self): def test_create_notebook_deployment_bundle_validates(self): file_name = get_dir(join("pip1", "requirements.txt")) with self.assertRaises(RSConnectException): - create_notebook_deployment_bundle(file_name, [], None, None, None, None) + create_notebook_deployment_bundle( + file_name, [], None, None, None, True, hide_all_input=False, hide_tagged_input=False, image=None + ) file_name = get_dir(join("pip1", "dummy.ipynb")) with self.assertRaises(RSConnectException): - create_notebook_deployment_bundle(file_name, ["bogus"], None, None, None, None) + create_notebook_deployment_bundle( + file_name, ["bogus"], None, None, None, True, hide_all_input=False, hide_tagged_input=False, image=None + ) def test_create_api_deployment_bundle_validates(self): directory = get_api_path("flask") From 4388bfa417134d2c184617f0d7f3f35ed8388845 Mon Sep 17 00:00:00 2001 From: Bincheng Wu Date: Thu, 26 May 2022 14:57:07 -0400 Subject: [PATCH 06/11] make hide_all_input and hide_tagged_input required --- rsconnect/actions.py | 14 +++++++------- rsconnect/bundle.py | 12 ++++++------ tests/test_bundle.py | 12 ++++++++---- 3 files changed, 21 insertions(+), 17 deletions(-) diff --git a/rsconnect/actions.py b/rsconnect/actions.py index 2ebd06fb..ea2ec068 100644 --- a/rsconnect/actions.py +++ b/rsconnect/actions.py @@ -1501,9 +1501,9 @@ def create_notebook_deployment_bundle( python: str, environment: Environment, extra_files_need_validating: bool, - hide_all_input: bool = False, - hide_tagged_input: bool = False, - image: str = None, + hide_all_input: bool, + hide_tagged_input: bool, + image: str, ) -> typing.IO[bytes]: """ Create an in-memory bundle, ready to deploy. @@ -1534,8 +1534,8 @@ def create_notebook_deployment_bundle( return make_notebook_html_bundle( file_name, python, - hide_all_input=hide_all_input, - hide_tagged_input=hide_tagged_input, + hide_all_input, + hide_tagged_input, image=image, check_output=None, ) @@ -1548,8 +1548,8 @@ def create_notebook_deployment_bundle( file_name, environment, extra_files, - hide_all_input=hide_all_input, - hide_tagged_input=hide_tagged_input, + hide_all_input, + hide_tagged_input, image=image, ) diff --git a/rsconnect/bundle.py b/rsconnect/bundle.py index 2653c337..d9e1e604 100644 --- a/rsconnect/bundle.py +++ b/rsconnect/bundle.py @@ -182,8 +182,8 @@ def write_manifest( nb_name: str, environment: Environment, output_dir: str, - hide_all_input: bool = False, - hide_tagged_input: bool = False, + hide_all_input: bool, + hide_tagged_input: bool, image: str = None, ) -> typing.Tuple[list, list]: """Create a manifest for source publishing the specified notebook. @@ -260,8 +260,8 @@ def make_notebook_source_bundle( file: str, environment: Environment, extra_files: typing.List[str], - hide_all_input: bool = False, - hide_tagged_input: bool = False, + hide_all_input: bool, + hide_tagged_input: bool, image: str = None, ) -> typing.IO[bytes]: """Create a bundle containing the specified notebook and python environment. @@ -366,8 +366,8 @@ def make_html_manifest( def make_notebook_html_bundle( filename: str, python: str, - hide_all_input: bool = False, - hide_tagged_input: bool = False, + hide_all_input: bool, + hide_tagged_input: bool, image: str = None, check_output: typing.Callable = subprocess.check_output, # used to default to subprocess.check_output ) -> typing.IO[bytes]: diff --git a/tests/test_bundle.py b/tests/test_bundle.py index ee25ecb8..fbfc8d64 100644 --- a/tests/test_bundle.py +++ b/tests/test_bundle.py @@ -50,9 +50,9 @@ def test_source_bundle1(self): # runs in the notebook server. We need the introspection to run in # the kernel environment and not the notebook server environment. environment = detect_environment(directory) - with make_notebook_source_bundle(nb_path, environment, None, None, False, False) as bundle, tarfile.open( - mode="r:gz", fileobj=bundle - ) as tar: + with make_notebook_source_bundle( + nb_path, environment, hide_all_input=False, hide_tagged_input=False, image=None + ) as bundle, tarfile.open(mode="r:gz", fileobj=bundle) as tar: names = sorted(tar.getnames()) self.assertEqual( @@ -118,6 +118,8 @@ def test_source_bundle2(self): nb_path, environment, ["data.csv"], + hide_all_input=False, + hide_tagged_input=False, image="rstudio/connect:bionic", ) as bundle, tarfile.open(mode="r:gz", fileobj=bundle) as tar: @@ -222,7 +224,9 @@ def do_test_html_bundle(self, directory): self.maxDiff = 5000 nb_path = join(directory, "dummy.ipynb") - bundle = make_notebook_html_bundle(nb_path, sys.executable, None, False, False, None) + bundle = make_notebook_html_bundle( + nb_path, sys.executable, hide_all_input=False, hide_tagged_input=False, image=None, check_output=None + ) tar = tarfile.open(mode="r:gz", fileobj=bundle) From 93aefd424cad5661ec51495d8c73d51fa3341410 Mon Sep 17 00:00:00 2001 From: Bincheng Wu Date: Thu, 26 May 2022 15:01:57 -0400 Subject: [PATCH 07/11] add missing extra_files back to test --- tests/test_bundle.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_bundle.py b/tests/test_bundle.py index fbfc8d64..915fcc5e 100644 --- a/tests/test_bundle.py +++ b/tests/test_bundle.py @@ -51,7 +51,7 @@ def test_source_bundle1(self): # the kernel environment and not the notebook server environment. environment = detect_environment(directory) with make_notebook_source_bundle( - nb_path, environment, hide_all_input=False, hide_tagged_input=False, image=None + nb_path, environment, None, hide_all_input=False, hide_tagged_input=False, image=None ) as bundle, tarfile.open(mode="r:gz", fileobj=bundle) as tar: names = sorted(tar.getnames()) From 034027d98116d33d87ac08de589e9d23e6ba1b3c Mon Sep 17 00:00:00 2001 From: Bill Sager Date: Thu, 26 May 2022 13:21:33 -0700 Subject: [PATCH 08/11] move image in pubic api to optional --- rsconnect/actions.py | 60 +++++++++++++++++++++---------------------- rsconnect/bundle.py | 39 ++++++++++++++-------------- rsconnect/main.py | 17 ++++++------ tests/test_actions.py | 4 +-- tests/test_bundle.py | 16 ++++++------ 5 files changed, 67 insertions(+), 69 deletions(-) diff --git a/rsconnect/actions.py b/rsconnect/actions.py index 016c9c7e..d67f06ea 100644 --- a/rsconnect/actions.py +++ b/rsconnect/actions.py @@ -533,7 +533,7 @@ def write_quarto_manifest_json( environment: Environment, extra_files: typing.List[str], excludes: typing.List[str], - image: str, + image: str = None, ) -> None: """ Creates and writes a manifest.json file for the given Quarto project. @@ -544,11 +544,11 @@ def write_quarto_manifest_json( :param environment: The (optional) Python environment to use. :param extra_files: Any extra files to include in the manifest. :param excludes: A sequence of glob patterns to exclude when enumerating files to bundle. - :param image: the docker image to be specified for off-host execution (or None if no image is specified). + :param image: the optional docker image to be specified for off-host execution. Default = None. """ extra_files = validate_extra_files(directory, extra_files) - manifest, _ = make_quarto_manifest(directory, inspect, app_mode, image, environment, extra_files, excludes) + manifest, _ = make_quarto_manifest(directory, inspect, app_mode, environment, extra_files, excludes, image) manifest_path = join(directory, "manifest.json") write_manifest_json(manifest_path, manifest) @@ -567,7 +567,6 @@ def deploy_jupyter_notebook( connect_server: api.RSConnectServer, file_name: str, extra_files: typing.List[str], - image: str, new: bool, app_id: int, title: str, @@ -578,6 +577,7 @@ def deploy_jupyter_notebook( log_callback: typing.Callable, hide_all_input: bool, hide_tagged_input: bool, + image: str = None, ) -> typing.Tuple[typing.Any, typing.List]: """ A function to deploy a Jupyter notebook to Connect. Depending on the files involved @@ -586,7 +586,6 @@ def deploy_jupyter_notebook( :param connect_server: the Connect server information. :param file_name: the Jupyter notebook file to deploy. :param extra_files: any extra files that should be included in the deploy. - :param image: an optional docker image for off-host execution, previous default = None. :param new: a flag indicating a new deployment, previous default = False. :param app_id: the ID of an existing application to deploy new files for, previous default = None. :param title: an optional title for the deploy. If this is not provided, one will @@ -605,6 +604,7 @@ def deploy_jupyter_notebook( :param hide_all_input: if True, will hide all input cells when rendering output. Previous default = False. :param hide_tagged_input: If True, will hide input code cells with the 'hide_input' tag when rendering output. Previous default = False. + :param image: the optional docker image to be specified for off-host execution. Default = None. :return: the ultimate URL where the deployed app may be accessed and the sequence of log lines. The log lines value will be None if a log callback was provided. """ @@ -670,7 +670,6 @@ def _finalize_deploy( (the default) the lines from the deployment log will be returned as a sequence. If a log callback is provided, then None will be returned for the log lines part of the return tuple. - :param image: an optional docker image for off-host execution. :return: the ultimate URL where the deployed app may be accessed and the sequence of log lines. The log lines value will be None if a log callback was provided. """ @@ -707,7 +706,6 @@ def deploy_python_api( extra_files: typing.List[str], excludes: typing.List[str], entry_point: str, - image: str, new: bool, app_id: int, title: str, @@ -715,6 +713,7 @@ def deploy_python_api( conda_mode: bool, force_generate: bool, log_callback: typing.Callable, + image: str = None, ) -> typing.Tuple[str, typing.Union[list, None]]: """ A function to deploy a Python WSGi API module to Connect. Depending on the files involved @@ -725,7 +724,6 @@ def deploy_python_api( :param extra_files: any extra files that should be included in the deploy. :param excludes: a sequence of glob patterns that will exclude matched files. :param entry_point: the module/executable object for the WSGi framework. - :param image: an optional docker image for off-host execution. Previous default = None. :param new: a flag to force this as a new deploy. Previous default = False. :param app_id: the ID of an existing application to deploy new files for. Previous default = None. :param title: an optional title for the deploy. If this is not provided, one will @@ -739,6 +737,7 @@ def deploy_python_api( (the default) the lines from the deployment log will be returned as a sequence. If a log callback is provided, then None will be returned for the log lines part of the return tuple. Previous default = None. + :param image: the optional docker image to be specified for off-host execution. Default = None. :return: the ultimate URL where the deployed app may be accessed and the sequence of log lines. The log lines value will be None if a log callback was provided. """ @@ -766,7 +765,6 @@ def deploy_python_fastapi( extra_files: typing.List[str], excludes: typing.List[str], entry_point: str, - image: str, new: bool, app_id: int, title: str, @@ -774,6 +772,7 @@ def deploy_python_fastapi( conda_mode: bool, force_generate: bool, log_callback: typing.Callable, + image: str = None, ) -> typing.Tuple[str, typing.Union[list, None]]: """ A function to deploy a Python ASGI API module to RStudio Connect. Depending on the files involved @@ -784,7 +783,6 @@ def deploy_python_fastapi( :param extra_files: any extra files that should be included in the deploy. :param excludes: a sequence of glob patterns that will exclude matched files. :param entry_point: the module/executable object for the WSGi framework. - :param image: an optional docker image for off-host execution. Previous default = None. :param new: a flag to force this as a new deploy. Previous default = False. :param app_id: the ID of an existing application to deploy new files for. Previous default = None. :param title: an optional title for the deploy. If this is not provided, one will @@ -798,6 +796,7 @@ def deploy_python_fastapi( (the default) the lines from the deployment log will be returned as a sequence. If a log callback is provided, then None will be returned for the log lines part of the return tuple. Previous default = None. + :param image: the optional docker image to be specified for off-host execution. Default = None. :return: the ultimate URL where the deployed app may be accessed and the sequence of log lines. The log lines value will be None if a log callback was provided. """ @@ -825,7 +824,6 @@ def deploy_dash_app( extra_files: typing.List[str], excludes: typing.List[str], entry_point: str, - image: str, new: bool, app_id: int, title: str, @@ -833,6 +831,7 @@ def deploy_dash_app( conda_mode: bool, force_generate: bool, log_callback: typing.Callable, + image: str = None, ) -> typing.Tuple[str, typing.Union[list, None]]: """ A function to deploy a Python Dash app module to Connect. Depending on the files involved @@ -843,7 +842,6 @@ def deploy_dash_app( :param extra_files: any extra files that should be included in the deploy. :param excludes: a sequence of glob patterns that will exclude matched files. :param entry_point: the module/executable object for the WSGi framework. - :param image: an optional docker image for off-host execution. Previous default = None. :param new: a flag to force this as a new deploy. Previous default = False. :param app_id: the ID of an existing application to deploy new files for. Previous default = None. :param title: an optional title for the deploy. If this is not provided, one will @@ -857,6 +855,7 @@ def deploy_dash_app( (the default) the lines from the deployment log will be returned as a sequence. If a log callback is provided, then None will be returned for the log lines part of the return tuple. Previous default = None. + :param image: the optional docker image to be specified for off-host execution. Default = None. :return: the ultimate URL where the deployed app may be accessed and the sequence of log lines. The log lines value will be None if a log callback was provided. """ @@ -884,7 +883,6 @@ def deploy_streamlit_app( extra_files: typing.List[str], excludes: typing.List[str], entry_point: str, - image: str, new: bool, app_id: int, title: str, @@ -892,6 +890,7 @@ def deploy_streamlit_app( conda_mode: bool, force_generate: bool, log_callback: typing.Callable, + image: str = None, ) -> typing.Tuple[str, typing.Union[list, None]]: """ A function to deploy a Python Streamlit app module to Connect. Depending on the files involved @@ -902,7 +901,6 @@ def deploy_streamlit_app( :param extra_files: any extra files that should be included in the deploy. :param excludes: a sequence of glob patterns that will exclude matched files. :param entry_point: the module/executable object for the WSGi framework. - :param image: an optional docker image for off-host execution. Previous default = None. :param new: a flag to force this as a new deploy. Previous default = False. :param app_id: the ID of an existing application to deploy new files for. Previous default = None. :param title: an optional title for the deploy. If this is not provided, one will @@ -916,6 +914,7 @@ def deploy_streamlit_app( (the default) the lines from the deployment log will be returned as a sequence. If a log callback is provided, then None will be returned for the log lines part of the return tuple. Previous default = None. + :param image: the optional docker image to be specified for off-host execution. Default = None. :return: the ultimate URL where the deployed app may be accessed and the sequence of log lines. The log lines value will be None if a log callback was provided. """ @@ -943,7 +942,6 @@ def deploy_bokeh_app( extra_files: typing.List[str], excludes: typing.List[str], entry_point: str, - image: str, new: bool, app_id: int, title: str, @@ -951,6 +949,7 @@ def deploy_bokeh_app( conda_mode: bool, force_generate: bool, log_callback: typing.Callable, + image: str = None, ) -> typing.Tuple[str, typing.Union[list, None]]: """ A function to deploy a Python Bokeh app module to Connect. Depending on the files involved @@ -961,7 +960,6 @@ def deploy_bokeh_app( :param extra_files: any extra files that should be included in the deploy. :param excludes: a sequence of glob patterns that will exclude matched files. :param entry_point: the module/executable object for the WSGi framework. - :param image: an optional docker image for off-host execution. Previous default = None. :param new: a flag to force this as a new deploy. Previous default = False. :param app_id: the ID of an existing application to deploy new files for. Previous default = None. :param title: an optional title for the deploy. If this is not provided, one will @@ -975,6 +973,7 @@ def deploy_bokeh_app( (the default) the lines from the deployment log will be returned as a sequence. If a log callback is provided, then None will be returned for the log lines part of the return tuple. Previous default = None. + :param image: the optional docker image to be specified for off-host execution. Default = None. :return: the ultimate URL where the deployed app may be accessed and the sequence of log lines. The log lines value will be None if a log callback was provided. """ @@ -1056,7 +1055,7 @@ def _deploy_by_python_framework( force_generate=force_generate, ) bundle = create_api_deployment_bundle( - directory, extra_files, excludes, entry_point, app_mode, environment, image, True + directory, extra_files, excludes, entry_point, app_mode, environment, True, image ) return _finalize_deploy( connect_server, @@ -1142,7 +1141,6 @@ def gather_basic_deployment_info_for_notebook( :param title: an optional title. If this isn't specified, a default title will be generated. :param static: a flag to note whether a static document should be deployed. - :param image: an optional docker image for off-host execution. :return: the app ID, name, title information and mode for the deployment. """ validate_file_is_notebook(file_name) @@ -1541,8 +1539,8 @@ def create_api_deployment_bundle( entry_point: str, app_mode: AppMode, environment: Environment, - image: str, extra_files_need_validating: bool, + image: str = None, ) -> typing.IO[bytes]: """ Create an in-memory bundle, ready to deploy. @@ -1553,11 +1551,11 @@ def create_api_deployment_bundle( :param entry_point: the module/executable object for the WSGi framework. :param app_mode: the mode of the app being deployed. :param environment: environmental information. - :param image: an optional docker image for off-host execution. Previous default = None. :param extra_files_need_validating: a flag indicating whether the list of extra files should be validated or not. Part of validating includes qualifying each with the specified directory. If you provide False here, make sure the names are properly qualified first. Previous default = True. + :param image: the optional docker image to be specified for off-host execution. Default = None. :return: the bundle. """ entry_point = validate_entry_point(entry_point, directory) @@ -1568,7 +1566,7 @@ def create_api_deployment_bundle( if app_mode is None: app_mode = AppModes.PYTHON_API - return make_api_bundle(directory, entry_point, app_mode, environment, image, extra_files, excludes) + return make_api_bundle(directory, entry_point, app_mode, environment, extra_files, excludes, image) def create_quarto_deployment_bundle( @@ -1578,8 +1576,8 @@ def create_quarto_deployment_bundle( app_mode: AppMode, inspect: typing.Dict[str, typing.Any], environment: Environment, - image: str, extra_files_need_validating: bool, + image: str = None, ) -> typing.IO[bytes]: """ Create an in-memory bundle, ready to deploy. @@ -1590,11 +1588,11 @@ def create_quarto_deployment_bundle( :param entry_point: the module/executable object for the WSGi framework. :param app_mode: the mode of the app being deployed. :param environment: environmental information. - :param image: an optional docker image for off-host execution. Previous default = None. :param extra_files_need_validating: a flag indicating whether the list of extra files should be validated or not. Part of validating includes qualifying each with the specified directory. If you provide False here, make sure the names are properly qualified first. Previous default = True. + :param image: the optional docker image to be specified for off-host execution. Default = None. :return: the bundle. """ if extra_files_need_validating: @@ -1603,7 +1601,7 @@ def create_quarto_deployment_bundle( if app_mode is None: app_mode = AppModes.STATIC_QUARTO - return make_quarto_source_bundle(directory, inspect, app_mode, image, environment, extra_files, excludes) + return make_quarto_source_bundle(directory, inspect, app_mode, environment, extra_files, excludes, image) def deploy_bundle( @@ -1725,7 +1723,7 @@ def write_notebook_manifest_json( if app_mode == AppModes.UNKNOWN: raise api.RSConnectException('Could not determine the app mode from "%s"; please specify one.' % extension) - manifest_data = make_source_manifest(app_mode, image, environment, file_name, None) + manifest_data = make_source_manifest(app_mode, environment, file_name, None, image) manifest_add_file(manifest_data, file_name, directory) manifest_add_buffer(manifest_data, environment.filename, environment.contents) @@ -1741,11 +1739,11 @@ def create_api_manifest_and_environment_file( directory: str, entry_point: str, environment: Environment, - image: str, app_mode: AppMode, extra_files: typing.List[str], excludes: typing.List[str], force: bool, + image: str = None, ) -> None: """ Creates and writes a manifest.json file for the given Python API entry point. If @@ -1756,16 +1754,16 @@ def create_api_manifest_and_environment_file( :param entry_point: the module/executable object for the WSGi framework. :param environment: the Python environment to start with. This should be what's returned by the inspect_environment() function. - :param image: an optional docker image for off-host execution. Previous default = None. :param app_mode: the application mode to assume. Previous default = AppModes.PYTHON_API. :param extra_files: any extra files that should be included in the manifest. Previous default = None. :param excludes: a sequence of glob patterns that will exclude matched files. Previous default = None. :param force: if True, forces the environment file to be written. even if it already exists. Previous default = True. + :param image: the optional docker image to be specified for off-host execution. Default = None. :return: """ if ( - not write_api_manifest_json(directory, entry_point, environment, image, app_mode, extra_files, excludes) + not write_api_manifest_json(directory, entry_point, environment, app_mode, extra_files, excludes, image) or force ): write_environment_file(environment, directory) @@ -1775,10 +1773,10 @@ def write_api_manifest_json( directory: str, entry_point: str, environment: Environment, - image: str, app_mode: AppMode, extra_files: typing.List[str], excludes: typing.List[str], + image: str = None, ) -> bool: """ Creates and writes a manifest.json file for the given entry point file. If @@ -1789,15 +1787,15 @@ def write_api_manifest_json( :param entry_point: the module/executable object for the WSGi framework. :param environment: the Python environment to start with. This should be what's returned by the inspect_environment() function. - :param image: an optional docker image for off-host execution. Previous default = None. :param app_mode: the application mode to assume. Previous default = AppModes.PYTHON_API. :param extra_files: any extra files that should be included in the manifest. Previous default = None. :param excludes: a sequence of glob patterns that will exclude matched files. Previous default = None. + :param image: the optional docker image to be specified for off-host execution. Default = None. :return: whether or not the environment file (requirements.txt, environment.yml, etc.) that goes along with the manifest exists. """ extra_files = validate_extra_files(directory, extra_files) - manifest, _ = make_api_manifest(directory, entry_point, app_mode, environment, image, extra_files, excludes) + manifest, _ = make_api_manifest(directory, entry_point, app_mode, environment, extra_files, excludes, image) manifest_path = join(directory, "manifest.json") write_manifest_json(manifest_path, manifest) diff --git a/rsconnect/bundle.py b/rsconnect/bundle.py index 50dc8cb0..240be171 100644 --- a/rsconnect/bundle.py +++ b/rsconnect/bundle.py @@ -44,10 +44,10 @@ # noinspection SpellCheckingInspection def make_source_manifest( app_mode: AppMode, - image: str, environment: Environment, entrypoint: str, quarto_inspection: typing.Dict[str, typing.Any], + image: str = None, ) -> typing.Dict[str, typing.Any]: manifest = { @@ -194,7 +194,7 @@ def write_manifest( Returns the list of filenames written. """ manifest_filename = "manifest.json" - manifest = make_source_manifest(AppModes.JUPYTER_NOTEBOOK, image, environment, nb_name, None) + manifest = make_source_manifest(AppModes.JUPYTER_NOTEBOOK, environment, nb_name, None, image) if hide_all_input: if "jupyter" not in manifest: manifest["jupyter"] = {} @@ -273,7 +273,7 @@ def make_notebook_source_bundle( base_dir = dirname(file) nb_name = basename(file) - manifest = make_source_manifest(AppModes.JUPYTER_NOTEBOOK, image, environment, nb_name, None) + manifest = make_source_manifest(AppModes.JUPYTER_NOTEBOOK, environment, nb_name, None, image) if hide_all_input: if "jupyter" not in manifest: manifest["jupyter"] = {} @@ -314,10 +314,10 @@ def make_quarto_source_bundle( directory: str, inspect: typing.Dict[str, typing.Any], app_mode: AppMode, - image: str, environment: Environment, extra_files: typing.List[str], excludes: typing.List[str], + image: str = None, ) -> typing.IO[bytes]: """ Create a bundle containing the specified Quarto content and (optional) @@ -326,7 +326,7 @@ def make_quarto_source_bundle( Returns a file-like object containing the bundle tarball. """ manifest, relevant_files = make_quarto_manifest( - directory, inspect, app_mode, image, environment, extra_files, excludes + directory, inspect, app_mode, environment, extra_files, excludes, image ) bundle_file = tempfile.TemporaryFile(prefix="rsc_bundle") @@ -346,7 +346,7 @@ def make_quarto_source_bundle( def make_html_manifest( filename: str, - image: str, + image: str = None, ) -> typing.Dict[str, typing.Any]: # noinspection SpellCheckingInspection manifest = { @@ -569,9 +569,9 @@ def make_api_manifest( entry_point: str, app_mode: AppMode, environment: Environment, - image: str, extra_files: typing.List[str], excludes: typing.List[str], + image: str = None, ) -> typing.Tuple[typing.Dict[str, typing.Any], typing.List[str]]: """ Makes a manifest for an API. @@ -580,16 +580,16 @@ def make_api_manifest( :param entry_point: the main entry point for the API. :param app_mode: the app mode to use. :param environment: the Python environment information. - :param image: an optional docker image for off-host execution. :param extra_files: a sequence of any extra files to include in the bundle. :param excludes: a sequence of glob patterns that will exclude matched files. + :param image: the optional docker image to be specified for off-host execution. Default = None. :return: the manifest and a list of the files involved. """ if is_environment_dir(directory): excludes = list(excludes or []) + ["bin/", "lib/"] relevant_files = _create_api_file_list(directory, environment.filename, extra_files, excludes) - manifest = make_source_manifest(app_mode, image, environment, entry_point, None) + manifest = make_source_manifest(app_mode, environment, entry_point, None, image) manifest_add_buffer(manifest, environment.filename, environment.contents) @@ -602,9 +602,9 @@ def make_api_manifest( def make_html_bundle_content( path: str, entrypoint: str, - image: str, extra_files: typing.List[str], excludes: typing.List[str], + image: str = None, ) -> typing.Tuple[typing.Dict[str, typing.Any], typing.List[str]]: """ Makes a manifest for static html deployment. @@ -613,6 +613,7 @@ def make_html_bundle_content( :param entry_point: the main entry point for the API. :param extra_files: a sequence of any extra files to include in the bundle. :param excludes: a sequence of glob patterns that will exclude matched files. + :param image: the optional docker image to be specified for off-host execution. Default = None. :return: the manifest and a list of the files involved. """ entrypoint = entrypoint or infer_entrypoint(path, "text/html") @@ -692,21 +693,21 @@ def infer_entrypoint(path, mimetype): def make_html_bundle( path: str, entry_point: str, - image: str, extra_files: typing.List[str], excludes: typing.List[str], + image: str = None, ) -> typing.IO[bytes]: """ Create an html bundle, given a path and a manifest. :param path: the file, or the directory containing the files to deploy. :param entry_point: the main entry point for the API. - :param image: an optional docker image for off-host execution. :param extra_files: a sequence of any extra files to include in the bundle. :param excludes: a sequence of glob patterns that will exclude matched files. + :param image: the optional docker image to be specified for off-host execution. Default = None. :return: a file-like object containing the bundle tarball. """ - manifest, relevant_files = make_html_bundle_content(path, entry_point, image, extra_files, excludes) + manifest, relevant_files = make_html_bundle_content(path, entry_point, extra_files, excludes, image) bundle_file = tempfile.TemporaryFile(prefix="rsc_bundle") with tarfile.open(mode="w:gz", fileobj=bundle_file) as bundle: @@ -726,9 +727,9 @@ def make_api_bundle( entry_point: str, app_mode: AppMode, environment: Environment, - image: str, extra_files: typing.List[str], excludes: typing.List[str], + image: str = None, ) -> typing.IO[bytes]: """ Create an API bundle, given a directory path and a manifest. @@ -737,13 +738,13 @@ def make_api_bundle( :param entry_point: the main entry point for the API. :param app_mode: the app mode to use. :param environment: the Python environment information. - :param image: an optional docker image for off-host execution. :param extra_files: a sequence of any extra files to include in the bundle. :param excludes: a sequence of glob patterns that will exclude matched files. + :param image: the optional docker image to be specified for off-host execution. Default = None. :return: a file-like object containing the bundle tarball. """ manifest, relevant_files = make_api_manifest( - directory, entry_point, app_mode, environment, image, extra_files, excludes + directory, entry_point, app_mode, environment, extra_files, excludes, image ) bundle_file = tempfile.TemporaryFile(prefix="rsc_bundle") @@ -809,10 +810,10 @@ def make_quarto_manifest( directory: str, quarto_inspection: typing.Dict[str, typing.Any], app_mode: AppMode, - image: str, environment: Environment, extra_files: typing.List[str], excludes: typing.List[str], + image: str = None, ) -> typing.Tuple[typing.Dict[str, typing.Any], typing.List[str]]: """ Makes a manifest for a Quarto project. @@ -820,10 +821,10 @@ def make_quarto_manifest( :param directory: The directory containing the Quarto project. :param quarto_inspection: The parsed JSON from a 'quarto inspect' against the project. :param app_mode: The application mode to assume. - :param image: an optional docker image for off-host execution. :param environment: The (optional) Python environment to use. :param extra_files: Any extra files to include in the manifest. :param excludes: A sequence of glob patterns to exclude when enumerating files to bundle. + :param image: the optional docker image to be specified for off-host execution. Default = None. :return: the manifest and a list of the files involved. """ if environment: @@ -846,10 +847,10 @@ def make_quarto_manifest( relevant_files = _create_quarto_file_list(directory, extra_files, excludes) manifest = make_source_manifest( app_mode, - image, environment, None, quarto_inspection, + image, ) for rel_path in relevant_files: diff --git a/rsconnect/main.py b/rsconnect/main.py index f409fdd7..4f9d489a 100644 --- a/rsconnect/main.py +++ b/rsconnect/main.py @@ -602,7 +602,6 @@ def _deploy_bundle( :param title_is_default: a flag noting whether the title carries a defaulted value. :param bundle: the bundle to deploy. :param env_vars: list of NAME=VALUE pairs to be set as the app environment - :param image: an optional docker image for off-host execution. """ with cli_feedback("Uploading bundle"): app = deploy_bundle(connect_server, app_id, name, title, title_is_default, bundle, env_vars) @@ -693,7 +692,7 @@ def _deploy_bundle( "--image", "-I", help="Target image to be used during content execution (only applicable if the RStudio Connect " - "server is configured to use off-host execution)", + "server is configured to use off-host execution)", ) @click.argument("file", type=click.Path(exists=True, dir_okay=False, file_okay=True)) @click.argument( @@ -908,7 +907,7 @@ def deploy_manifest( "--image", "-I", help="Target image to be used during content execution (only applicable if the RStudio Connect " - "server is configured to use off-host execution)", + "server is configured to use off-host execution)", ) @click.argument("directory", type=click.Path(exists=True, dir_okay=True, file_okay=False)) @click.argument( @@ -977,7 +976,7 @@ def deploy_quarto( with cli_feedback("Creating deployment bundle"): bundle = create_quarto_deployment_bundle( - directory, extra_files, exclude, app_mode, inspect, environment, image, False + directory, extra_files, exclude, app_mode, inspect, environment, False, image ) _deploy_bundle( @@ -1058,7 +1057,7 @@ def deploy_html( with cli_feedback("Creating deployment bundle"): try: - bundle = make_html_bundle(path, entrypoint, "", extra_files, excludes) + bundle = make_html_bundle(path, entrypoint, extra_files, excludes, None) except IOError as error: msg = "Unable to include the file %s in the bundle: %s" % ( error.filename, @@ -1283,7 +1282,7 @@ def _deploy_by_framework( with cli_feedback("Creating deployment bundle"): bundle = create_api_deployment_bundle( - directory, extra_files, exclude, entrypoint, app_mode, environment, image, False + directory, extra_files, exclude, entrypoint, app_mode, environment, False, image ) _deploy_bundle( @@ -1369,7 +1368,7 @@ def write_manifest(): "--image", "-I", help="Target image to be used during content execution (only applicable if the RStudio Connect " - "server is configured to use off-host execution)", + "server is configured to use off-host execution)", ) @click.argument("file", type=click.Path(exists=True, dir_okay=False, file_okay=True)) @click.argument( @@ -1472,7 +1471,7 @@ def write_manifest_notebook( "--image", "-I", help="Target image to be used during content execution (only applicable if the RStudio Connect " - "server is configured to use off-host execution)", + "server is configured to use off-host execution)", ) @click.argument("directory", type=click.Path(exists=True, dir_okay=True, file_okay=False)) @click.argument( @@ -1682,10 +1681,10 @@ def _write_framework_manifest( directory, entrypoint, environment, - image, app_mode, extra_files, exclude, + image, ) if environment_file_exists and not force_generate: diff --git a/tests/test_actions.py b/tests/test_actions.py index 667f8f5c..15099a92 100644 --- a/tests/test_actions.py +++ b/tests/test_actions.py @@ -218,7 +218,7 @@ def test_deploy_python_api_validates(self): directory = get_api_path("flask") server = RSConnectServer("https://www.bogus.com", "bogus") with self.assertRaises(RSConnectException): - deploy_python_api(server, directory, [], [], "bogus", None, False, None, None, None, False, False, None) + deploy_python_api(server, directory, [], [], "bogus", False, None, None, None, False, False, None, None) def test_deploy_dash_app_docs(self): self.assertTrue("Dash app" in deploy_dash_app.__doc__) @@ -250,7 +250,7 @@ def test_create_api_deployment_bundle_validates(self): with self.assertRaises(RSConnectException): create_api_deployment_bundle(directory, [], [], "bogus:bogus:bogus", None, None, None, None) with self.assertRaises(RSConnectException): - create_api_deployment_bundle(directory, ["bogus"], [], "app:app", MakeEnvironment(), None, None, True) + create_api_deployment_bundle(directory, ["bogus"], [], "app:app", MakeEnvironment(), None, True, None) def test_inspect_environment(self): environment = inspect_environment(sys.executable, get_dir("pip1")) diff --git a/tests/test_bundle.py b/tests/test_bundle.py index a4f47827..f7bfa3e6 100644 --- a/tests/test_bundle.py +++ b/tests/test_bundle.py @@ -291,7 +291,7 @@ def test_make_source_manifest(self): ) # include image parameter - manifest = make_source_manifest(AppModes.PYTHON_API, "rstudio/connect:bionic", None, None, None) + manifest = make_source_manifest(AppModes.PYTHON_API, None, None, None, "rstudio/connect:bionic") self.assertEqual( manifest, { @@ -305,7 +305,6 @@ def test_make_source_manifest(self): # include environment parameter manifest = make_source_manifest( AppModes.PYTHON_API, - None, Environment( conda=None, contents="", @@ -319,6 +318,7 @@ def test_make_source_manifest(self): ), None, None, + None, ) self.assertEqual( manifest, @@ -338,9 +338,9 @@ def test_make_source_manifest(self): manifest = make_source_manifest( AppModes.PYTHON_API, None, - None, "main.py", None, + None, ) # print(manifest) self.assertEqual( @@ -353,12 +353,12 @@ def test_make_source_manifest(self): AppModes.PYTHON_API, None, None, - None, { "quarto": {"version": "0.9.16"}, "engines": ["jupyter"], "config": {"project": {"title": "quarto-proj-py"}, "editor": "visual", "language": {}}, }, + None, ) # print(manifest) self.assertEqual( @@ -415,10 +415,10 @@ def test_make_quarto_manifest(self): "config": {"project": {"title": "quarto-proj-py"}, "editor": "visual", "language": {}}, }, AppModes.SHINY_QUARTO, - "rstudio/connect:bionic", None, None, None, + "rstudio/connect:bionic", ) self.assertEqual( manifest, @@ -446,7 +446,6 @@ def test_make_quarto_manifest(self): "config": {"project": {"title": "quarto-proj-py"}, "editor": "visual", "language": {}}, }, AppModes.SHINY_QUARTO, - None, Environment( conda=None, contents="", @@ -460,6 +459,7 @@ def test_make_quarto_manifest(self): ), None, None, + None, ) self.assertEqual( manifest, @@ -495,9 +495,9 @@ def test_make_quarto_manifest(self): }, AppModes.SHINY_QUARTO, None, - None, ["a", "b", "c"], None, + None, ) self.assertEqual( manifest, @@ -524,9 +524,9 @@ def test_make_quarto_manifest(self): }, AppModes.SHINY_QUARTO, None, - None, ["a", "b", "c"], ["requirements.txt"], + None, ) self.assertEqual( manifest, From 814b23adf0db1d32752eebf0518537ea5fa7a5a6 Mon Sep 17 00:00:00 2001 From: Bill Sager Date: Thu, 26 May 2022 13:43:09 -0700 Subject: [PATCH 09/11] image param optional in public layer --- rsconnect/actions.py | 12 ++++++------ rsconnect/main.py | 10 +++++----- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/rsconnect/actions.py b/rsconnect/actions.py index 65c707f7..39c4ea86 100644 --- a/rsconnect/actions.py +++ b/rsconnect/actions.py @@ -1029,7 +1029,7 @@ def _deploy_by_python_framework( :param excludes: a sequence of glob patterns that will exclude matched files. :param entry_point: the module/executable object for the WSGi framework. :param gatherer: the function to use to gather basic information. - :param image: an optional docker image for off-host execution. Previous default = None. + :param image: the docker image to be specified for off-host execution. Use None if not specified. :param new: a flag to force this as a new deploy. Previous default = False. :param app_id: the ID of an existing application to deploy new files for. Previous default = None. :param title: an optional title for the deploy. If this is not provided, one will @@ -1501,7 +1501,7 @@ def create_notebook_deployment_bundle( extra_files_need_validating: bool, hide_all_input: bool, hide_tagged_input: bool, - image: str, + image: str = None, ) -> typing.IO[bytes]: """ Create an in-memory bundle, ready to deploy. @@ -1511,7 +1511,6 @@ def create_notebook_deployment_bundle( :param app_mode: the mode of the app being deployed. :param python: information about the version of Python being used. :param environment: environmental information. - :param image: an optional docker image for off-host execution. Previous default = None. :param extra_files_need_validating: a flag indicating whether the list of extra files should be validated or not. Part of validating includes qualifying each with the parent directory of the notebook file. If you provide False here, make @@ -1519,6 +1518,7 @@ def create_notebook_deployment_bundle( :param hide_all_input: if True, will hide all input cells when rendering output. Previous default = False. :param hide_tagged_input: If True, will hide input code cells with the 'hide_input' tag when rendering output. Previous default = False. + :param image: the optional docker image to be specified for off-host execution. Default = None. :return: the bundle. """ @@ -1673,7 +1673,7 @@ def create_notebook_manifest_and_environment_file( force: bool, hide_all_input: bool, hide_tagged_input: bool, - image: str, + image: str = None, ) -> None: """ Creates and writes a manifest.json file for the given notebook entry point file. @@ -1711,7 +1711,7 @@ def write_notebook_manifest_json( extra_files: typing.List[str], hide_all_input: bool, hide_tagged_input: bool, - image: str, + image: str = None, ) -> bool: """ Creates and writes a manifest.json file for the given entry point file. If @@ -1728,7 +1728,7 @@ def write_notebook_manifest_json( :param hide_all_input: if True, will hide all input cells when rendering output. Previous default = False. :param hide_tagged_input: If True, will hide input code cells with the 'hide_input' tag when rendering output. Previous default = False. - :param image: an optional docker image for off-host execution. Previous default = None. + :param image: the optional docker image to be specified for off-host execution. Default = None. :return: whether or not the environment file (requirements.txt, environment.yml, etc.) that goes along with the manifest exists. """ diff --git a/rsconnect/main.py b/rsconnect/main.py index 4f9d489a..21263074 100644 --- a/rsconnect/main.py +++ b/rsconnect/main.py @@ -719,7 +719,7 @@ def deploy_notebook( hide_all_input, hide_tagged_input, env_vars, - image, + image: str = None, ): set_verbosity(verbose) @@ -758,7 +758,7 @@ def deploy_notebook( with cli_feedback("Creating deployment bundle"): bundle = create_notebook_deployment_bundle( - file, extra_files, app_mode, python, environment, image, False, hide_all_input, hide_tagged_input + file, extra_files, app_mode, python, environment, False, hide_all_input, hide_tagged_input, image ) _deploy_bundle( connect_server, @@ -1162,7 +1162,7 @@ def deploy_app( directory, extra_files, env_vars, - image, + image: str = None, ): _deploy_by_framework( name, @@ -1488,7 +1488,7 @@ def write_manifest_quarto( verbose, directory, extra_files, - image, + image: str = None, ): set_verbosity(verbose) with cli_feedback("Checking arguments"): @@ -1604,7 +1604,7 @@ def manifest_writer( verbose, directory, extra_files, - image, + image: str = None, ): _write_framework_manifest( overwrite, From 7f4330db240d99d87134fcca9b7acea4f5288482 Mon Sep 17 00:00:00 2001 From: Bill Sager Date: Thu, 26 May 2022 14:02:37 -0700 Subject: [PATCH 10/11] Changelog entry --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 47e4b237..5de886cb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - You can now deploy static content such as html and its associated assets with `rsconnect deploy html`. +- An optional `image` parameter has been added to the applicable functions to support + target content image. This parameter defaults to `None` if not provided. + ## [1.7.1] - 2022-02-15 ### Added From 1dc328207bcb6c1abaa94a5593e23aaf03d64a3a Mon Sep 17 00:00:00 2001 From: Bincheng Wu Date: Fri, 27 May 2022 11:38:55 -0400 Subject: [PATCH 11/11] remove extra code around check_output --- rsconnect/actions.py | 1 - rsconnect/bundle.py | 5 +---- tests/test_bundle.py | 6 +++++- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/rsconnect/actions.py b/rsconnect/actions.py index 39c4ea86..4ef45d79 100644 --- a/rsconnect/actions.py +++ b/rsconnect/actions.py @@ -1535,7 +1535,6 @@ def create_notebook_deployment_bundle( hide_all_input, hide_tagged_input, image=image, - check_output=None, ) except subprocess.CalledProcessError as exc: # Jupyter rendering failures are often due to diff --git a/rsconnect/bundle.py b/rsconnect/bundle.py index e2c1f4c2..d9977d7b 100644 --- a/rsconnect/bundle.py +++ b/rsconnect/bundle.py @@ -369,12 +369,9 @@ def make_notebook_html_bundle( hide_all_input: bool, hide_tagged_input: bool, image: str = None, - check_output: typing.Callable = subprocess.check_output, # used to default to subprocess.check_output + check_output: typing.Callable = subprocess.check_output, ) -> typing.IO[bytes]: # noinspection SpellCheckingInspection - if check_output is None: - check_output = subprocess.check_output - cmd = [ python, "-m", diff --git a/tests/test_bundle.py b/tests/test_bundle.py index d8a77518..6967db68 100644 --- a/tests/test_bundle.py +++ b/tests/test_bundle.py @@ -225,7 +225,11 @@ def do_test_html_bundle(self, directory): nb_path = join(directory, "dummy.ipynb") bundle = make_notebook_html_bundle( - nb_path, sys.executable, hide_all_input=False, hide_tagged_input=False, image=None, check_output=None + nb_path, + sys.executable, + hide_all_input=False, + hide_tagged_input=False, + image=None, ) tar = tarfile.open(mode="r:gz", fileobj=bundle)