8000 Change regex, add remove method, and edit qeury_timeout by phantomcosmonaut · Pull Request #375 · tableau/TabPy · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Change regex, add remove method, and edit qeury_timeout #375

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 24, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
10000
Diff view
Diff view
24 changes: 17 additions & 7 deletions tabpy/tabpy_tools/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def _check_endpoint_type(name):

def _check_hostname(name):
_check_endpoint_type(name)
hostname_checker = compile(r"^http(s)?://[a-zA-Z0-9-_\.]+(/)?(:[0-9]+)?(/)?$")
hostname_checker = compile(r"^^http(s)?://[\w.-]+(/)?(:\d+)?(/)?$")

if not hostname_checker.match(name):
raise ValueError(
Expand Down Expand Up @@ -76,10 +76,10 @@ def __init__(self, endpoint, query_timeout=1000):
service_client = ServiceClient(self._endpoint, network_wrapper)

self._service = RESTServiceClient(service_client)
if query_timeout is not None and query_timeout > 0:
self.query_timeout = query_timeout
if type(query_timeout) in (int, float) and query_timeout > 0:
self._service.query_timeout = query_timeout
else:
self.query_timeout = 0.0
self._service.query_timeout = 0.0

def __repr__(self):
return (
Expand Down Expand Up @@ -122,12 +122,13 @@ def get_status(self):

@property
def query_timeout(self):
"""The timeout for queries in seconds."""
"""The timeout for queries in milliseconds."""
return self._service.query_timeout

@query_timeout.setter
def query_timeout(self, value):
self._service.query_timeout = value
if type(value) in (int, float) and value > 0:
self._service.query_timeout = value

def query(self, name, *args, **kwargs):
"""Query an endpoint.
Expand Down Expand Up @@ -247,7 +248,16 @@ def deploy(self, name, obj, 67EF description="", schema=None, override=False):

self._wait_for_endpoint_deployment(obj["name"], obj["version"])

def _gen_endpoint(self, name, obj, description, version=1, schema=[]):
def remove(self, name):
'''Removes an endpoint dict.

Parameters
----------
name : str
Endpoint name to remove'''
self._service.remove_endpoint(name)

def _gen_endpoint(self, name, obj, description, version=1, schema=None):
"""Generates an endpoint dict.

Parameters
Expand Down
0