Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
121 commits
Select commit Hold shift + click to select a range
2a4b538
# Feature (2970): Update python client to support setup command (#22)
sudiptatj Oct 31, 2024
8723978
improve polyapi-python setup (#24)
eupharis Nov 4, 2024
7ece4d0
# Feature (3007): Update python -m polyapi function add --logs option…
sudiptatj Nov 4, 2024
e292e4e
Project Glide + Refactor main command line args parsing (#26)
aarongoin Nov 14, 2024
cd89d8a
fix for poly cache directory path construction
aarongoin Nov 18, 2024
a8c2f52
one more adjustment to the deployables cache directory so there can't…
aarongoin Nov 18, 2024
4a0277a
this better?
aarongoin Nov 18, 2024
571e85a
verbose logging on upload code to see what's failing in CI/CD
aarongoin Nov 18, 2024
dbbbe61
bumpity
aarongoin Nov 18, 2024
c03268e
whoops
aarongoin Nov 18, 2024
64c2e37
so close
aarongoin Nov 18, 2024
2f71748
better?
aarongoin Nov 18, 2024
57a2d40
okay this should be the fix
aarongoin Nov 18, 2024
0e78bd3
is it this?
aarongoin Nov 18, 2024
30b2a28
maybe
aarongoin Nov 18, 2024
156d3df
oh for the love of pete
aarongoin Nov 18, 2024
20d8982
whatever. might be a pypi issue
aarongoin Nov 19, 2024
37b421b
removing verbose logging
aarongoin Nov 19, 2024
4cc8a16
fixing bugs in sync command to use correct api urls
aarongoin Nov 19, 2024
aa0be64
update logging
aarongoin Nov 19, 2024
db8aec6
lint
aarongoin Nov 19, 2024
32a65d1
improved auth
aarongoin Nov 19, 2024
14cf1ce
last fix for function sync
aarongoin Nov 19, 2024
9d4824a
fix bug when comment arguments don't align with the function
aarongoin Nov 19, 2024
ffe19f0
try forcing the poly directory to exist
aarongoin Nov 20, 2024
0d32c4a
test logging
aarongoin Nov 20, 2024
8bbb2c7
remove debug logging
aarongoin Nov 20, 2024
2808c97
fixing project glide deployable types and bumping the version
aarongoin Nov 22, 2024
123f0b7
fixing missing arguments in python client function upload
aarongoin Nov 22, 2024
7dc7afe
fixing return type for trained functions
aarongoin Nov 22, 2024
e117f1e
fix bug preventing use of poly sync command locally
aarongoin Nov 22, 2024
d4a656f
next version of client!
eupharis Nov 26, 2024
7441019
EN #3183 allow null logs flag for python client (#28)
eneumann Dec 5, 2024
57e7369
let the typing_extensions versions increase to support latest openai …
eupharis Dec 6, 2024
03fd34c
update dependency in one more place
eupharis Dec 6, 2024
28a1c39
Some bug fixes for python client (#29)
aarongoin Dec 14, 2024
027ceb5
Merge branch 'main' into develop
eupharis Dec 23, 2024
4ff9ba9
0.3.2
eupharis Dec 23, 2024
e895ae9
add poly schemas support (#31)
eupharis Mar 24, 2025
d189377
update to v4
eupharis Mar 24, 2025
a140802
v4 everywhere
eupharis Mar 24, 2025
96f63c3
bump version
eupharis Mar 24, 2025
15eab87
add new version
eupharis Mar 24, 2025
3ad2607
remove warning, just go with any type for now
eupharis Mar 26, 2025
1479d39
better generate printed messages, fix generate bug after function add
eupharis Mar 26, 2025
7db1cbe
Update python version (#32)
dchiniquy Mar 27, 2025
a3f09cd
Update python image (#33)
dchiniquy Mar 27, 2025
19fafde
Rollback version
nahuel-polyapi Mar 27, 2025
fccbf1e
onward (#34)
eupharis Apr 8, 2025
1e947d6
next (#35)
eupharis Apr 8, 2025
11108e0
improve intellisense detection of schemas
eupharis Apr 11, 2025
ef7e5e9
release 0.3.3.dev8, fix misleading generate after setup
eupharis Apr 14, 2025
71e2332
0.3.3.dev9 - add support for optional arguments (#36)
eupharis Apr 14, 2025
2b4a2d0
next
eupharis Apr 15, 2025
2169e15
release 0.3.3.dev10
eupharis Apr 15, 2025
c2db3e9
EN #3943 update to support SFX serverSideAsync True by setting correc…
eneumann May 2, 2025
2fc69ea
deploying version 0.3.3 for R22
nahuel-polyapi May 6, 2025
1e683f2
Merge branch 'main' into develop
eupharis May 6, 2025
a4a4872
upgrade version
FedeMarchiniHotovo May 6, 2025
e0e74b7
Merge branch 'main' into develop
FedeMarchiniHotovo May 6, 2025
a6ba2f3
4084 - revert strippping none values from function arguments during e…
akinboboye May 7, 2025
9c1a2a1
P2) Update clients and specs endpoint so when generating with no-type…
RichardDzurus May 7, 2025
d20794b
4010 generate contexts (#43)
akinboboye May 8, 2025
d02bae3
make contexts truly optional
eupharis May 12, 2025
bf238b2
P3) (Optoro) Allow variable to be secret in the UI, but gettable in f…
RichardDzurus May 13, 2025
78d4b15
add generate contexts (#45)
akinboboye May 15, 2025
ebf6e6b
adds mtls and direct execute options (#44)
RichardDzurus May 22, 2025
938dfdd
polyCustom - prevent rewrites of executionId (#46)
RichardDzurus May 26, 2025
db5381b
4292 (#47)
akinboboye May 27, 2025
93cff00
create mock schemas to fit everything when using no types flag (#48)
RichardDzurus May 28, 2025
050853e
EN #4348 flatten new-lines in arg descriptions (#50)
eneumann May 28, 2025
ee50a54
EN #4360 fix return types for TS funcs (#49)
eneumann May 28, 2025
bd33593
adding ability for python client server and client functions to add c…
aarongoin May 28, 2025
bc8e096
fix type error!
aarongoin May 28, 2025
569ec60
try simple upgrade
eupharis May 30, 2025
8c9d3d1
changed version
FedeMarchiniHotovo Jun 3, 2025
bd5729d
0.3.8.dev0 make it clearer that jsonschema parsing issue is warning n…
eupharis Jun 4, 2025
19c5613
4418 p2 bug on glide pre commit hook poly prepare make sure we git ad…
Daniel-Estoll Jun 18, 2025
391871a
4523 fix python client to save generate command arguments and reuse t…
Ash1R Jun 18, 2025
0026216
Update pydantic version to work with Python 3.13 (#54)
Ash1R Jun 24, 2025
a719bc0
fix vari under no types (#56)
eupharis Jun 25, 2025
0052b8e
better import error (#59)
eupharis Jun 26, 2025
cde7993
4645 Add github action for polyapi-python unittests, fix polyapi-pyth…
Ash1R Jun 26, 2025
4672a5a
Windows glide bug (#61)
Daniel-Estoll Jun 26, 2025
aa693fe
version command in python (#58)
RichardDzurus Jun 27, 2025
c6d9b8e
P2) Webhook Payload Type Blows Up our Python Client (#62)
RichardDzurus Jun 27, 2025
d47ab1d
Fixing bug where users couldn't put a description in their polyConfig…
aarongoin Jun 27, 2025
d32781a
next
eupharis Jun 30, 2025
f8416ee
fix schema generation (#64)
RichardDzurus Jun 30, 2025
88c55a3
remove bad ci file
eupharis Jun 30, 2025
58ac792
Upgrading version to 0.3.8 (#67)
nahuel-polyapi Jul 1, 2025
7dc8423
Merge branch 'main' into develop
eupharis Jul 1, 2025
8f0e01a
4655 p3 polyapi python schema errors lets fix (#63)
Daniel-Estoll Jul 7, 2025
5bad68b
Fixed find deployables command to ensure there are no duplicates (#65)
Daniel-Estoll Jul 7, 2025
b954112
Added check for LOGS_ENABLED env var and updated exceptions (#70)
Daniel-Estoll Jul 8, 2025
3b9ea19
allow higher stdlib_list
eupharis Jul 8, 2025
f5df984
update in one more spot
eupharis Jul 8, 2025
7a7c9b4
Merge branch 'main' into develop
eupharis Jul 8, 2025
c880a6a
increase version of truststore installed
eupharis Jul 8, 2025
e59776c
added logger (#72)
Daniel-Estoll Jul 9, 2025
f4ed72e
Change print to use logging (#73)
Daniel-Estoll Jul 16, 2025
c612f6e
EN #4845 fix function args schema bug for TypedDicts
eneumann Jul 17, 2025
a584bea
Revert c612f6e (EN #4845 fix function args schema bug for TypedDicts)…
eneumann Jul 17, 2025
1575998
EN bump v to 0.3.9.dev8
eneumann Jul 17, 2025
f51658c
EN #4845 fix func arg schema bug with typed dicts (#75)
eneumann Jul 17, 2025
eb81b46
Tabi sdk (#74)
aarongoin Jul 17, 2025
afb18ff
oh lordy (#76)
aarongoin Jul 17, 2025
c15d143
One more missed f-string in tabi
aarongoin Jul 17, 2025
6d9e606
Revert monkey patch (#77)
Daniel-Estoll Jul 18, 2025
5b9f621
remove need for special logging process
eupharis Jul 21, 2025
38827b6
fix GitHub action for polyapi python unittests, fix polyapi python un…
Ash1R Jul 21, 2025
65201eb
running into weird ord bug in python3.11, lets do simpler 7 char hash…
eupharis Jul 25, 2025
e3a343b
fix tests
eupharis Jul 28, 2025
25e768a
add workflow dispatch
eupharis Jul 28, 2025
422fcc6
try under 3.13
eupharis Jul 28, 2025
d1750c6
0.3.9.dev15: define some sort of scrub_keys
eupharis Jul 28, 2025
d6b18d7
back up
eupharis Jul 28, 2025
87caa04
actually fix tests
eupharis Jul 28, 2025
8a44827
Revert "actually fix tests"
eupharis Jul 28, 2025
06e8a41
in sync with actions now?
eupharis Jul 28, 2025
989840f
update version for deploy
aarongoin Jul 31, 2025
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
2 changes: 1 addition & 1 deletion .flake8
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[flake8]
ignore = E203,E303,E402,E501,E722,W391,F401,W292,F811
ignore = E203,E303,E402,E501,E722,W391,F401,W292,F811,E302
max-line-length = 150
max-complexity = 22
32 changes: 32 additions & 0 deletions .github/workflows/python-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Python CI

on:
workflow_dispatch:
push:
branches: [develop]
pull_request:
branches: [develop]

jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: '3.12'
cache: 'pip'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r dev_requirements.txt --no-cache-dir

- name: Create dummy poly directory for tests
run: mkdir -p polyapi/poly

- name: Run unit tests
run: python -m unittest discover -s tests -t . -v
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,5 @@ function_add_test.py
lib_test*.py
polyapi/poly
polyapi/vari
polyapi/tabi
polyapi/schemas
18 changes: 0 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,24 +70,6 @@ def bar():
return "Hello World"
```

## See Server Function Logs

In order to see function logs, please first set `logsEnabled` to `true` in Canopy for the function.

https://na1.polyapi.io/canopy/polyui/collections/server-functions

Then in your code, get the poly logger and log with it like so:

```python
logger = logging.getLogger("poly")
def bar():
logger.warning("I AM THE LOG")
return "Hello World"
```

Finally, click the "Show Logs" button to see your server function logs in Canopy!


## Complex Types In Server Functions

You can define arbitrarily complex argument and return types using TypedDicts.
Expand Down
4 changes: 3 additions & 1 deletion dev_requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
-r requirements.txt
mock==5.2.0
pytest
pytest
flask==3.0.3

6 changes: 3 additions & 3 deletions polyapi/auth.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from typing import List, Dict, Any, Tuple
import uuid

from polyapi.typedefs import PropertySpecification
from polyapi.utils import parse_arguments, get_type_and_def
Expand All @@ -26,7 +25,8 @@ async def getToken(clientId: str, clientSecret: str, scopes: List[str], callback

Function ID: {function_id}
\"""
eventsClientId = "{client_id}"
from polyapi.poly.client_id import client_id
eventsClientId = client_id
function_id = "{function_id}"

options = options or {{}}
Expand Down Expand Up @@ -165,7 +165,7 @@ def render_auth_function(
func_str = ""

if function_name == "getToken":
func_str = GET_TOKEN_TEMPLATE.format(function_id=function_id, description=function_description, client_id=uuid.uuid4().hex)
func_str = GET_TOKEN_TEMPLATE.format(function_id=function_id, description=function_description)
elif function_name == "introspectToken":
func_str = INTROSPECT_TOKEN_TEMPLATE.format(function_id=function_id, description=function_description)
elif function_name == "refreshToken":
Expand Down
23 changes: 13 additions & 10 deletions polyapi/deployables.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import os
import string
import random
import subprocess
import json
import hashlib
Expand Down Expand Up @@ -65,20 +67,21 @@ class SyncDeployment(TypedDict, total=False):
context: str
name: str
description: str
type: str
type: DeployableTypes
fileRevision: str
file: str
types: DeployableFunctionTypes
typeSchemas: Dict[str, any]
typeSchemas: Dict[str, Any]
dependencies: List[str]
config: Dict[str, any]
config: Dict[str, Any]
instance: str
id: Optional[str] = None
deployed: Optional[str] = None
id: Optional[str]
deployed: Optional[str]


DeployableTypeEntries: List[Tuple[DeployableTypeNames, DeployableTypes]] = [
("PolyServerFunction", "server-function"),
("PolyClientFunction", "client-function"),
("PolyServerFunction", "server-function"), # type: ignore
("PolyClientFunction", "client-function"), # type: ignore
]

DeployableTypeToName: Dict[DeployableTypeNames, DeployableTypes] = {name: type for name, type in DeployableTypeEntries}
Expand Down Expand Up @@ -118,13 +121,13 @@ def get_all_deployable_files_windows(config: PolyDeployConfig) -> List[str]:
pattern = ' '.join(f"/C:\"polyConfig: {name}\"" for name in config["type_names"]) or '/C:"polyConfig"'

exclude_command = f" | findstr /V /I \"{exclude_pattern}\"" if exclude_pattern else ''
search_command = f" | findstr /S /M /I /F:/ {pattern} *.*"
search_command = f" | findstr /M /I /F:/ {pattern}"

result = []
for dir_path in config["include_dirs"]:
if dir_path != '.':
include_pattern = " ".join(f"{dir_path}*.{f}" for f in config["include_files_or_extensions"]) or "*"
dir_command = f"dir {include_pattern} /S /P /B > NUL"
dir_command = f"dir {include_pattern} /S /P /B"
full_command = f"{dir_command}{exclude_command}{search_command}"
try:
output = subprocess.check_output(full_command, shell=True, text=True)
Expand Down Expand Up @@ -175,7 +178,7 @@ def get_git_revision(branch_or_tag: str = "HEAD") -> str:
return check_output(["git", "rev-parse", "--short", branch_or_tag], text=True).strip()
except CalledProcessError:
# Return a random 7-character hash as a fallback
return "".join(format(ord(c), 'x') for c in os.urandom(4))[:7]
return "".join([random.choice(string.ascii_letters + string.digits) for _ in range(7)])

def get_cache_deployments_revision() -> str:
"""Retrieve the cache deployments revision from a file."""
Expand Down
24 changes: 19 additions & 5 deletions polyapi/execute.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
from typing import Dict, Optional
import requests
import os
import logging
from requests import Response
from polyapi.config import get_api_key_and_url, get_mtls_config
from polyapi.exceptions import PolyApiException

logger = logging.getLogger("poly")

def direct_execute(function_type, function_id, data) -> Response:
""" execute a specific function id/type
"""
Expand All @@ -13,7 +17,11 @@ def direct_execute(function_type, function_id, data) -> Response:

endpoint_info = requests.post(url, json=data, headers=headers)
if endpoint_info.status_code < 200 or endpoint_info.status_code >= 300:
raise PolyApiException(f"{endpoint_info.status_code}: {endpoint_info.content.decode('utf-8', errors='ignore')}")
error_content = endpoint_info.content.decode("utf-8", errors="ignore")
if function_type == 'api' and os.getenv("LOGS_ENABLED"):
raise PolyApiException(f"Error executing api function with id: {function_id}. Status code: {endpoint_info.status_code}. Request data: {data}, Response: {error_content}")
elif function_type != 'api':
raise PolyApiException(f"{endpoint_info.status_code}: {error_content}")

endpoint_info_data = endpoint_info.json()
request_params = endpoint_info_data.copy()
Expand All @@ -38,9 +46,12 @@ def direct_execute(function_type, function_id, data) -> Response:
**request_params
)

if resp.status_code < 200 or resp.status_code >= 300:
if (resp.status_code < 200 or resp.status_code >= 300):
error_content = resp.content.decode("utf-8", errors="ignore")
raise PolyApiException(f"{resp.status_code}: {error_content}")
if function_type == 'api' and os.getenv("LOGS_ENABLED"):
logger.error(f"Error executing api function with id: {function_id}. Status code: {resp.status_code}. Request data: {data}, Response: {error_content}")
elif function_type != 'api':
raise PolyApiException(f"{resp.status_code}: {error_content}")

return resp

Expand All @@ -59,9 +70,12 @@ def execute(function_type, function_id, data) -> Response:
headers=headers,
)

if resp.status_code < 200 or resp.status_code >= 300:
if (resp.status_code < 200 or resp.status_code >= 300) and os.getenv("LOGS_ENABLED"):
error_content = resp.content.decode("utf-8", errors="ignore")
raise PolyApiException(f"{resp.status_code}: {error_content}")
if function_type == 'api' and os.getenv("LOGS_ENABLED"):
logger.error(f"Error executing api function with id: {function_id}. Status code: {resp.status_code}. Request data: {data}, Response: {error_content}")
elif function_type != 'api':
raise PolyApiException(f"{resp.status_code}: {error_content}")

return resp

Expand Down
Loading
Loading