Skip to content

Commit

Permalink
Merge pull request #4195 from davzucky/master
Browse files Browse the repository at this point in the history
Pass S3 client option from storage to result
  • Loading branch information
jcrist authored Mar 3, 2021
2 parents 5504704 + ef1de13 commit 6412878
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 1 deletion.
6 changes: 6 additions & 0 deletions changes/pr4195.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
fix:
- "Forward `client_options` to `S3Result` from `S3` storage - [#4195](https://github.com/PrefectHQ/prefect/pull/4195"


contributor:
- "[David Zucker](https://github.com/davzucky)"
2 changes: 1 addition & 1 deletion src/prefect/storage/s3.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def __init__(

self.client_options = client_options

result = S3Result(bucket=bucket)
result = S3Result(bucket=bucket, boto3_kwargs=client_options)
super().__init__(
result=result,
stored_as_script=stored_as_script,
Expand Down
27 changes: 27 additions & 0 deletions tests/storage/test_s3_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,33 @@ def test_boto3_client_property(monkeypatch):
)


def test_s3_storage_init_properly_result_with_boto3_args(monkeypatch):
client = MagicMock()
boto3 = MagicMock(client=MagicMock(return_value=client))
monkeypatch.setattr("boto3.client", boto3)

storage = S3(
bucket="bucket",
client_options={"endpoint_url": "http://some-endpoint", "use_ssl": False},
)

credentials = dict(
ACCESS_KEY="id", SECRET_ACCESS_KEY="secret", SESSION_TOKEN="session"
)
with context(secrets=dict(AWS_CREDENTIALS=credentials)):
result_path = storage.result.write("test")
assert result_path
boto3.assert_called_with(
"s3",
aws_access_key_id="id",
aws_secret_access_key="secret",
aws_session_token="session",
region_name=None,
endpoint_url="http://some-endpoint",
use_ssl=False,
)


def test_add_flow_to_S3():
storage = S3(bucket="bucket")

Expand Down

0 comments on commit 6412878

Please sign in to comment.