Skip to content

Commit ff3092f

Browse files
Format client.py
1 parent ff526b2 commit ff3092f

File tree

1 file changed

+17
-13
lines changed

1 file changed

+17
-13
lines changed

tabpy/tabpy_tools/client.py

+17-13
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,9 @@ def _check_endpoint_name(name):
5050

5151

5252
class Client:
53-
def __init__(self, endpoint, query_timeout=1000, remote_server=False, localhost_endpoint=None):
53+
def __init__(
54+
self, endpoint, query_timeout=1000, remote_server=False, localhost_endpoint=None
55+
):
5456
"""
5557
Connects to a running server.
5658
@@ -64,13 +66,13 @@ def __init__(self, endpoint, query_timeout=1000, remote_server=False, localhost_
6466
6567
query_timeout : float, optional
6668
The timeout for query operations.
67-
69+
6870
remote_server : bool, optional
6971
Whether client is a remote TabPy server.
70-
72+
7173
localhost_endpoint : str, optional
72-
The localhost endpoint with potentially different protocol and
73-
port compared to the main endpoint parameter.
74+
The localhost endpoint with potentially different protocol and
75+
port compared to the main endpoint parameter.
7476
"""
7577
_check_hostname(endpoint)
7678

@@ -244,7 +246,7 @@ def deploy(self, name, obj, description="", schema=None, override=False, is_publ
244246
"""
245247
if self._remote_server:
246248
self._remote_deploy(
247-
name, obj,
249+
name, obj,
248250
description=description, schema=schema, override=override, is_public=is_public
249251
)
250252
return
@@ -467,7 +469,9 @@ def _wait_for_endpoint_deployment(
467469
logger.info(f"Sleeping {interval}...")
468470
time.sleep(interval)
469471

470-
def _remote_deploy(self, name, obj, description="", schema=None, override=False, is_public=False):
472+
def _remote_deploy(
473+
self, name, obj, description="", schema=None, override=False, is_public=False
474+
):
471475
"""
472476
Remotely deploy a Python function using the /evaluate endpoint. Takes the same inputs
473477
as deploy.
@@ -499,9 +503,9 @@ def _gen_remote_script(self):
499503
remote_script.append(
500504
f"client.set_credentials('{auth.username}', '{auth.password}')"
501505
) if (auth := self._service.service_client.network_wrapper.auth) else None
502-
506+
503507
return "\n".join(remote_script) + "\n"
504-
508+
505509
def _evaluate_remote_script(self, remote_script):
506510
"""
507511
Uses TabPy /evaluate endpoint to execute a remote TabPy client script.
@@ -523,10 +527,10 @@ def _evaluate_remote_script(self, remote_script):
523527
json=payload
524528
)
525529

526-
log_message = response.text.replace('null', 'success')
527-
if "Ad-hoc scripts have been disabled" in log_message:
528-
log_message += "\n[Connecting to this TabPy server with remote_server=True is not allowed.]"
529-
print(f"\n{response.status_code} - {log_message}\n")
530+
msg = response.text.replace('null', 'success')
531+
if "Ad-hoc scripts have been disabled" in msg:
532+
msg += "\n[Remote TabPy client not allowed.]"
533+
print(f"\n{response.status_code} - {msg}\n")
530534

531535
def set_credentials(self, username, password):
532536
"""

0 commit comments

Comments
 (0)