Skip to content

Commit 7b532ae

Browse files
author
Matthew Lynch
authored
Merge pull request #265 from rstudio/revert-261-mslynch-shinyapps-io-refactor
Revert "support for shinyapps.io"
2 parents cfb7ce7 + c5eea1b commit 7b532ae

22 files changed

+321
-1552
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
/rsconnect/version.py
1919
htmlcov
2020
/tests/testdata/**/rsconnect-python/
21-
test-home/
2221
/docs/docs/index.md
2322
/docs/docs/changelog.md
2423
/rsconnect-build

requirements.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ click>=7.0.0
33
coverage
44
flake8
55
funcsigs
6-
httpretty==1.1.4
76
importlib-metadata
87
ipykernel
98
ipython

rsconnect/actions.py

Lines changed: 14 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -218,15 +218,6 @@ def test_server(connect_server):
218218
raise RSConnectException("\n".join(failures))
219219

220220

221-
def test_shinyapps_server(server: api.ShinyappsServer):
222-
with api.ShinyappsClient(server) as client:
223-
try:
224-
result = client.get_current_user()
225-
server.handle_bad_response(result)
226-
except RSConnectException as exc:
227-
raise RSConnectException("Failed to verify with shinyapps.io ({}).".format(exc))
228-
229-
230221
def test_api_key(connect_server):
231222
"""
232223
Test that an API Key may be used to authenticate with the given RStudio Connect server.
@@ -322,7 +313,7 @@ def check_server_capabilities(connect_server, capability_functions, details_sour
322313
raise RSConnectException(message)
323314

324315

325-
def _make_deployment_name(remote_server: api.TargetableServer, title: str, force_unique: bool) -> str:
316+
def _make_deployment_name(connect_server, title, force_unique) -> str:
326317
"""
327318
Produce a name for a deployment based on its title. It is assumed that the
328319
title is already defaulted and validated as appropriate (meaning the title
@@ -333,7 +324,7 @@ def _make_deployment_name(remote_server: api.TargetableServer, title: str, force
333324
that we collapse repeating underscores and, if the name is too short, it is
334325
padded to the left with underscores.
335326
336-
:param remote_server: the information needed to interact with the Connect server.
327+
:param connect_server: the information needed to interact with the Connect server.
337328
:param title: the title to start with.
338329
:param force_unique: a flag noting whether the generated name must be forced to be
339330
unique.
@@ -347,7 +338,7 @@ def _make_deployment_name(remote_server: api.TargetableServer, title: str, force
347338

348339
# Now, make sure it's unique, if needed.
349340
if force_unique:
350-
name = api.find_unique_name(remote_server, name)
341+
name = api.find_unique_name(connect_server, name)
351342

352343
return name
353344

@@ -1456,7 +1447,7 @@ def _generate_gather_basic_deployment_info_for_python(app_mode: AppMode) -> typi
14561447
"""
14571448

14581449
def gatherer(
1459-
remote_server: api.TargetableServer,
1450+
connect_server: api.RSConnectServer,
14601451
app_store: AppStore,
14611452
directory: str,
14621453
entry_point: str,
@@ -1465,7 +1456,7 @@ def gatherer(
14651456
title: str,
14661457
) -> typing.Tuple[str, int, str, str, bool, AppMode]:
14671458
return _gather_basic_deployment_info_for_framework(
1468-
remote_server,
1459+
connect_server,
14691460
app_store,
14701461
directory,
14711462
entry_point,
@@ -1486,7 +1477,7 @@ def gatherer(
14861477

14871478

14881479
def _gather_basic_deployment_info_for_framework(
1489-
remote_server: api.TargetableServer,
1480+
connect_server: api.RSConnectServer,
14901481
app_store: AppStore,
14911482
directory: str,
14921483
entry_point: str,
@@ -1498,7 +1489,7 @@ def _gather_basic_deployment_info_for_framework(
14981489
"""
14991490
Helps to gather the necessary info for performing a deployment.
15001491
1501-
:param remote_server: the server information.
1492+
:param connect_server: the Connect server information.
15021493
:param app_store: the store for the specified directory.
15031494
:param directory: the primary file being deployed.
15041495
:param entry_point: the entry point for the API in '<module>:<object> format. if
@@ -1523,19 +1514,13 @@ def _gather_basic_deployment_info_for_framework(
15231514
if app_id is None:
15241515
# Possible redeployment - check for saved metadata.
15251516
# Use the saved app information unless overridden by the user.
1526-
app_id, existing_app_mode = app_store.resolve(remote_server.url, app_id, app_mode)
1517+
app_id, existing_app_mode = app_store.resolve(connect_server.url, app_id, app_mode)
15271518
logger.debug("Using app mode from app %s: %s" % (app_id, app_mode))
15281519
elif app_id is not None:
15291520
# Don't read app metadata if app-id is specified. Instead, we need
15301521
# to get this from Connect.
1531-
if isinstance(remote_server, api.RSConnectServer):
1532-
app = api.get_app_info(remote_server, app_id)
1533-
existing_app_mode = AppModes.get_by_ordinal(app.get("app_mode", 0), True)
1534-
elif isinstance(remote_server, api.ShinyappsServer):
1535-
app = api.get_shinyapp_info(remote_server, app_id)
1536-
existing_app_mode = AppModes.get_by_cloud_name(app.json_data["mode"])
1537-
else:
1538-
raise RSConnectException("Unable to infer Connect client.")
1522+
app = api.get_app_info(connect_server, app_id)
1523+
existing_app_mode = AppModes.get_by_ordinal(app.get("app_mode", 0), True)
15391524
if existing_app_mode and app_mode != existing_app_mode:
15401525
msg = (
15411526
"Deploying with mode '%s',\n"
@@ -1553,7 +1538,7 @@ def _gather_basic_deployment_info_for_framework(
15531538
return (
15541539
entry_point,
15551540
app_id,
1556-
_make_deployment_name(remote_server, title, app_id is None),
1541+
_make_deployment_name(connect_server, title, app_id is None),
15571542
title,
15581543
default_title,
15591544
app_mode,
@@ -1712,7 +1697,7 @@ def create_quarto_deployment_bundle(
17121697

17131698

17141699
def deploy_bundle(
1715-
remote_server: api.TargetableServer,
1700+
connect_server: api.RSConnectServer,
17161701
app_id: int,
17171702
name: str,
17181703
title: str,
@@ -1723,7 +1708,7 @@ def deploy_bundle(
17231708
"""
17241709
Deploys the specified bundle.
17251710
1726-
:param remote_server: the server information.
1711+
:param connect_server: the Connect server information.
17271712
:param app_id: the ID of the app to deploy, if this is a redeploy.
17281713
:param name: the name for the deploy.
17291714
:param title: the title for the deploy.
@@ -1733,17 +1718,7 @@ def deploy_bundle(
17331718
:return: application information about the deploy. This includes the ID of the
17341719
task that may be queried for deployment progress.
17351720
"""
1736-
ce = RSConnectExecutor(
1737-
server=remote_server,
1738-
app_id=app_id,
1739-
name=name,
1740-
title=title,
1741-
title_is_default=title_is_default,
1742-
bundle=bundle,
1743-
env_vars=env_vars,
1744-
)
1745-
ce.deploy_bundle()
1746-
return ce.state["deployed_info"]
1721+
return api.do_bundle_deploy(connect_server, app_id, name, title, title_is_default, bundle, env_vars)
17471722

17481723

17491724
def spool_deployment_log(connect_server, app, log_callback):

rsconnect/actions_content.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@
44
import json
55
import time
66
import traceback
7+
78
from concurrent.futures import ThreadPoolExecutor, as_completed
89
from datetime import datetime, timedelta
10+
911
import semver
1012

11-
from .api import RSConnectClient, emit_task_log
13+
from .api import RSConnect, emit_task_log
1214
from .log import logger
1315
from .models import BuildStatus, ContentGuidWithBundle
1416
from .metadata import ContentBuildStore
@@ -35,7 +37,7 @@ def build_add_content(connect_server, content_guids_with_bundle):
3537
+ "please wait for it to finish before adding new content."
3638
)
3739

38-
with RSConnectClient(connect_server, timeout=120) as client:
40+
with RSConnect(connect_server, timeout=120) as client:
3941
if len(content_guids_with_bundle) == 1:
4042
all_content = [client.content_get(content_guids_with_bundle[0].guid)]
4143
else:
@@ -226,7 +228,7 @@ def _monitor_build(connect_server, content_items):
226228

227229
def _build_content_item(connect_server, content, poll_wait):
228230
init_content_build_store(connect_server)
229-
with RSConnectClient(connect_server) as client:
231+
with RSConnect(connect_server) as client:
230232
# Pending futures will still try to execute when ThreadPoolExecutor.shutdown() is called
231233
# so just exit immediately if the current build has been aborted.
232234
# ThreadPoolExecutor.shutdown(cancel_futures=) isnt available until py3.9
@@ -290,7 +292,7 @@ def download_bundle(connect_server, guid_with_bundle):
290292
"""
291293
:param guid_with_bundle: models.ContentGuidWithBundle
292294
"""
293-
with RSConnectClient(connect_server, timeout=120) as client:
295+
with RSConnect(connect_server, timeout=120) as client:
294296
# bundle_id not provided so grab the latest
295297
if not guid_with_bundle.bundle_id:
296298
content = client.get_content(guid_with_bundle.guid)
@@ -309,7 +311,7 @@ def get_content(connect_server, guid):
309311
:param guid: a single guid as a string or list of guids.
310312
:return: a list of content items.
311313
"""
312-
with RSConnectClient(connect_server, timeout=120) as client:
314+
with RSConnect(connect_server, timeout=120) as client:
313315
if isinstance(guid, str):
314316
result = [client.get_content(guid)]
315317
else:
@@ -320,7 +322,7 @@ def get_content(connect_server, guid):
320322
def search_content(
321323
connect_server, published, unpublished, content_type, r_version, py_version, title_contains, order_by
322324
):
323-
with RSConnectClient(connect_server, timeout=120) as client:
325+
with RSConnect(connect_server, timeout=120) as client:
324326
result = client.search_content()
325327
result = _apply_content_filters(
326328
result, published, unpublished, content_type, r_version, py_version, title_contains

0 commit comments

Comments
 (0)