Skip to main content

Prefect collection of tasks and subflows to integrate with AWS

Project description

Coordinate and incorporate AWS in your dataflow with prefect-aws


PyPI

Visit the full docs here to see additional examples and the API reference.

Welcome!

prefect-aws is a collection of pre-built Prefect tasks that can be used to quickly construct Prefect flows that interact with Amazon Web Services.

Getting Started

Saving credentials to a block

You will need to obtain AWS credentials in order to use prefect-aws.

  1. Refer to the AWS Configuration documentation on how to retrieve your access key ID and secret access key
  2. Copy the access key ID and secret access key
  3. Create a short script, replacing the placeholders (or do so in the UI)
from prefect_aws import AwsCredentials
AwsCredentials(
    aws_access_key_id="PLACEHOLDER",
    aws_secret_access_key="PLACEHOLDER",
    aws_session_token=None,  # replace this with token if necessary
).save("BLOCK_NAME_PLACEHOLDER")

Congrats! You can now easily load the saved block, which holds your credentials:

from prefect_aws import AwsCredentials
AwsCredentials.load("BLOCK_NAME_PLACEHOLDER")

Write and run a flow

Upload and download from S3Bucket

from prefect import flow
from prefect_aws.s3 import S3Bucket

@flow
def example_flow():
    with open("hello.py", "w") as f:
        f.write("print('Hello world!')")

    s3_bucket = S3Bucket.load("my-bucket-test")
    s3_bucket.upload_from_path("hello.py")
    s3_bucket.download_object_to_path("hello.py", "downloaded_hello.py")

example_flow()

Write, read, and delete secret from AWS Secrets Manager

from prefect import flow
from prefect_aws import AwsCredentials, AwsSecret

@flow
def example_flow():
    secrets_manager = AwsSecret.load("my-block")
    secrets_manager.write_secret("my-secret-value")
    secret = secrets_manager.read_secret()
    print(secret)
    secrets_manager.delete_secret()

example_flow()

Use with_options to customize options on any existing task or flow

custom_example_flow = example_flow.with_options(
    name="My custom task name",
    retries=2,
    retry_delay_seconds=10,
) 

Resources

Refer to the API documentation on the sidebar to explore all the capabilities of Prefect AWS!

For more tips on how to use tasks and flows in a Collection, check out Using Collections!

Recipes

A tutorial on ECSTask can be found here.

For additional recipes and examples, check out prefect-recipes.

Feedback

If you have any questions or issues while using prefect-aws, you can find help in either the Prefect Discourse forum or the Prefect Slack community.

Feel free to star or watch prefect-aws for updates too!

Installation

Install prefect-aws

pip install prefect-aws

A list of available blocks in prefect-aws and their setup instructions can be found here.

Requires an installation of Python 3.7+

We recommend using a Python virtual environment manager such as pipenv, conda or virtualenv.

These tasks are designed to work with Prefect 2.0. For more information about how to use Prefect, please refer to the Prefect documentation.

Contributing

If you'd like to help contribute to fix an issue or add a feature to prefect-aws, please propose changes through a pull request from a fork of the repository.

Here are the steps:

  1. Fork the repository
  2. Clone the forked repository
  3. Install the repository and its dependencies:
pip install -e ".[dev]"
  1. Make desired changes
  2. Add tests
  3. Insert an entry to CHANGELOG.md
  4. Install pre-commit to perform quality checks prior to commit:
pre-commit install
  1. git commit, git push, and create a pull request

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

prefect-aws-0.2.5.tar.gz (73.0 kB view details)

Uploaded Source

Built Distribution

prefect_aws-0.2.5-py3-none-any.whl (39.8 kB view details)

Uploaded Python 3

File details

Details for the file prefect-aws-0.2.5.tar.gz.

File metadata

  • Download URL: prefect-aws-0.2.5.tar.gz
  • Upload date:
  • Size: 73.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.16

File hashes

Hashes for prefect-aws-0.2.5.tar.gz
Algorithm Hash digest
SHA256 10c819b53a75d362164d082b62a911dc3cb13f14ce3c589d4bb4b6eb42814936
MD5 66d1c5a6edb5dd90fb35dcab0e7d367d
BLAKE2b-256 f3813816f41de2b213dbf23e8edbcedb7ed85e8021ada3504d2dd9284ae72674

See more details on using hashes here.

File details

Details for the file prefect_aws-0.2.5-py3-none-any.whl.

File metadata

  • Download URL: prefect_aws-0.2.5-py3-none-any.whl
  • Upload date:
  • Size: 39.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.16

File hashes

Hashes for prefect_aws-0.2.5-py3-none-any.whl
Algorithm Hash digest
SHA256 b00cbab19cf545526a7c934441ac2fe64b2fec723a205f3554b7204cb82049a3
MD5 89a57b70e6fd47626864b0aca617e136
BLAKE2b-256 cbb58f49c51bec116fb70fadb9918bd7ef406b4c1397b8a16921b0d41b7595a9

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page