Skip to content
Merged
Show file tree
Hide file tree
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
Diff view
Diff view
8 changes: 4 additions & 4 deletions polyapi/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@
"""


def _wrap_code_in_try_except(code: str) -> str:
def _wrap_code_in_try_except(function_name: str, code: str) -> str:
""" this is necessary because client functions with imports will blow up ALL server functions,
even if they don't use them.
because the server function will try to load all client functions when loading the library
"""
prefix = """logger = logging.getLogger("poly")
try:
"""
suffix = """except ImportError as e:
logger.debug(e)"""
suffix = f"""except ImportError as e:
logger.warning("Failed to import client function '{function_name}', function unavailable: " + str(e))"""

lines = code.split("\n")
code = "\n ".join(lines)
Expand All @@ -39,6 +39,6 @@ def render_client_function(
return_type_def=return_type_def,
)

code = _wrap_code_in_try_except(code)
code = _wrap_code_in_try_except(function_name, code)

return code + "\n\n", func_type_defs
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ requires = ["setuptools>=61.2", "wheel"]

[project]
name = "polyapi-python"
version = "0.3.8.dev4"
version = "0.3.8.dev5"
description = "The Python Client for PolyAPI, the IPaaS by Developers for Developers"
authors = [{ name = "Dan Fellin", email = "dan@polyapi.io" }]
dependencies = [
Expand Down