Skip to content
Merged

R22 #40

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 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
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
4 changes: 2 additions & 2 deletions .flake8
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[flake8]
extend-ignore = E203,E303,E402,E501,E722,W391,F401,W292
ignore = E203,E303,E402,E501,E722,W391,F401,W292,F811
max-line-length = 150
max-complexity = 20
max-complexity = 22
26 changes: 13 additions & 13 deletions .github/workflows/polyapi-update-python-package.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Update python pip package
name: Update python pip package
on:
push:
paths:
Expand All @@ -13,7 +13,7 @@ jobs:
runs-on: ubuntu-latest
if: ${{ github.ref == 'refs/heads/develop' }}
environment: dev

steps:
- uses: actions/checkout@v4
- name: Set up Python
Expand All @@ -31,7 +31,7 @@ jobs:
- name: Build a binary wheel and a source tarball
run: python3 -m build
- name: Store the distribution packages
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: python-package-distributions
path: dist/
Expand All @@ -44,27 +44,27 @@ jobs:
needs: develop-build
environment:
name: dev
url: https://pypi.org/p/polyapi-python
url: https://pypi.org/p/polyapi-python

permissions:
id-token: write
id-token: write
steps:

- name: Download all the dists
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: python-package-distributions
path: dist/
- name: Publish distribution 📦 to PyPI
uses: pypa/gh-action-pypi-publish@release/v1


main-build:
name: Build distribution 📦
runs-on: ubuntu-latest
if: ${{ github.ref == 'refs/heads/main' }}
environment: main

steps:
- uses: actions/checkout@v4
- name: Set up Python
Expand All @@ -81,7 +81,7 @@ jobs:
- name: Build a binary wheel and a source tarball
run: python3 -m build
- name: Store the distribution packages
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: python-package-distributions
path: dist/
Expand All @@ -90,20 +90,20 @@ jobs:
main-publish-to-pypi:
name: >-
Publish Python 🐍 distribution 📦 to PyPI
if: ${{ github.ref == 'refs/heads/main' }}
if: ${{ github.ref == 'refs/heads/main' }}
needs:
- main-build
runs-on: ubuntu-latest
environment:
name: main
url: https://pypi.org/p/polyapi-python
url: https://pypi.org/p/polyapi-python
permissions:
id-token: write
id-token: write


steps:
- name: Download all the dists
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: python-package-distributions
path: dist/
Expand Down
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,6 @@ __pycache__
.polyapi-python
function_add_test.py
lib_test*.py
polyapi/poly/
polyapi/vari/
polyapi/poly
polyapi/vari
polyapi/schemas
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2023 PolyAPI Inc.
Copyright (c) 2025 PolyAPI Inc.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,26 @@ To run this library's unit tests, please clone the repo then run:
python -m unittest discover
```

## Linting

The flake8 config is at the root of this repo at `.flake8`.

When hacking on this library, please enable flake8 and add this line to your flake8 args (e.g., in your VSCode Workspace Settings):

```
--config=.flake8
```

## Mypy Type Improvements

This script is handy for checking for any mypy types:

```bash
./check_mypy.sh
```

Please ignore \[name-defined\] errors for now. This is a known bug we are working to fix!

## Support

If you run into any issues or want help getting started with this project, please contact support@polyapi.io
5 changes: 5 additions & 0 deletions check_mypy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash

mypy polyapi/poly
mypy polyapi/vari
mypy polyapi/schemas
2 changes: 2 additions & 0 deletions polyapi/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from typing import List, Dict, Any, TypedDict
{args_def}
{return_type_def}

class {api_response_type}(TypedDict):
status: int
headers: Dict
Expand Down Expand Up @@ -41,6 +42,7 @@ def render_api_function(
arg_names = [a["name"] for a in arguments]
args, args_def = parse_arguments(function_name, arguments)
return_type_name, return_type_def = get_type_and_def(return_type) # type: ignore

data = "{" + ", ".join([f"'{arg}': {rewrite_arg_name(arg)}" for arg in arg_names]) + "}"

api_response_type = f"{function_name}Response"
Expand Down
3 changes: 1 addition & 2 deletions polyapi/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

CLI_COMMANDS = ["setup", "generate", "function", "clear", "help", "update_rendered_spec"]


def execute_from_cli():
# First we setup all our argument parsing logic
# Then we parse the arguments (waaay at the bottom)
Expand Down Expand Up @@ -46,9 +47,7 @@ def setup(args):

def generate_command(args):
initialize_config()
print("Generating Poly functions...", end="")
generate()
print_green("DONE")

generate_parser.set_defaults(command=generate_command)

Expand Down
6 changes: 5 additions & 1 deletion polyapi/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ def set_api_key_and_url(key: str, url: str):
config.set("polyapi", "poly_api_base_url", url)
with open(get_config_file_path(), "w") as f:
config.write(f)
global API_KEY
global API_URL
API_KEY = key
API_URL = url


def initialize_config(force=False):
Expand All @@ -81,7 +85,7 @@ def initialize_config(force=False):
sys.exit(1)

set_api_key_and_url(key, url)
print_green(f"Poly setup complete.")
print_green("Poly setup complete.")

if not key or not url:
print_yellow("Poly API Key and Poly API Base URL are required.")
Expand Down
7 changes: 6 additions & 1 deletion polyapi/execute.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from typing import Dict
import requests
from requests import Response
from polyapi.config import get_api_key_and_url
Expand All @@ -7,10 +8,14 @@
def execute(function_type, function_id, data) -> Response:
""" execute a specific function id/type
"""
data_without_None = data
if isinstance(data, Dict):
data_without_None = {k: v for k, v in data.items() if v is not None}

api_key, api_url = get_api_key_and_url()
headers = {"Authorization": f"Bearer {api_key}"}
url = f"{api_url}/functions/{function_type}/{function_id}/execute"
resp = requests.post(url, json=data, headers=headers)
resp = requests.post(url, json=data_without_None, headers=headers)
# print(resp.status_code)
# print(resp.headers["content-type"])
if resp.status_code < 200 or resp.status_code >= 300:
Expand Down
7 changes: 2 additions & 5 deletions polyapi/function_cli.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import sys
from typing import Any, List, Optional
import requests
from polyapi.generate import get_functions_and_parse, generate_functions
from polyapi.generate import generate as generate_library
from polyapi.config import get_api_key_and_url
from polyapi.utils import get_auth_headers, print_green, print_red, print_yellow
from polyapi.parser import parse_function_code, get_jsonschema_type
Expand Down Expand Up @@ -87,10 +87,7 @@ def function_add_or_update(
function_id = resp.json()["id"]
print(f"Function ID: {function_id}")
if generate:
print("Generating new custom function...", end="")
functions = get_functions_and_parse(limit_ids=[function_id])
generate_functions(functions)
print_green("DONE")
generate_library()
else:
print("Error adding function.")
print(resp.status_code)
Expand Down
Loading