polyapi-python 0.2.4.dev12__py3-none-any.whl → 0.2.4.dev13__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
polyapi/client.py CHANGED
@@ -10,6 +10,22 @@ from typing import List, Dict, Any, TypedDict
10
10
  """
11
11
 
12
12
 
13
+ def _wrap_code_in_try_except(code: str) -> str:
14
+ """ this is necessary because client functions with imports will blow up ALL server functions,
15
+ even if they don't use them.
16
+ because the server function will try to load all client functions when loading the library
17
+ """
18
+ prefix = """logger = logging.getLogger("poly")
19
+ try:
20
+ """
21
+ suffix = """except ImportError as e:
22
+ logger.debug(e)"""
23
+
24
+ lines = code.split("\n")
25
+ code = "\n ".join(lines)
26
+ return "".join([prefix, code, "\n", suffix])
27
+
28
+
13
29
  def render_client_function(
14
30
  function_name: str,
15
31
  code: str,
@@ -22,4 +38,7 @@ def render_client_function(
22
38
  args_def=args_def,
23
39
  return_type_def=return_type_def,
24
40
  )
41
+
42
+ code = _wrap_code_in_try_except(code)
43
+
25
44
  return code + "\n\n", func_type_defs
polyapi/utils.py CHANGED
@@ -10,7 +10,7 @@ from polyapi.schema import generate_schema_types, clean_title, map_primitive_typ
10
10
 
11
11
  # this string should be in every __init__ file.
12
12
  # it contains all the imports needed for the function or variable code to run
13
- CODE_IMPORTS = "from typing import List, Dict, Any, TypedDict, Optional\nimport requests\nimport socketio # type: ignore\nfrom polyapi.config import get_api_key_and_url\nfrom polyapi.execute import execute, execute_post, variable_get, variable_update\n\n"
13
+ CODE_IMPORTS = "from typing import List, Dict, Any, TypedDict, Optional\nimport logging\nimport requests\nimport socketio # type: ignore\nfrom polyapi.config import get_api_key_and_url\nfrom polyapi.execute import execute, execute_post, variable_get, variable_update\n\n"
14
14
 
15
15
 
16
16
  def init_the_init(full_path: str) -> None:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: polyapi-python
3
- Version: 0.2.4.dev12
3
+ Version: 0.2.4.dev13
4
4
  Summary: The Python Client for PolyAPI, the IPaaS by Developers for Developers
5
5
  Author-email: Dan Fellin <dan@polyapi.io>
6
6
  License: MIT License
@@ -3,7 +3,7 @@ polyapi/__main__.py,sha256=V4zhAh_YGxno5f_KSrlkELxcuDh9bR3WSd0n-2r-qQQ,93
3
3
  polyapi/api.py,sha256=Pq_OT8egmtlzMjovN5GGZXWnF5oWMkrgR0rmrzJ6ifM,1861
4
4
  polyapi/auth.py,sha256=p2KSLt6q52t9gnqPmgXTOQ2_lmdFilZkIoGmQrRTPLQ,5330
5
5
  polyapi/cli.py,sha256=xlKH4cSmSo7eXbyXCLWyL4rXM1QFsltC_MxoxMPgt6I,2187
6
- polyapi/client.py,sha256=8k50Vwg9HnmHHTyfKH1vfMJqF0jnnVMsWuWI9AfASkM,761
6
+ polyapi/client.py,sha256=w15XOABkwdL4V4r2iWY_nypzLjvoKVuux8jUKbA16pQ,1329
7
7
  polyapi/config.py,sha256=S8TU10upy5OW1_vX-CqQTJD-ZOB6329aMjiUCmukfUI,2292
8
8
  polyapi/constants.py,sha256=NGjso6K5rGnE8TGdrXmdEfvvr-HI3DTVGwOYiWO68LM,511
9
9
  polyapi/error_handler.py,sha256=I_e0iz6VM23FLVQWJljxs2NGcl_OODbi43OcbnqBlp8,2398
@@ -15,11 +15,11 @@ polyapi/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
15
15
  polyapi/schema.py,sha256=1a7nIO867Xy3bagmPUNdYMxtS5OoCAv8oKIbYgj55dk,2957
16
16
  polyapi/server.py,sha256=iXUR1Kd5TnWK-V5qHhvFvQuHx-3IcTv8WChXVY5Mbog,1882
17
17
  polyapi/typedefs.py,sha256=a5WfHaAvjeql3y1iA3_SkpUztTbKvS5bPqkVxkCvr9E,1459
18
- polyapi/utils.py,sha256=86OSrkXlaB0HZppkItT9Xp3m2LBfIT4nPIhyBkIJ0OU,6164
18
+ polyapi/utils.py,sha256=9dFboLurZwBBtFZxXBDNri4QvSJAyZhkNUWK5LZh6ME,6180
19
19
  polyapi/variables.py,sha256=d36-trnfTL_8m2NkorMiImb4O3UrJbiFV38CHxV5i0A,4200
20
20
  polyapi/webhook.py,sha256=KidW6J1R4pWsgJ9duPiG-kzO8S28zfVyPhSn8ypD30Y,4325
21
- polyapi_python-0.2.4.dev12.dist-info/LICENSE,sha256=Hi0kDr56Dsy0uYIwNt4r9G7tI8x8miXRTlyvbeplCP8,1068
22
- polyapi_python-0.2.4.dev12.dist-info/METADATA,sha256=qwLPcEy6wky4Oc_ZNQza_OE6XhcNPWtMnZGFKpm6bCc,4868
23
- polyapi_python-0.2.4.dev12.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
24
- polyapi_python-0.2.4.dev12.dist-info/top_level.txt,sha256=CEFllOnzowci_50RYJac-M54KD2IdAptFsayVVF_f04,8
25
- polyapi_python-0.2.4.dev12.dist-info/RECORD,,
21
+ polyapi_python-0.2.4.dev13.dist-info/LICENSE,sha256=Hi0kDr56Dsy0uYIwNt4r9G7tI8x8miXRTlyvbeplCP8,1068
22
+ polyapi_python-0.2.4.dev13.dist-info/METADATA,sha256=_1h4w9445uvZ3l6IOAXOUsblQc2QjfmaIoGy_uSFdvQ,4868
23
+ polyapi_python-0.2.4.dev13.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
24
+ polyapi_python-0.2.4.dev13.dist-info/top_level.txt,sha256=CEFllOnzowci_50RYJac-M54KD2IdAptFsayVVF_f04,8
25
+ polyapi_python-0.2.4.dev13.dist-info/RECORD,,