From 97b4ca5dc7e8714b974d7e26cc9a5b8072df11d2 Mon Sep 17 00:00:00 2001 From: Jake Ichikawa Date: Thu, 21 Nov 2024 08:27:04 -0800 Subject: [PATCH 01/25] Test commit. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 87bbeef5..244bed9d 100755 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# TabPy +# TabPy [![Tableau Supported](https://img.shields.io/badge/Support%20Level-Tableau%20Supported-53bd92.svg)](https://www.tableau.com/support-levels-it-and-developer-tools) [![GitHub](https://img.shields.io/badge/license-MIT-brightgreen.svg)](https://raw.githubusercontent.com/Tableau/TabPy/master/LICENSE) From 1a7c028592ff0411b4545a3b0f8a92a50cff14b1 Mon Sep 17 00:00:00 2001 From: Jake Ichikawa Date: Thu, 21 Nov 2024 08:35:26 -0800 Subject: [PATCH 02/25] Test integ. --- README.md | 2 +- tabpy/tabpy_tools/client.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 244bed9d..87bbeef5 100755 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# TabPy +# TabPy [![Tableau Supported](https://img.shields.io/badge/Support%20Level-Tableau%20Supported-53bd92.svg)](https://www.tableau.com/support-levels-it-and-developer-tools) [![GitHub](https://img.shields.io/badge/license-MIT-brightgreen.svg)](https://raw.githubusercontent.com/Tableau/TabPy/master/LICENSE) diff --git a/tabpy/tabpy_tools/client.py b/tabpy/tabpy_tools/client.py index 684fdc0e..41ddb0a6 100644 --- a/tabpy/tabpy_tools/client.py +++ b/tabpy/tabpy_tools/client.py @@ -419,6 +419,7 @@ def _wait_for_endpoint_deployment( logger.info( f"Waiting for endpoint {endpoint_name} to deploy to " f"version {version}" ) + time.sleep(interval) start = time.time() while True: ep_status = self.get_status() From 17dec729d6ea0a02794de37717797461b2c4e9ce Mon Sep 17 00:00:00 2001 From: Jake Ichikawa Date: Thu, 21 Nov 2024 08:52:34 -0800 Subject: [PATCH 03/25] Test deleting stage path. --- tabpy/tabpy_server/handlers/endpoint_handler.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tabpy/tabpy_server/handlers/endpoint_handler.py b/tabpy/tabpy_server/handlers/endpoint_handler.py index d7f45f43..64b964cf 100644 --- a/tabpy/tabpy_server/handlers/endpoint_handler.py +++ b/tabpy/tabpy_server/handlers/endpoint_handler.py @@ -115,11 +115,13 @@ def delete(self, name): # delete files if endpoint_info["type"] != "alias": - delete_path = get_query_object_path( + query_path = get_query_object_path( self.settings["state_file_path"], name, None ) + staging_path = query_path.replace("/query_objects/", "/staging/endpoints/") try: - yield self._delete_po_future(delete_path) + yield self._delete_po_future(query_path) + yield self._delete_po_future(staging_path) except Exception as e: self.error_out(400, f"Error while deleting: {e}") self.finish() From b74ecc493de5ad6c7768f39fa221743d7c6be28c Mon Sep 17 00:00:00 2001 From: Jake Ichikawa Date: Thu, 21 Nov 2024 09:00:54 -0800 Subject: [PATCH 04/25] Add docstring updates. --- tabpy/tabpy_tools/client.py | 3 +++ tabpy/tabpy_tools/rest_client.py | 2 ++ 2 files changed, 5 insertions(+) diff --git a/tabpy/tabpy_tools/client.py b/tabpy/tabpy_tools/client.py index 41ddb0a6..c6a6a1f4 100644 --- a/tabpy/tabpy_tools/client.py +++ b/tabpy/tabpy_tools/client.py @@ -1,4 +1,5 @@ import copy +import inspect from re import compile import time import requests @@ -379,6 +380,7 @@ def _gen_endpoint(self, name, obj, description, version=1, schema=None, is_publi description = obj.__doc__.strip() or "" if isinstance(obj.__doc__, str) else "" endpoint_object = CustomQueryObject(query=obj, description=description,) + docstring = inspect.getdoc(obj) or "-- no docstring found in query function --" return { "name": name, @@ -390,6 +392,7 @@ def _gen_endpoint(self, name, obj, description, version=1, schema=None, is_publi "methods": endpoint_object.get_methods(), "required_files": [], "required_packages": [], + "docstring": docstring, "schema": copy.copy(schema), "is_public": is_public, } diff --git a/tabpy/tabpy_tools/rest_client.py b/tabpy/tabpy_tools/rest_client.py index c3b7a526..5f1bb0a0 100644 --- a/tabpy/tabpy_tools/rest_client.py +++ b/tabpy/tabpy_tools/rest_client.py @@ -41,6 +41,7 @@ class Endpoint(RESTObject): version = RESTProperty(int) description = RESTProperty(str) dependencies = RESTProperty(list) + docstring = RESTProperty(str) methods = RESTProperty(list) creation_time = RESTProperty(datetime, from_epoch, to_epoch) last_modified_time = RESTProperty(datetime, from_epoch, to_epoch) @@ -64,6 +65,7 @@ def __eq__(self, other): and self.version == other.version and self.description == other.description and self.dependencies == other.dependencies + and self.docstring == other.docstring and self.methods == other.methods and self.evaluator == other.evaluator and self.schema_version == other.schema_version From 16e1f2579bc291a4bba55c47dc40d14f5395ed31 Mon Sep 17 00:00:00 2001 From: Jake Ichikawa Date: Thu, 21 Nov 2024 09:09:20 -0800 Subject: [PATCH 05/25] Test modified docstring. --- tabpy/tabpy_tools/client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tabpy/tabpy_tools/client.py b/tabpy/tabpy_tools/client.py index c6a6a1f4..6a3f67db 100644 --- a/tabpy/tabpy_tools/client.py +++ b/tabpy/tabpy_tools/client.py @@ -380,7 +380,7 @@ def _gen_endpoint(self, name, obj, description, version=1, schema=None, is_publi description = obj.__doc__.strip() or "" if isinstance(obj.__doc__, str) else "" endpoint_object = CustomQueryObject(query=obj, description=description,) - docstring = inspect.getdoc(obj) or "-- no docstring found in query function --" + docstring = "-- no docstring found in query function --" return { "name": name, From 3dbbd83a010185b2bcf2aef8bc25755bf384d234 Mon Sep 17 00:00:00 2001 From: Jake Ichikawa Date: Thu, 21 Nov 2024 09:15:05 -0800 Subject: [PATCH 06/25] Test docstring update. --- tabpy/tabpy_tools/client.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tabpy/tabpy_tools/client.py b/tabpy/tabpy_tools/client.py index 6a3f67db..bf355889 100644 --- a/tabpy/tabpy_tools/client.py +++ b/tabpy/tabpy_tools/client.py @@ -380,7 +380,6 @@ def _gen_endpoint(self, name, obj, description, version=1, schema=None, is_publi description = obj.__doc__.strip() or "" if isinstance(obj.__doc__, str) else "" endpoint_object = CustomQueryObject(query=obj, description=description,) - docstring = "-- no docstring found in query function --" return { "name": name, @@ -392,7 +391,7 @@ def _gen_endpoint(self, name, obj, description, version=1, schema=None, is_publi "methods": endpoint_object.get_methods(), "required_files": [], "required_packages": [], - "docstring": docstring, + "docstring": endpoint_object.get_doc_string(), "schema": copy.copy(schema), "is_public": is_public, } From 72be56666ef9654f7e89fb6cf7ee3f6cb74d1598 Mon Sep 17 00:00:00 2001 From: Jake Ichikawa Date: Thu, 21 Nov 2024 09:30:53 -0800 Subject: [PATCH 07/25] docstring test. --- tabpy/tabpy_tools/custom_query_object.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tabpy/tabpy_tools/custom_query_object.py b/tabpy/tabpy_tools/custom_query_object.py index 18a149b8..2e108b96 100644 --- a/tabpy/tabpy_tools/custom_query_object.py +++ b/tabpy/tabpy_tools/custom_query_object.py @@ -71,10 +71,11 @@ def query(self, *args, **kwargs): def get_doc_string(self): """Get doc string from customized query""" - if self.custom_query.__doc__ is not None: - return self.custom_query.__doc__ - else: - return "-- no docstring found in query function --" + return "-- no docstring found in query function --" + # if self.custom_query.__doc__ is not None: + # return self.custom_query.__doc__ + # else: + # return "-- no docstring found in query function --" def get_methods(self): return [self.get_query_method()] From a351438d7c1da15d12fb2b556da4a3b759a579bc Mon Sep 17 00:00:00 2001 From: Jake Ichikawa Date: Thu, 21 Nov 2024 09:36:19 -0800 Subject: [PATCH 08/25] return docstring escaped. --- tabpy/tabpy_tools/client.py | 1 - tabpy/tabpy_tools/custom_query_object.py | 11 ++++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tabpy/tabpy_tools/client.py b/tabpy/tabpy_tools/client.py index bf355889..f7b28e06 100644 --- a/tabpy/tabpy_tools/client.py +++ b/tabpy/tabpy_tools/client.py @@ -1,5 +1,4 @@ import copy -import inspect from re import compile import time import requests diff --git a/tabpy/tabpy_tools/custom_query_object.py b/tabpy/tabpy_tools/custom_query_object.py index 2e108b96..4b232c90 100644 --- a/tabpy/tabpy_tools/custom_query_object.py +++ b/tabpy/tabpy_tools/custom_query_object.py @@ -71,11 +71,12 @@ def query(self, *args, **kwargs): def get_doc_string(self): """Get doc string from customized query""" - return "-- no docstring found in query function --" - # if self.custom_query.__doc__ is not None: - # return self.custom_query.__doc__ - # else: - # return "-- no docstring found in query function --" + if self.custom_query.__doc__ is not None: + return str( + bytes(self.custom_query.__doc__, "utf-8").decode("unicode_escape") + ) + else: + return "-- no docstring found in query function --" def get_methods(self): return [self.get_query_method()] From ef066ac062fe2078d8374b9ad5467e5e30bed860 Mon Sep 17 00:00:00 2001 From: Jake Ichikawa Date: Thu, 21 Nov 2024 09:47:09 -0800 Subject: [PATCH 09/25] docstring str --- tabpy/tabpy_tools/custom_query_object.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/tabpy/tabpy_tools/custom_query_object.py b/tabpy/tabpy_tools/custom_query_object.py index 4b232c90..c5f31cbd 100644 --- a/tabpy/tabpy_tools/custom_query_object.py +++ b/tabpy/tabpy_tools/custom_query_object.py @@ -71,12 +71,7 @@ def query(self, *args, **kwargs): def get_doc_string(self): """Get doc string from customized query""" - if self.custom_query.__doc__ is not None: - return str( - bytes(self.custom_query.__doc__, "utf-8").decode("unicode_escape") - ) - else: - return "-- no docstring found in query function --" + return str(self.custom_query.__doc__ or "-- no docstring found in query function --") def get_methods(self): return [self.get_query_method()] From 669638804b253d06393c91faeb841f49968ca19a Mon Sep 17 00:00:00 2001 From: Jake Ichikawa Date: Thu, 21 Nov 2024 09:57:17 -0800 Subject: [PATCH 10/25] try except around docstring. --- tabpy/tabpy_tools/custom_query_object.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tabpy/tabpy_tools/custom_query_object.py b/tabpy/tabpy_tools/custom_query_object.py index c5f31cbd..90034581 100644 --- a/tabpy/tabpy_tools/custom_query_object.py +++ b/tabpy/tabpy_tools/custom_query_object.py @@ -71,7 +71,12 @@ def query(self, *args, **kwargs): def get_doc_string(self): """Get doc string from customized query""" - return str(self.custom_query.__doc__ or "-- no docstring found in query function --") + try: + return str( + self.custom_query.__doc__ or "-- no docstring found in query function --" + ) + except: + return "-- no docstring found in query function --" def get_methods(self): return [self.get_query_method()] From cef04d751f9fdd73654cdaece35c4969b1d577e0 Mon Sep 17 00:00:00 2001 From: Jake Ichikawa Date: Thu, 21 Nov 2024 10:03:05 -0800 Subject: [PATCH 11/25] return utf-8 --- tabpy/tabpy_tools/custom_query_object.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/tabpy/tabpy_tools/custom_query_object.py b/tabpy/tabpy_tools/custom_query_object.py index 90034581..3936a598 100644 --- a/tabpy/tabpy_tools/custom_query_object.py +++ b/tabpy/tabpy_tools/custom_query_object.py @@ -72,10 +72,13 @@ def query(self, *args, **kwargs): def get_doc_string(self): """Get doc string from customized query""" try: - return str( - self.custom_query.__doc__ or "-- no docstring found in query function --" - ) - except: + if self.custom_query.__doc__ is not None: + return str( + bytes(self.custom_query.__doc__, "utf-8").decode("unicode_escape") + ) + else: + return "-- no docstring found in query function --" + except Exception as e: return "-- no docstring found in query function --" def get_methods(self): From be38d880a3497c64335a44d470c5c9e823bdf3e6 Mon Sep 17 00:00:00 2001 From: Jake Ichikawa Date: Thu, 21 Nov 2024 10:10:23 -0800 Subject: [PATCH 12/25] win32 encoding. --- tabpy/tabpy_tools/custom_query_object.py | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/tabpy/tabpy_tools/custom_query_object.py b/tabpy/tabpy_tools/custom_query_object.py index 3936a598..9d649c48 100644 --- a/tabpy/tabpy_tools/custom_query_object.py +++ b/tabpy/tabpy_tools/custom_query_object.py @@ -71,15 +71,12 @@ def query(self, *args, **kwargs): def get_doc_string(self): """Get doc string from customized query""" - try: - if self.custom_query.__doc__ is not None: - return str( - bytes(self.custom_query.__doc__, "utf-8").decode("unicode_escape") - ) - else: - return "-- no docstring found in query function --" - except Exception as e: - return "-- no docstring found in query function --" + if self.custom_query.__doc__: + encoding = "utf-8" if sys.platform != "win32" else "cp1252" + return str( + bytes(self.custom_query.__doc__, encoding).decode("unicode_escape") + ) + return "-- no docstring found in query function --" def get_methods(self): return [self.get_query_method()] From dc668a25be4df8ff95a3b14c438df5a5557c4aef Mon Sep 17 00:00:00 2001 From: Jake Ichikawa Date: Thu, 21 Nov 2024 10:17:22 -0800 Subject: [PATCH 13/25] Fix for win32. --- tabpy/tabpy_tools/custom_query_object.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/tabpy/tabpy_tools/custom_query_object.py b/tabpy/tabpy_tools/custom_query_object.py index 9d649c48..077e3414 100644 --- a/tabpy/tabpy_tools/custom_query_object.py +++ b/tabpy/tabpy_tools/custom_query_object.py @@ -71,12 +71,10 @@ def query(self, *args, **kwargs): def get_doc_string(self): """Get doc string from customized query""" - if self.custom_query.__doc__: - encoding = "utf-8" if sys.platform != "win32" else "cp1252" - return str( - bytes(self.custom_query.__doc__, encoding).decode("unicode_escape") - ) - return "-- no docstring found in query function --" + if self.custom_query.__doc__ is not None and sys.platform != "win32": + return self.custom_query.__doc__ + else: + return "-- no docstring found in query function --" def get_methods(self): return [self.get_query_method()] From d54a68a82b8bc88fb17c5b239e956d9ffeeef0cd Mon Sep 17 00:00:00 2001 From: Jake Ichikawa Date: Thu, 21 Nov 2024 10:17:47 -0800 Subject: [PATCH 14/25] change condition order. --- tabpy/tabpy_tools/custom_query_object.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tabpy/tabpy_tools/custom_query_object.py b/tabpy/tabpy_tools/custom_query_object.py index 077e3414..cbc819e3 100644 --- a/tabpy/tabpy_tools/custom_query_object.py +++ b/tabpy/tabpy_tools/custom_query_object.py @@ -71,7 +71,7 @@ def query(self, *args, **kwargs): def get_doc_string(self): """Get doc string from customized query""" - if self.custom_query.__doc__ is not None and sys.platform != "win32": + if sys.platform != "win32" and self.custom_query.__doc__ is not None: return self.custom_query.__doc__ else: return "-- no docstring found in query function --" From 44f3dfa89a2d8f2da6703b9a5f5f390219c71a71 Mon Sep 17 00:00:00 2001 From: Jake Ichikawa Date: Thu, 21 Nov 2024 10:22:51 -0800 Subject: [PATCH 15/25] undo endpoint_handler change. --- tabpy/tabpy_server/handlers/endpoint_handler.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/tabpy/tabpy_server/handlers/endpoint_handler.py b/tabpy/tabpy_server/handlers/endpoint_handler.py index 64b964cf..d7f45f43 100644 --- a/tabpy/tabpy_server/handlers/endpoint_handler.py +++ b/tabpy/tabpy_server/handlers/endpoint_handler.py @@ -115,13 +115,11 @@ def delete(self, name): # delete files if endpoint_info["type"] != "alias": - query_path = get_query_object_path( + delete_path = get_query_object_path( self.settings["state_file_path"], name, None ) - staging_path = query_path.replace("/query_objects/", "/staging/endpoints/") try: - yield self._delete_po_future(query_path) - yield self._delete_po_future(staging_path) + yield self._delete_po_future(delete_path) except Exception as e: self.error_out(400, f"Error while deleting: {e}") self.finish() From ec05b7ecc47597d1415f6611c1d8a927ea05ad77 Mon Sep 17 00:00:00 2001 From: Jake Ichikawa Date: Thu, 21 Nov 2024 10:26:09 -0800 Subject: [PATCH 16/25] change docstring impl --- tabpy/tabpy_tools/client.py | 8 ++++++-- tabpy/tabpy_tools/custom_query_object.py | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/tabpy/tabpy_tools/client.py b/tabpy/tabpy_tools/client.py index f7b28e06..54834af9 100644 --- a/tabpy/tabpy_tools/client.py +++ b/tabpy/tabpy_tools/client.py @@ -1,4 +1,5 @@ import copy +import inspect from re import compile import time import requests @@ -379,6 +380,10 @@ def _gen_endpoint(self, name, obj, description, version=1, schema=None, is_publi description = obj.__doc__.strip() or "" if isinstance(obj.__doc__, str) else "" endpoint_object = CustomQueryObject(query=obj, description=description,) + + docstring = "-- no docstring found in query function --" + if sys.platform != "win32": + docstring = inspect.getdoc(obj) or "-- no docstring found in query function --" return { "name": name, @@ -390,7 +395,7 @@ def _gen_endpoint(self, name, obj, description, version=1, schema=None, is_publi "methods": endpoint_object.get_methods(), "required_files": [], "required_packages": [], - "docstring": endpoint_object.get_doc_string(), + "docstring": docstring, "schema": copy.copy(schema), "is_public": is_public, } @@ -420,7 +425,6 @@ def _wait_for_endpoint_deployment( logger.info( f"Waiting for endpoint {endpoint_name} to deploy to " f"version {version}" ) - time.sleep(interval) start = time.time() while True: ep_status = self.get_status() diff --git a/tabpy/tabpy_tools/custom_query_object.py b/tabpy/tabpy_tools/custom_query_object.py index cbc819e3..18a149b8 100644 --- a/tabpy/tabpy_tools/custom_query_object.py +++ b/tabpy/tabpy_tools/custom_query_object.py @@ -71,7 +71,7 @@ def query(self, *args, **kwargs): def get_doc_string(self): """Get doc string from customized query""" - if sys.platform != "win32" and self.custom_query.__doc__ is not None: + if self.custom_query.__doc__ is not None: return self.custom_query.__doc__ else: return "-- no docstring found in query function --" From a0ca62b682d7a9d20d701abd8171dba848d88973 Mon Sep 17 00:00:00 2001 From: Jake Ichikawa Date: Thu, 21 Nov 2024 10:39:01 -0800 Subject: [PATCH 17/25] test get_doc_string. --- tabpy/tabpy_tools/client.py | 6 +----- tabpy/tabpy_tools/custom_query_object.py | 14 ++++++++++---- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/tabpy/tabpy_tools/client.py b/tabpy/tabpy_tools/client.py index 54834af9..b459e559 100644 --- a/tabpy/tabpy_tools/client.py +++ b/tabpy/tabpy_tools/client.py @@ -380,10 +380,6 @@ def _gen_endpoint(self, name, obj, description, version=1, schema=None, is_publi description = obj.__doc__.strip() or "" if isinstance(obj.__doc__, str) else "" endpoint_object = CustomQueryObject(query=obj, description=description,) - - docstring = "-- no docstring found in query function --" - if sys.platform != "win32": - docstring = inspect.getdoc(obj) or "-- no docstring found in query function --" return { "name": name, @@ -395,7 +391,7 @@ def _gen_endpoint(self, name, obj, description, version=1, schema=None, is_publi "methods": endpoint_object.get_methods(), "required_files": [], "required_packages": [], - "docstring": docstring, + "docstring": endpoint_object.get_doc_string(), "schema": copy.copy(schema), "is_public": is_public, } diff --git a/tabpy/tabpy_tools/custom_query_object.py b/tabpy/tabpy_tools/custom_query_object.py index 18a149b8..7949dbc5 100644 --- a/tabpy/tabpy_tools/custom_query_object.py +++ b/tabpy/tabpy_tools/custom_query_object.py @@ -1,4 +1,7 @@ +import inspect import logging +import platform +import sys from .query_object import QueryObject as _QueryObject @@ -71,10 +74,13 @@ def query(self, *args, **kwargs): def get_doc_string(self): """Get doc string from customized query""" - if self.custom_query.__doc__ is not None: - return self.custom_query.__doc__ - else: - return "-- no docstring found in query function --" + default_docstring = "-- no docstring found in query function --" + return default_docstring + # Docstring parsing not working on Windows. + # if platform.system() == "Windows": + # return default_docstring + # else: + # return inspect.getdoc(self.custom_query) or default_docstring def get_methods(self): return [self.get_query_method()] From 4ed276819b88964d67036e25613e189b4120c747 Mon Sep 17 00:00:00 2001 From: Jake Ichikawa Date: Thu, 21 Nov 2024 10:44:31 -0800 Subject: [PATCH 18/25] test get_doc_string. --- tabpy/tabpy_tools/custom_query_object.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tabpy/tabpy_tools/custom_query_object.py b/tabpy/tabpy_tools/custom_query_object.py index 7949dbc5..ee6d9f7b 100644 --- a/tabpy/tabpy_tools/custom_query_object.py +++ b/tabpy/tabpy_tools/custom_query_object.py @@ -1,7 +1,6 @@ import inspect import logging import platform -import sys from .query_object import QueryObject as _QueryObject @@ -75,7 +74,8 @@ def query(self, *args, **kwargs): def get_doc_string(self): """Get doc string from customized query""" default_docstring = "-- no docstring found in query function --" - return default_docstring + obj = self.custom_query + return obj.__doc__.strip() or default_docstring if isinstance(obj.__doc__, str) else default_docstring # Docstring parsing not working on Windows. # if platform.system() == "Windows": # return default_docstring From d7d264fef4c622ab405b6c88182894ee30d7c976 Mon Sep 17 00:00:00 2001 From: Jake Ichikawa Date: Thu, 21 Nov 2024 10:51:39 -0800 Subject: [PATCH 19/25] fix doc string. --- tabpy/tabpy_tools/custom_query_object.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/tabpy/tabpy_tools/custom_query_object.py b/tabpy/tabpy_tools/custom_query_object.py index ee6d9f7b..363548e4 100644 --- a/tabpy/tabpy_tools/custom_query_object.py +++ b/tabpy/tabpy_tools/custom_query_object.py @@ -1,4 +1,3 @@ -import inspect import logging import platform from .query_object import QueryObject as _QueryObject @@ -74,13 +73,12 @@ def query(self, *args, **kwargs): def get_doc_string(self): """Get doc string from customized query""" default_docstring = "-- no docstring found in query function --" - obj = self.custom_query - return obj.__doc__.strip() or default_docstring if isinstance(obj.__doc__, str) else default_docstring # Docstring parsing not working on Windows. - # if platform.system() == "Windows": - # return default_docstring - # else: - # return inspect.getdoc(self.custom_query) or default_docstring + if platform.system() == "Windows": + return default_docstring + else: + obj = self.custom_query + return obj.__doc__.strip() or default_docstring if isinstance(obj.__doc__, str) else default_docstring def get_methods(self): return [self.get_query_method()] From 6cd77b2eb3a0497853d0f5684dca332dd799bd27 Mon Sep 17 00:00:00 2001 From: Jake Ichikawa Date: Thu, 21 Nov 2024 10:57:52 -0800 Subject: [PATCH 20/25] clean up get_doc_string. --- tabpy/tabpy_tools/custom_query_object.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tabpy/tabpy_tools/custom_query_object.py b/tabpy/tabpy_tools/custom_query_object.py index 363548e4..0991756e 100644 --- a/tabpy/tabpy_tools/custom_query_object.py +++ b/tabpy/tabpy_tools/custom_query_object.py @@ -73,12 +73,13 @@ def query(self, *args, **kwargs): def get_doc_string(self): """Get doc string from customized query""" default_docstring = "-- no docstring found in query function --" - # Docstring parsing not working on Windows. + + # Skip docstring parsing on Windows 32-bit systems if platform.system() == "Windows": return default_docstring - else: - obj = self.custom_query - return obj.__doc__.strip() or default_docstring if isinstance(obj.__doc__, str) else default_docstring + + docstring = getattr(self.custom_query, '__doc__', None) + return docstring.strip() if isinstance(docstring, str) and docstring else default_docstring def get_methods(self): return [self.get_query_method()] From 5231e4fd0f24898386eb2a8b04c99fea2361aa61 Mon Sep 17 00:00:00 2001 From: Jake Ichikawa Date: Thu, 21 Nov 2024 11:01:57 -0800 Subject: [PATCH 21/25] try skipping docstring on 32bit only. --- tabpy/tabpy_tools/custom_query_object.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tabpy/tabpy_tools/custom_query_object.py b/tabpy/tabpy_tools/custom_query_object.py index 0991756e..497471d2 100644 --- a/tabpy/tabpy_tools/custom_query_object.py +++ b/tabpy/tabpy_tools/custom_query_object.py @@ -75,7 +75,7 @@ def get_doc_string(self): default_docstring = "-- no docstring found in query function --" # Skip docstring parsing on Windows 32-bit systems - if platform.system() == "Windows": + if platform.system() == "Windows" and platform.architecture()[0] == "32bit": return default_docstring docstring = getattr(self.custom_query, '__doc__', None) From 0b2ed8e17c7261f87fb96ed823a2c75449c3e5d1 Mon Sep 17 00:00:00 2001 From: Jake Ichikawa Date: Thu, 21 Nov 2024 11:08:55 -0800 Subject: [PATCH 22/25] use sys instead of platform. --- tabpy/tabpy_tools/custom_query_object.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tabpy/tabpy_tools/custom_query_object.py b/tabpy/tabpy_tools/custom_query_object.py index 497471d2..db4f3aa8 100644 --- a/tabpy/tabpy_tools/custom_query_object.py +++ b/tabpy/tabpy_tools/custom_query_object.py @@ -1,5 +1,5 @@ import logging -import platform +import sys from .query_object import QueryObject as _QueryObject @@ -75,11 +75,11 @@ def get_doc_string(self): default_docstring = "-- no docstring found in query function --" # Skip docstring parsing on Windows 32-bit systems - if platform.system() == "Windows" and platform.architecture()[0] == "32bit": + if sys.platform == 'win32': return default_docstring - docstring = getattr(self.custom_query, '__doc__', None) - return docstring.strip() if isinstance(docstring, str) and docstring else default_docstring + ds = getattr(self.custom_query, '__doc__', None) + return ds if ds and isinstance(ds, str) else default_docstring def get_methods(self): return [self.get_query_method()] From 189fd5bb2d152cfd5db69c289cb07308102466d2 Mon Sep 17 00:00:00 2001 From: Jake Ichikawa Date: Thu, 21 Nov 2024 12:42:29 -0800 Subject: [PATCH 23/25] print error --- tabpy/tabpy_tools/custom_query_object.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/tabpy/tabpy_tools/custom_query_object.py b/tabpy/tabpy_tools/custom_query_object.py index db4f3aa8..25bcf755 100644 --- a/tabpy/tabpy_tools/custom_query_object.py +++ b/tabpy/tabpy_tools/custom_query_object.py @@ -74,13 +74,16 @@ def get_doc_string(self): """Get doc string from customized query""" default_docstring = "-- no docstring found in query function --" - # Skip docstring parsing on Windows 32-bit systems - if sys.platform == 'win32': + # TODO: fix docstring parsing on Windows systems + # if sys.platform == 'win32': + # return default_docstring + try: + ds = getattr(self.custom_query, '__doc__', None) + return ds if ds and isinstance(ds, str) else default_docstring + except Exception as e: + print(e) return default_docstring - ds = getattr(self.custom_query, '__doc__', None) - return ds if ds and isinstance(ds, str) else default_docstring - def get_methods(self): return [self.get_query_method()] From 464a5f052943fdef2efc3dac46bd2f958f1d009a Mon Sep 17 00:00:00 2001 From: Jake Ichikawa Date: Thu, 21 Nov 2024 12:49:06 -0800 Subject: [PATCH 24/25] print pytest logs. --- .github/workflows/push.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index 373ad8f3..57669a14 100755 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -29,5 +29,5 @@ jobs: - name: Test with pytest run: | - pytest tests + pytest -s tests/integration/test_deploy_and_evaluate_model.py From 2cc16e3f1005d1e49959adf2314dc4f27b890c34 Mon Sep 17 00:00:00 2001 From: Jake Ichikawa Date: Thu, 21 Nov 2024 12:57:39 -0800 Subject: [PATCH 25/25] try -s --- .github/workflows/push.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index 57669a14..dce1ec4e 100755 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -29,5 +29,5 @@ jobs: - name: Test with pytest run: | - pytest -s tests/integration/test_deploy_and_evaluate_model.py + pytest -s tests