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

Commit

Permalink
Merge branch 'main' into mask-prefect-api-key
Browse files Browse the repository at this point in the history
  • Loading branch information
jakekaplan committed Nov 21, 2023
2 parents 06fd5c7 + 36b203d commit 6fd777d
Show file tree
Hide file tree
Showing 26 changed files with 1,004 additions and 99 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.7
python-version: 3.8

- name: Install packages
run: |
Expand Down
6 changes: 2 additions & 4 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ jobs:
strategy:
matrix:
python-version:
- "3.7"
- "3.8"
- "3.9"
- "3.10"
- "3.11"
fail-fast: false
steps:
- uses: actions/checkout@v4
Expand All @@ -33,9 +33,7 @@ jobs:
env:
PREFECT_SERVER_DATABASE_CONNECTION_URL: "sqlite+aiosqlite:///./collection-tests.db"
run: |
prefect server database reset -y
coverage run --branch -m pytest tests -vv
coverage report
pytest --cov=prefect_aws --no-cov-on-fail --cov-report=term-missing --cov-branch tests -n auto -vv
- name: Run mkdocs build
run: |
Expand Down
45 changes: 41 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,54 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added

- Added retries to ECS task run creation for ECS worker - [#303](https://github.com/PrefectHQ/prefect-aws/pull/303)
- Added support to `ECSWorker` for `awsvpcConfiguration` [#304](https://github.com/PrefectHQ/prefect-aws/pull/304)

### Changed
- Added 'SecretBrinary' suport to `AwsSecret` block - [#274](https://github.com/PrefectHQ/prefect-aws/pull/274)

- Changed `push_to_s3` deployment step function to write paths `as_posix()` to allow support for deploying from windows [#314](https://github.com/PrefectHQ/prefect-aws/pull/314)
### Fixed

### Deprecated

### Removed

## 0.4.2

Released November 6th, 2023.

### Fixed

- Fixed use_ssl default for s3 client.

## 0.4.1

Released October 13th, 2023.

### Added

- AWS S3 copy and move tasks and `S3Bucket` methods - [#316](https://github.com/PrefectHQ/prefect-aws/pull/316)

### Fixed

- `ECSWorker` issue where defining a custom network configuration with a subnet would erroneously report it as missing from the VPC when more than one subnet exists in the VPC. [#321](https://github.com/PrefectHQ/prefect-aws/pull/321)
- Updated `push_to_s3` and `pull_from_s3` deployment steps to properly create a boto3 session client if the passed credentials are a referenced `AwsCredentials` block [#322](https://github.com/PrefectHQ/prefect-aws/pull/322)

## 0.4.0

Released October 5th, 2023.

### Changed

- Changed `push_to_s3` deployment step function to write paths `as_posix()` to allow support for deploying from windows [#314](https://github.com/PrefectHQ/prefect-aws/pull/314)
- Conditional imports to support operating with pydantic>2 installed - [#317](https://github.com/PrefectHQ/prefect-aws/pull/317)

## 0.3.7

Released August 31st, 2023.

### Added

- Added retries to ECS task run creation for ECS worker - [#303](https://github.com/PrefectHQ/prefect-aws/pull/303)
- Added support to `ECSWorker` for `awsvpcConfiguration` [#304](https://github.com/PrefectHQ/prefect-aws/pull/304)

## 0.3.6

Released July 20th, 2023.
Expand Down
18 changes: 8 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,24 @@
# Incorporate AWS into your Prefect workflows with `prefect-aws`
# `prefect-aws`

<p align="center">
<img src="https://user-images.githubusercontent.com/15331990/214123296-4cfa69ed-d105-4ca2-a351-4c21917086c7.png">
<br>
<a href="https://pypi.python.org/pypi/prefect-aws/" alt="PyPI version">
<img alt="PyPI" src="https://img.shields.io/pypi/v/prefect-aws?color=0052FF&labelColor=090422"></a>
<img alt="PyPI" src="https://img.shields.io/pypi/v/prefect-aws?color=26272B&labelColor=090422"></a>
<a href="https://github.com/prefecthq/prefect-aws/" alt="Stars">
<img src="https://img.shields.io/github/stars/prefecthq/prefect-aws?color=0052FF&labelColor=090422" /></a>
<img src="https://img.shields.io/github/stars/prefecthq/prefect-aws?color=26272B&labelColor=090422" /></a>
<a href="https://pepy.tech/badge/prefect-aws/" alt="Downloads">
<img src="https://img.shields.io/pypi/dm/prefect-aws?color=0052FF&labelColor=090422" /></a>
<img src="https://img.shields.io/pypi/dm/prefect-aws?color=26272B&labelColor=090422" /></a>
<a href="https://github.com/prefecthq/prefect-aws/pulse" alt="Activity">
<img src="https://img.shields.io/github/commit-activity/m/prefecthq/prefect-aws?color=0052FF&labelColor=090422" /></a>
<img src="https://img.shields.io/github/commit-activity/m/prefecthq/prefect-aws?color=26272B&labelColor=090422" /></a>
<br>
<a href="https://prefect-community.slack.com" alt="Slack">
<img src="https://img.shields.io/badge/slack-join_community-red.svg?color=0052FF&labelColor=090422&logo=slack" /></a>
<img src="https://img.shields.io/badge/slack-join_community-red.svg?color=26272B&labelColor=090422&logo=slack" /></a>
<a href="https://discourse.prefect.io/" alt="Discourse">
<img src="https://img.shields.io/badge/discourse-browse_forum-red.svg?color=0052FF&labelColor=090422&logo=discourse" /></a>
<img src="https://img.shields.io/badge/discourse-browse_forum-red.svg?color=26272B&labelColor=090422&logo=discourse" /></a>
</p>

## Welcome!

The `prefect-aws` collection makes it easy to leverage the capabilities of AWS in your flows, featuring support for ECS, S3, Secrets Manager, Batch Job, and Client Waiter.
`prefect-aws` makes it easy to leverage the capabilities of AWS in your flows, featuring support for ECS, S3, Secrets Manager, and Batch.

Visit the full docs [here](https://PrefectHQ.github.io/prefect-aws).

Expand Down
24 changes: 8 additions & 16 deletions docs/ecs_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ ECS (Elastic Container Service) tasks are a good option for executing Prefect 2

## ECS Flow Run Execution

Prefect enables remote flow execution via [workers](https://docs.prefect.io/2.11.1/concepts/work-pools/#worker-overview) and [work pools](https://docs.prefect.io/2.11.1/concepts/work-pools/#work-pool-overview). To learn more about these concepts please see our [deployment tutorial](https://docs.prefect.io/2.11.1/tutorial/deployments/).
Prefect enables remote flow execution via [workers](https://docs.prefect.io/concepts/work-pools/#worker-overview) and [work pools](https://docs.prefect.io/concepts/work-pools/#work-pool-overview). To learn more about these concepts please see our [deployment tutorial](https://docs.prefect.io/tutorial/deployments/).

For details on how workers and work pools are implemented for ECS, see the diagram below:
#### Architecture Diagram
Expand Down Expand Up @@ -182,22 +182,14 @@ To create an [IAM role](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_role
"containerDefinitions": [
{
"name": "prefect-worker",
"image": "prefecthq/prefect",
"image": "prefecthq/prefect:2-latest",
"cpu": 512,
"memory": 1024,
"essential": true,
"command": [
"pip",
"install",
"prefect-aws",
"&&",
"prefect",
"worker",
"start",
"--pool",
"my-ecs-pool",
"--type",
"ecs"
"/bin/sh",
"-c",
"pip install prefect-aws && prefect worker start --pool my-ecs-pool --type ecs"
],
"environment": [
{
Expand All @@ -218,7 +210,7 @@ To create an [IAM role](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_role

- For the `PREFECT_API_KEY`, individuals on the organization tier can create a [service account](https://docs.prefect.io/latest/cloud/users/service-accounts/) for the worker. If on a personal tier, you can pass a user’s API key.

- Replace `<your-ecs-task-role-arn>` with the ARN of the IAM role you created in Step 1.
- Replace both instances of `<your-ecs-task-role-arn>` with the ARN of the IAM role you created in Step 2.

- Notice that the CPU and Memory allocations are relatively small. The worker's main responsibility is to submit work through API calls to AWS, _not_ to execute your Prefect flow code.

Expand Down Expand Up @@ -296,10 +288,10 @@ To create an [IAM role](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_role
- Do your flow runs require higher `CPU`?
- Would an EC2 `Launch Type` speed up your flow run execution?

These infrastructure configuration values can be set on your ECS work pool or they can be overridden on the deployment level through [job_variables](https://docs.prefect.io/2.11.0/concepts/infrastructure/#kubernetesjob-overrides-and-customizations) if desired.
These infrastructure configuration values can be set on your ECS work pool or they can be overridden on the deployment level through [job_variables](https://docs.prefect.io/concepts/infrastructure/#kubernetesjob-overrides-and-customizations) if desired.


2. Consider adding a [build action](https://docs.prefect.io/2.11.0/concepts/deployments-ux/#the-build-action) to your Prefect Project [`prefect.yaml`](https://docs.prefect.io/2.11.0/concepts/deployments-ux/#the-prefect-yaml-file) if you want to automatically build a Docker image and push it to an image registry `prefect deploy` is run.
2. Consider adding a [build action](https://docs.prefect.io/concepts/deployments-ux/#the-build-action) to your Prefect Project [`prefect.yaml`](https://docs.prefect.io/concepts/deployments-ux/#the-prefect-yaml-file) if you want to automatically build a Docker image and push it to an image registry `prefect deploy` is run.

Here is an example build action for ECR:
```yaml
Expand Down
Binary file modified docs/img/favicon.ico
Binary file not shown.
Binary file removed docs/img/prefect-logo-mark-solid-white-500.png
Binary file not shown.
Binary file added docs/img/prefect-logo-mark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed docs/img/prefect-logo-white.png
Binary file not shown.
18 changes: 8 additions & 10 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,24 @@
# Coordinate and incorporate AWS in your dataflow with `prefect-aws`
# `prefect-aws`

<p align="center">
<img src="https://user-images.githubusercontent.com/15331990/214123296-4cfa69ed-d105-4ca2-a351-4c21917086c7.png">
<br>
<a href="https://pypi.python.org/pypi/prefect-aws/" alt="PyPI version">
<img alt="PyPI" src="https://img.shields.io/pypi/v/prefect-aws?color=0052FF&labelColor=090422"></a>
<img alt="PyPI" src="https://img.shields.io/pypi/v/prefect-aws?color=26272B&labelColor=090422"></a>
<a href="https://github.com/prefecthq/prefect-aws/" alt="Stars">
<img src="https://img.shields.io/github/stars/prefecthq/prefect-aws?color=0052FF&labelColor=090422" /></a>
<img src="https://img.shields.io/github/stars/prefecthq/prefect-aws?color=26272B&labelColor=090422" /></a>
<a href="https://pepy.tech/badge/prefect-aws/" alt="Downloads">
<img src="https://img.shields.io/pypi/dm/prefect-aws?color=0052FF&labelColor=090422" /></a>
<img src="https://img.shields.io/pypi/dm/prefect-aws?color=26272B&labelColor=090422" /></a>
<a href="https://github.com/prefecthq/prefect-aws/pulse" alt="Activity">
<img src="https://img.shields.io/github/commit-activity/m/prefecthq/prefect-aws?color=0052FF&labelColor=090422" /></a>
<img src="https://img.shields.io/github/commit-activity/m/prefecthq/prefect-aws?color=26272B&labelColor=090422" /></a>
<br>
<a href="https://prefect-community.slack.com" alt="Slack">
<img src="https://img.shields.io/badge/slack-join_community-red.svg?color=0052FF&labelColor=090422&logo=slack" /></a>
<img src="https://img.shields.io/badge/slack-join_community-red.svg?color=26272B&labelColor=090422&logo=slack" /></a>
<a href="https://discourse.prefect.io/" alt="Discourse">
<img src="https://img.shields.io/badge/discourse-browse_forum-red.svg?color=0052FF&labelColor=090422&logo=discourse" /></a>
<img src="https://img.shields.io/badge/discourse-browse_forum-red.svg?color=26272B&labelColor=090422&logo=discourse" /></a>
</p>

## Welcome!

The `prefect-aws` collection makes it easy to leverage the capabilities of AWS in your flows, featuring support for ECSTask, S3, Secrets Manager, Batch Job, and Client Waiter.
`prefect-aws` makes it easy to leverage the capabilities of AWS in your flows, featuring support for ECSTask, S3, Secrets Manager, Batch Job, and Client Waiter.


## Getting Started
Expand Down
14 changes: 7 additions & 7 deletions docs/stylesheets/extra.css
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/* theme */
:root > * {
/* theme */
--md-primary-fg-color: #115AF4;
--md-primary-fg-color--light: #115AF4;
--md-primary-fg-color--dark: #115AF4;
--md-primary-fg-color: #26272B;
--md-primary-fg-color--light: #26272B;
--md-primary-fg-color--dark: #26272B;
}

/* Table formatting */
Expand Down Expand Up @@ -72,7 +72,7 @@ to force column width */
/* dark mode slate theme */
/* dark mode code overrides */
[data-md-color-scheme="slate"] {
--md-code-bg-color: #252a33;
--md-code-bg-color: #1c1d20;
--md-code-fg-color: #eee;
--md-code-hl-color: #3b3d54;
--md-code-hl-name-color: #eee;
Expand Down Expand Up @@ -100,15 +100,15 @@ to force column width */

/* dark mode collection catalog overrides */
[data-md-color-scheme="slate"] .collection-item {
background-color: #3b3d54;
background-color: #26272B;
}

/* dark mode recipe collection overrides */
[data-md-color-scheme="slate"] .recipe-item {
background-color: #3b3d54;
background-color: #26272B;
}

/* dark mode API doc overrides */
[data-md-color-scheme="slate"] .prefect-table th {
background-color: #3b3d54;
background-color: #26272B;
}
2 changes: 1 addition & 1 deletion mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ theme:
icon:
repo: fontawesome/brands/github
logo:
img/prefect-logo-mark-solid-white-500.png
img/prefect-logo-mark.png
font:
text: Inter
code: Source Code Pro
Expand Down
7 changes: 6 additions & 1 deletion prefect_aws/client_parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@

from botocore import UNSIGNED
from botocore.client import Config
from pydantic import BaseModel, Field, FilePath, root_validator, validator
from pydantic import VERSION as PYDANTIC_VERSION

if PYDANTIC_VERSION.startswith("2."):
from pydantic.v1 import BaseModel, Field, FilePath, root_validator, validator
else:
from pydantic import BaseModel, Field, FilePath, root_validator, validator


class AwsClientParameters(BaseModel):
Expand Down
11 changes: 8 additions & 3 deletions prefect_aws/credentials.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@
from mypy_boto3_s3 import S3Client
from mypy_boto3_secretsmanager import SecretsManagerClient
from prefect.blocks.abstract import CredentialsBlock
from pydantic import Field, SecretStr
from pydantic import VERSION as PYDANTIC_VERSION

if PYDANTIC_VERSION.startswith("2."):
from pydantic.v1 import Field, SecretStr
else:
from pydantic import Field, SecretStr

from prefect_aws.client_parameters import AwsClientParameters

Expand Down Expand Up @@ -35,7 +40,7 @@ class AwsCredentials(CredentialsBlock):
```
""" # noqa E501

_logo_url = "https://images.ctfassets.net/gm98wzqotmnx/1jbV4lceHOjGgunX15lUwT/db88e184d727f721575aeb054a37e277/aws.png?h=250" # noqa
_logo_url = "https://cdn.sanity.io/images/3ugk85nk/production/d74b16fe84ce626345adf235a47008fea2869a60-225x225.png" # noqa
_block_type_name = "AWS Credentials"
_documentation_url = "https://prefecthq.github.io/prefect-aws/credentials/#prefect_aws.credentials.AwsCredentials" # noqa

Expand Down Expand Up @@ -159,7 +164,7 @@ class MinIOCredentials(CredentialsBlock):
```
""" # noqa E501

_logo_url = "https://images.ctfassets.net/gm98wzqotmnx/22vXcxsOrVeFrUwHfSoaeT/7607b876eb589a9028c8126e78f4c7b4/imageedit_7_2837870043.png?h=250" # noqa
_logo_url = "https://cdn.sanity.io/images/3ugk85nk/production/676cb17bcbdff601f97e0a02ff8bcb480e91ff40-250x250.png" # noqa
_block_type_name = "MinIO Credentials"
_description = (
"Block used to manage authentication with MinIO. Refer to the MinIO "
Expand Down
Loading

0 comments on commit 6fd777d

Please sign in to comment.