@@ -50,7 +50,9 @@ def _check_endpoint_name(name):
50
50
51
51
52
52
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
+ ):
54
56
"""
55
57
Connects to a running server.
56
58
@@ -64,13 +66,13 @@ def __init__(self, endpoint, query_timeout=1000, remote_server=False, localhost_
64
66
65
67
query_timeout : float, optional
66
68
The timeout for query operations.
67
-
69
+
68
70
remote_server : bool, optional
69
71
Whether client is a remote TabPy server.
70
-
72
+
71
73
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.
74
76
"""
75
77
_check_hostname (endpoint )
76
78
@@ -244,7 +246,7 @@ def deploy(self, name, obj, description="", schema=None, override=False, is_publ
244
246
"""
245
247
if self ._remote_server :
246
248
self ._remote_deploy (
247
- name , obj ,
249
+ name , obj ,
248
250
description = description , schema = schema , override = override , is_public = is_public
249
251
)
250
252
return
@@ -467,7 +469,9 @@ def _wait_for_endpoint_deployment(
467
469
logger .info (f"Sleeping { interval } ..." )
468
470
time .sleep (interval )
469
471
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
+ ):
471
475
"""
472
476
Remotely deploy a Python function using the /evaluate endpoint. Takes the same inputs
473
477
as deploy.
@@ -499,9 +503,9 @@ def _gen_remote_script(self):
499
503
remote_script .append (
500
504
f"client.set_credentials('{ auth .username } ', '{ auth .password } ')"
501
505
) if (auth := self ._service .service_client .network_wrapper .auth ) else None
502
-
506
+
503
507
return "\n " .join (remote_script ) + "\n "
504
-
508
+
505
509
def _evaluate_remote_script (self , remote_script ):
506
510
"""
507
511
Uses TabPy /evaluate endpoint to execute a remote TabPy client script.
@@ -523,10 +527,10 @@ def _evaluate_remote_script(self, remote_script):
523
527
json = payload
524
528
)
525
529
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 " )
530
534
531
535
def set_credentials (self , username , password ):
532
536
"""
0 commit comments