Skip to content

Commit 2b71a6c

Browse files
committed
Merge branch 'deploy-shiny-without-add' into shinyapps
2 parents dde98d0 + 5a4ff5c commit 2b71a6c

File tree

4 files changed

+52
-42
lines changed

4 files changed

+52
-42
lines changed

rsconnect/actions.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -967,6 +967,7 @@ def deploy_python_shiny(
967967
log_callback,
968968
)
969969

970+
970971
def deploy_dash_app(
971972
connect_server: api.RSConnectServer,
972973
directory: str,
@@ -1540,6 +1541,7 @@ def gatherer(
15401541
gather_basic_deployment_info_for_bokeh = _generate_gather_basic_deployment_info_for_python(AppModes.BOKEH_APP)
15411542
gather_basic_deployment_info_for_shiny = _generate_gather_basic_deployment_info_for_python(AppModes.PYTHON_SHINY)
15421543

1544+
15431545
def _gather_basic_deployment_info_for_framework(
15441546
remote_server: api.TargetableServer,
15451547
app_store: AppStore,

rsconnect/main.py

Lines changed: 46 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,40 @@ def wrapper(*args, **kwargs):
133133
return wrapper
134134

135135

136+
def shinyapps_args(func):
137+
@click.option(
138+
"--account",
139+
"-A",
140+
envvar="SHINYAPPS_ACCOUNT",
141+
help="The shinyapps.io account name.",
142+
)
143+
@click.option(
144+
"--token",
145+
"-T",
146+
envvar="SHINYAPPS_TOKEN",
147+
help="The shinyapps.io token.",
148+
)
149+
@click.option(
150+
"--secret",
151+
"-S",
152+
envvar="SHINYAPPS_SECRET",
153+
help="The shinyapps.io token secret.",
154+
)
155+
@functools.wraps(func)
156+
def wrapper(*args, **kwargs):
157+
return func(*args, **kwargs)
158+
159+
return wrapper
160+
161+
162+
def _passthrough(func):
163+
@functools.wraps(func)
164+
def wrapper(*args, **kwargs):
165+
return func(*args, **kwargs)
166+
167+
return wrapper
168+
169+
136170
def validate_env_vars(ctx, param, all_values):
137171
vars = {}
138172

@@ -280,24 +314,7 @@ def _test_shinyappsio_creds(server: api.ShinyappsServer):
280314
type=click.File(),
281315
help="The path to trusted TLS CA certificates.",
282316
)
283-
@click.option(
284-
"--account",
285-
"-a",
286-
envvar="SHINYAPPS_ACCOUNT",
287-
help="The shinyapps.io account name.",
288-
)
289-
@click.option(
290-
"--token",
291-
"-T",
292-
envvar="SHINYAPPS_TOKEN",
293-
help="The shinyapps.io token.",
294-
)
295-
@click.option(
296-
"--secret",
297-
"-S",
298-
envvar="SHINYAPPS_SECRET",
299-
help="The shinyapps.io token secret.",
300-
)
317+
@shinyapps_args
301318
@click.option("--verbose", "-v", is_flag=True, help="Print detailed messages.")
302319
def add(name, server, api_key, insecure, cacert, account, token, secret, verbose):
303320

@@ -728,24 +745,7 @@ def deploy_notebook(
728745
)
729746
@server_args
730747
@content_args
731-
@click.option(
732-
"--account",
733-
"-a",
734-
envvar="SHINYAPPS_ACCOUNT",
735-
help="The shinyapps.io account name.",
736-
)
737-
@click.option(
738-
"--token",
739-
"-T",
740-
envvar="SHINYAPPS_TOKEN",
741-
help="The shinyapps.io token.",
742-
)
743-
@click.option(
744-
"--secret",
745-
"-S",
746-
envvar="SHINYAPPS_SECRET",
747-
help="The shinyapps.io token secret.",
748-
)
748+
@shinyapps_args
749749
@click.argument("file", type=click.Path(exists=True, dir_okay=True, file_okay=True))
750750
@cli_exception_handler
751751
def deploy_manifest(
@@ -984,7 +984,9 @@ def deploy_html(
984984
)
985985

986986

987-
def generate_deploy_python(app_mode, alias, min_version):
987+
def generate_deploy_python(app_mode, alias, min_version, supported_by_shinyapps=False):
988+
shinyapps = shinyapps_args if supported_by_shinyapps else _passthrough
989+
988990
# noinspection SpellCheckingInspection
989991
@deploy.command(
990992
name=alias,
@@ -998,6 +1000,7 @@ def generate_deploy_python(app_mode, alias, min_version):
9981000
)
9991001
@server_args
10001002
@content_args
1003+
@shinyapps
10011004
@click.option(
10021005
"--entrypoint",
10031006
"-e",
@@ -1056,6 +1059,9 @@ def deploy_app(
10561059
api_key: str,
10571060
insecure: bool,
10581061
cacert: typing.IO,
1062+
account: str,
1063+
token: str,
1064+
secret: str,
10591065
entrypoint,
10601066
exclude,
10611067
new: bool,
@@ -1110,7 +1116,9 @@ def deploy_app(
11101116
deploy_dash_app = generate_deploy_python(app_mode=AppModes.DASH_APP, alias="dash", min_version="1.8.2")
11111117
deploy_streamlit_app = generate_deploy_python(app_mode=AppModes.STREAMLIT_APP, alias="streamlit", min_version="1.8.4")
11121118
deploy_bokeh_app = generate_deploy_python(app_mode=AppModes.BOKEH_APP, alias="bokeh", min_version="1.8.4")
1113-
deploy_shiny = generate_deploy_python(app_mode=AppModes.PYTHON_SHINY, alias="shiny", min_version="2022.07.0")
1119+
deploy_shiny = generate_deploy_python(
1120+
app_mode=AppModes.PYTHON_SHINY, alias="shiny", min_version="2022.07.0", supported_by_shinyapps=True
1121+
)
11141122

11151123

11161124
@deploy.command(

rsconnect/validation.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def validate_connection_options(url, api_key, insecure, cacert, account_name, to
1313
options.
1414
"""
1515
connect_options = {"-k/--api-key": api_key, "-i/--insecure": insecure, "-c/--cacert": cacert}
16-
shinyapps_options = {"-T/--token": token, "-S/--secret": secret, "-a/--account": account_name}
16+
shinyapps_options = {"-T/--token": token, "-S/--secret": secret, "-A/--account": account_name}
1717
options_mutually_exclusive_with_name = {"-s/--server": url, **connect_options, **shinyapps_options}
1818
present_options_mutually_exclusive_with_name = _get_present_options(options_mutually_exclusive_with_name)
1919

@@ -25,7 +25,7 @@ def validate_connection_options(url, api_key, insecure, cacert, account_name, to
2525
)
2626
if not name and not url and not shinyapps_options:
2727
raise RSConnectException(
28-
"You must specify one of -n/--name OR -s/--server OR -a/--account, -T/--token, -S/--secret."
28+
"You must specify one of -n/--name OR -s/--server OR -A/--account, -T/--token, -S/--secret."
2929
)
3030

3131
present_connect_options = _get_present_options(connect_options)
@@ -40,4 +40,4 @@ def validate_connection_options(url, api_key, insecure, cacert, account_name, to
4040

4141
if present_shinyapps_options:
4242
if len(present_shinyapps_options) != 3:
43-
raise RSConnectException("-a/--account, -T/--token, and -S/--secret must all be provided for shinyapps.io.")
43+
raise RSConnectException("-A/--account, -T/--token, and -S/--secret must all be provided for shinyapps.io.")

tests/test_main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ def test_add_shinyapps_missing_options(self):
333333
self.assertEqual(result.exit_code, 1, result.output)
334334
self.assertEqual(
335335
str(result.exception),
336-
"-a/--account, -T/--token, and -S/--secret must all be provided for shinyapps.io.",
336+
"-A/--account, -T/--token, and -S/--secret must all be provided for shinyapps.io.",
337337
)
338338
finally:
339339
if original_api_key_value:

0 commit comments

Comments
 (0)