Skip to content

Commit d44f0b6

Browse files
authored
Merge pull request #431 from rstudio/remove-capability-check
remove capability check
2 parents b1f8b4e + 11617c4 commit d44f0b6

File tree

5 files changed

+0
-147
lines changed

5 files changed

+0
-147
lines changed

rsconnect/actions.py

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -272,19 +272,6 @@ def _to_sort_key(text):
272272
}
273273

274274

275-
def are_apis_supported_on_server(connect_details):
276-
"""
277-
Returns whether or not the Connect server has Python itself enabled and its license allows
278-
for API usage. This controls whether APIs may be deployed..
279-
280-
:param connect_details: details about a Connect server as returned by gather_server_details()
281-
:return: boolean True if the Connect server supports Python APIs or not or False if not.
282-
:error: The Posit Connect server does not allow for Python APIs.
283-
"""
284-
warn("This method has been moved and will be deprecated.", DeprecationWarning, stacklevel=2)
285-
return connect_details["python"]["api_enabled"]
286-
287-
288275
def is_conda_supported_on_server(connect_details):
289276
"""
290277
Returns whether or not conda is supported on a Connect server.
@@ -296,34 +283,6 @@ def is_conda_supported_on_server(connect_details):
296283
return connect_details.get("conda", {}).get("supported", False)
297284

298285

299-
def check_server_capabilities(connect_server, capability_functions, details_source=gather_server_details):
300-
"""
301-
Uses a sequence of functions that check for capabilities in a Connect server. The
302-
server settings data is retrieved by the gather_server_details() function.
303-
304-
Each function provided must accept one dictionary argument which will be the server
305-
settings data returned by the gather_server_details() function. That function must
306-
return a boolean value. It must also contain a docstring which itself must contain
307-
an ":error:" tag as the last thing in the docstring. If the function returns False,
308-
an exception is raised with the function's ":error:" text as its message.
309-
310-
:param connect_server: the information needed to interact with the Connect server.
311-
:param capability_functions: a sequence of functions that will be called.
312-
:param details_source: the source for obtaining server details, gather_server_details(),
313-
by default.
314-
"""
315-
details = details_source(connect_server)
316-
317-
for function in capability_functions:
318-
if not function(details):
319-
index = function.__doc__.find(":error:") if function.__doc__ else -1
320-
if index >= 0:
321-
message = function.__doc__[index + 7 :].strip()
322-
else:
323-
message = "The server does not satisfy the %s capability check." % function.__name__
324-
raise RSConnectException(message)
325-
326-
327286
def _make_deployment_name(remote_server: api.TargetableServer, title: str, force_unique: bool) -> str:
328287
"""
329288
Produce a name for a deployment based on its title. It is assumed that the
@@ -830,7 +789,6 @@ def deploy_app(
830789
(
831790
ce.validate_server()
832791
.validate_app_mode(app_mode=app_mode)
833-
.check_server_capabilities([are_apis_supported_on_server])
834792
.make_bundle(
835793
make_api_bundle,
836794
directory,

rsconnect/api.py

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,6 @@ def get_content(self, content_guid):
294294
def wait_for_task(
295295
self, task_id, log_callback, abort_func=lambda: False, timeout=get_timeout(), poll_wait=0.5, raise_on_error=True
296296
):
297-
298297
last_status = None
299298
ending = time.time() + timeout if timeout else 999999999999
300299

@@ -655,36 +654,6 @@ def make_bundle(self, func: Callable, *args, **kwargs):
655654

656655
return self
657656

658-
def check_server_capabilities(self, capability_functions):
659-
"""
660-
Uses a sequence of functions that check for capabilities in a Connect server. The
661-
server settings data is retrieved by the gather_server_details() function.
662-
663-
Each function provided must accept one dictionary argument which will be the server
664-
settings data returned by the gather_server_details() function. That function must
665-
return a boolean value. It must also contain a docstring which itself must contain
666-
an ":error:" tag as the last thing in the docstring. If the function returns False,
667-
an exception is raised with the function's ":error:" text as its message.
668-
669-
:param capability_functions: a sequence of functions that will be called.
670-
:param details_source: the source for obtaining server details, gather_server_details(),
671-
by default.
672-
"""
673-
if isinstance(self.remote_server, PositServer):
674-
return self
675-
676-
details = self.server_details
677-
678-
for function in capability_functions:
679-
if not function(details):
680-
index = function.__doc__.find(":error:") if function.__doc__ else -1
681-
if index >= 0:
682-
message = function.__doc__[index + 7 :].strip()
683-
else:
684-
message = "The server does not satisfy the %s capability check." % function.__name__
685-
raise RSConnectException(message)
686-
return self
687-
688657
def upload_rstudio_bundle(self, prepare_deploy_result, bundle_size: int, contents):
689658
upload_url = prepare_deploy_result.presigned_url
690659
parsed_upload_url = urlparse(upload_url)

rsconnect/bundle.py

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1431,27 +1431,6 @@ def fake_module_file_from_directory(directory: str):
14311431
return join(directory, app_name + ".py")
14321432

14331433

1434-
def is_python_enabled_on_server(connect_details):
1435-
"""
1436-
Returns whether or not the Connect server has Python itself enabled.
1437-
1438-
:error: The Posit Connect server does not have Python enabled.
1439-
"""
1440-
return any(connect_details.get("python", {}).get("versions", []))
1441-
1442-
1443-
def are_apis_supported_on_server(connect_details):
1444-
"""
1445-
Returns whether or not the Connect server has Python itself enabled and its license allows
1446-
for API usage. This controls whether APIs may be deployed..
1447-
1448-
:param connect_details: details about a Connect server as returned by gather_server_details()
1449-
:return: boolean True if the Connect server supports Python APIs or not or False if not.
1450-
:error: The Posit Connect server does not allow for Python APIs.
1451-
"""
1452-
return connect_details["python"]["api_enabled"]
1453-
1454-
14551434
def which_python(python: typing.Optional[str] = None):
14561435
"""Determines which Python executable to use.
14571436

rsconnect/main.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@
4040
from . import api, VERSION, validation
4141
from .api import RSConnectExecutor, RSConnectServer, RSConnectClient, filter_out_server_info
4242
from .bundle import (
43-
is_python_enabled_on_server,
44-
are_apis_supported_on_server,
4543
create_python_environment,
4644
default_title_from_manifest,
4745
is_environment_dir,
@@ -1312,7 +1310,6 @@ def deploy_app(
13121310
(
13131311
ce.validate_server()
13141312
.validate_app_mode(app_mode=app_mode)
1315-
.check_server_capabilities([is_python_enabled_on_server, are_apis_supported_on_server])
13161313
.make_bundle(
13171314
make_api_bundle,
13181315
directory,

tests/test_actions.py

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,12 @@
1010

1111
from rsconnect.actions import (
1212
_verify_server,
13-
are_apis_supported_on_server,
14-
check_server_capabilities,
1513
create_api_deployment_bundle,
1614
create_notebook_deployment_bundle,
1715
deploy_dash_app,
1816
deploy_python_api,
1917
deploy_streamlit_app,
2018
deploy_bokeh_app,
21-
is_conda_supported_on_server,
2219
)
2320
from rsconnect.api import RSConnectServer
2421
from rsconnect.environment import MakeEnvironment
@@ -36,39 +33,6 @@ def test_verify_server(self):
3633
with self.assertRaises(RSConnectException):
3734
_verify_server(RSConnectServer("fake-url", None))
3835

39-
def test_check_server_capabilities(self):
40-
no_api_support = {"python": {"api_enabled": False}}
41-
api_support = {"python": {"api_enabled": True}}
42-
43-
with self.assertRaises(RSConnectException) as context:
44-
check_server_capabilities(None, (are_apis_supported_on_server,), lambda x: no_api_support)
45-
self.assertEqual(
46-
str(context.exception),
47-
"The Posit Connect server does not allow for Python APIs.",
48-
)
49-
50-
check_server_capabilities(None, (are_apis_supported_on_server,), lambda x: api_support)
51-
52-
no_conda = api_support
53-
conda_not_supported = {"conda": {"supported": False}}
54-
conda_supported = {"conda": {"supported": True}}
55-
56-
with self.assertRaises(RSConnectException) as context:
57-
check_server_capabilities(None, (is_conda_supported_on_server,), lambda x: no_conda)
58-
self.assertEqual(
59-
str(context.exception),
60-
"Conda is not supported on the target server. " + "Try deploying without requesting Conda.",
61-
)
62-
63-
with self.assertRaises(RSConnectException) as context:
64-
check_server_capabilities(None, (is_conda_supported_on_server,), lambda x: conda_not_supported)
65-
self.assertEqual(
66-
str(context.exception),
67-
"Conda is not supported on the target server. " + "Try deploying without requesting Conda.",
68-
)
69-
70-
check_server_capabilities(None, (is_conda_supported_on_server,), lambda x: conda_supported)
71-
7236
# noinspection PyUnusedLocal
7337
def fake_cap(details):
7438
return False
@@ -78,20 +42,6 @@ def fake_cap_with_doc(details):
7842
"""A docstring."""
7943
return False
8044

81-
with self.assertRaises(RSConnectException) as context:
82-
check_server_capabilities(None, (fake_cap,), lambda x: None)
83-
self.assertEqual(
84-
str(context.exception),
85-
"The server does not satisfy the fake_cap capability check.",
86-
)
87-
88-
with self.assertRaises(RSConnectException) as context:
89-
check_server_capabilities(None, (fake_cap_with_doc,), lambda x: None)
90-
self.assertEqual(
91-
str(context.exception),
92-
"The server does not satisfy the fake_cap_with_doc capability check.",
93-
)
94-
9545
def test_deploy_python_api_validates(self):
9646
directory = get_api_path("flask")
9747
server = RSConnectServer("https://www.bogus.com", "bogus")

0 commit comments

Comments
 (0)