mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-08-19 16:02:14 +00:00
feat: Add download button to S3 file picker (#2857)
This commit is contained in:
committed by
GitHub
parent
70c2669b1e
commit
f8c7a8edf8
@@ -4,7 +4,7 @@ import os
|
||||
|
||||
|
||||
class TestStringMethods(unittest.TestCase):
|
||||
_token = "wx9B4WcQhlGSrmhbHY8HqADxx6f4oy"
|
||||
_token = "<WM_TOKEN>"
|
||||
_workspace = "storage"
|
||||
_host = "http://localhost:8000"
|
||||
_resource_path = "u/admin/docker_minio"
|
||||
@@ -64,6 +64,17 @@ SET s3_secret_access_key='80yMndIMcyXwEujxVNINQbf0tBlIzRaLPyM2m1n4';
|
||||
}
|
||||
self.assertEqual(settings, expected_settings)
|
||||
|
||||
def test_boto3_connection_settings(self):
|
||||
settings = wmill.boto3_connection_settings(self._resource_path)
|
||||
expected_settings = {
|
||||
"endpoint_url": "http://localhost:9000",
|
||||
"region_name": "fr-paris",
|
||||
"use_ssl": False,
|
||||
"aws_access_key_id": "IeuKPSYLKTO2h9CWfCVR",
|
||||
"aws_secret_access_key": "80yMndIMcyXwEujxVNINQbf0tBlIzRaLPyM2m1n4",
|
||||
}
|
||||
self.assertEqual(settings, expected_settings)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
@@ -352,6 +352,25 @@ class Windmill:
|
||||
return None
|
||||
raise Exception("Could not generate Polars S3 connection settings from the provided resource") from e
|
||||
|
||||
def get_boto3_connection_settings(
|
||||
self,
|
||||
s3_resource_path: str = "",
|
||||
none_if_undefined: bool = False,
|
||||
) -> Any:
|
||||
"""
|
||||
Convenient helpers that takes an S3 resource as input and returns the settings necessary to
|
||||
initiate an S3 connection using boto3
|
||||
"""
|
||||
try:
|
||||
return self.post(
|
||||
f"/w/{self.workspace}/job_helpers/v2/boto3_connection_settings",
|
||||
json={} if s3_resource_path == "" else {"s3_resource_path": s3_resource_path},
|
||||
).json()
|
||||
except JSONDecodeError as e:
|
||||
if none_if_undefined:
|
||||
return None
|
||||
raise Exception("Could not generate Polars S3 connection settings from the provided resource") from e
|
||||
|
||||
def whoami(self) -> dict:
|
||||
return self.get("/users/whoami").json()
|
||||
|
||||
@@ -479,6 +498,7 @@ def run_script_async(
|
||||
scheduled_in_secs=scheduled_in_secs,
|
||||
)
|
||||
|
||||
|
||||
@init_global_client
|
||||
def run_flow_async(
|
||||
path: str,
|
||||
@@ -491,6 +511,7 @@ def run_flow_async(
|
||||
scheduled_in_secs=scheduled_in_secs,
|
||||
)
|
||||
|
||||
|
||||
@init_global_client
|
||||
def run_script_sync(
|
||||
hash: str,
|
||||
@@ -572,6 +593,15 @@ def polars_connection_settings(s3_resource_path: str = "", none_if_undefined: bo
|
||||
return _client.get_polars_connection_settings(s3_resource_path, none_if_undefined)
|
||||
|
||||
|
||||
@init_global_client
|
||||
def boto3_connection_settings(s3_resource_path: str = "", none_if_undefined: bool = False) -> Any:
|
||||
"""
|
||||
Convenient helpers that takes an S3 resource as input and returns the settings necessary to
|
||||
initiate an S3 connection using boto3
|
||||
"""
|
||||
return _client.get_boto3_connection_settings(s3_resource_path, none_if_undefined)
|
||||
|
||||
|
||||
@init_global_client
|
||||
def whoami() -> dict:
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user