feat: Add Python SDK capabilities to generate Polars and DuckDB connection settings to S3 (#2625)

* feat: Add Python SDK capabilities to generate Polars and DuckDB connection settings to S3

* Add endpoint to list S3 objects

* Add FE to set the workspace S3 resource

* Fix openapi

* sqlx prepare

* Hide Windmil LFS tab
This commit is contained in:
Guillaume Bouvignies
2023-11-15 19:37:02 +01:00
committed by GitHub
parent f38498b725
commit 90093656b4
29 changed files with 2102 additions and 663 deletions

View File

@@ -0,0 +1,16 @@
Testing pythong wmill client
============================
Make sure you have a local windmill BE running and listening on localhost:8000 (either using cargo run or via the docker compose).
Install the local package to your virtual env:
```bash
# this is necessary only if you made a change to the BE API via the openapi.yml file
cd ./windmill-api # you can generate it using the build.sh script at the root of this repo
pip3 install .
cd ./wmill
pip3 install .
```
Then you can run go to `wmill_client_test.py` and add a Token and Workspace if necessary. You can then implement your own test calling any function in the wmill client and test its output.

View File

@@ -0,0 +1,69 @@
import unittest
import wmill
import os
class TestStringMethods(unittest.TestCase):
_token = "<TOKEN>"
_workspace = "<WORKSPACE>"
def setUp(self):
os.environ["WM_WORKSPACE"] = self._workspace
os.environ["WM_TOKEN"] = self._token
def test_duckdb_connection_settings(self):
s3_resource = {
"port": 9000,
"bucket": "windmill",
"region": "fr-paris",
"useSSL": False,
"endPoint": "localhost:9000",
"accessKey": "ACCESS_KEY",
"pathStyle": True,
"secretKey": "SECRET_KEY",
}
settings = wmill.duckdb_connection_settings(s3_resource)
self.assertIsNotNone(settings)
expected_settings_str = """SET home_directory='./shared/';
INSTALL 'httpfs';
SET s3_url_style='path';
SET s3_region='fr-paris';
SET s3_endpoint='localhost:9000';
SET s3_use_ssl=0;
SET s3_access_key_id='ACCESS_KEY';
SET s3_secret_access_key='SECRET_KEY';
"""
self.assertEqual(settings, {"connection_settings_str": expected_settings_str})
settings = wmill.polars_connection_settings(s3_resource)
print(settings)
def test_polars_connection_settings(self):
s3_resource = {
"port": 9000,
"bucket": "windmill",
"region": "fr-paris",
"useSSL": False,
"endPoint": "localhost:9000",
"accessKey": "ACCESS_KEY",
"pathStyle": True,
"secretKey": "SECRET_KEY",
}
settings = wmill.polars_connection_settings(s3_resource)
print(settings)
expected_settings = {
"cache_regions": False,
"client_kwargs": {"region_name": "fr-paris"},
"endpoint_url": "localhost:9000",
"key": "ACCESS_KEY",
"secret": "SECRET_KEY",
"use_ssl": False,
}
self.assertEqual(settings, expected_settings)
if __name__ == "__main__":
unittest.main()