Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Fix deployment #169

Merged
merged 7 commits into from
Dec 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed

- `ECSTask` now logs the difference between the requested and the pre-registered task definition when using a `task_definition_arn` - [#166](https://github.com/PrefectHQ/prefect-aws/pull/166)
- Default of `S3Bucket` to be an empty string rather than None - [#169](https://github.com/PrefectHQ/prefect-aws/pull/169)

### Deprecated

### Removed

### Fixed

- Deployments of `S3Bucket` - [#169](https://github.com/PrefectHQ/prefect-aws/pull/169)
- The image from `task_definition_arn` will be respected if `image` is not explicitly set - [#170](https://github.com/PrefectHQ/prefect-aws/pull/170)

### Security
Expand Down
6 changes: 3 additions & 3 deletions prefect_aws/s3.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import os
import uuid
from pathlib import Path
from typing import Any, Dict, List, Optional
from typing import Any, Dict, List, Optional, Union
from uuid import uuid4

import boto3
Expand Down Expand Up @@ -269,8 +269,8 @@ class S3Bucket(WritableFileSystem, WritableDeploymentStorage):
description="A block containing your credentials (choose this or "
"AWS Credentials).",
)
basepath: Optional[Path] = Field(
default=None,
basepath: Optional[Union[str, Path]] = Field(
default="",
description="Location to write to and read from in the S3 bucket. Defaults to "
"the root of the bucket.",
)
Expand Down
17 changes: 17 additions & 0 deletions tests/test_s3_bucket.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import pytest
from botocore.exceptions import ClientError
from moto import mock_s3
from prefect.deployments import Deployment

from prefect_aws import AwsCredentials, MinIOCredentials
from prefect_aws.s3 import S3Bucket
Expand Down Expand Up @@ -312,3 +313,19 @@ def test_write_path_in_sync_context(s3_bucket):
key = s3_bucket.write_path("test.txt", content=b"hello")
content = s3_bucket.read_path(key)
assert content == b"hello"


def test_deployment_default_basepath(s3_bucket):
deployment = Deployment(name="testing", storage=s3_bucket)
assert deployment.location == "/"


@pytest.mark.parametrize("type_", [str, Path])
def test_deployment_set_basepath(aws_creds_block, type_):
s3_bucket_block = S3Bucket(
bucket_name=BUCKET_NAME,
aws_credentials=aws_creds_block,
basepath=type_("home"),
)
deployment = Deployment(name="testing", storage=s3_bucket_block)
assert deployment.location == "home/"