Created
September 29, 2021 13:29
-
-
Save anna-geller/2d1fd20e9c1ede937a86408a19a68ae1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import prefect | |
from prefect.storage import S3 | |
from prefect.run_configs import ECSRun | |
from prefect import task, Flow | |
FLOW_NAME = "ecs_demo" | |
STORAGE = S3( | |
bucket="prefect-datasets", | |
key=f"flows/{FLOW_NAME}.py", | |
stored_as_script=True, | |
# this will ensure to upload the Flow script to S3 during registration | |
local_script_path=f"{FLOW_NAME}.py", | |
) | |
RUN_CONFIG = ECSRun( | |
labels=["prod"], | |
task_role_arn="arn:aws:iam::123456:role/prefectTaskRole", | |
run_task_kwargs=dict(cluster="prefectEcsCluster", launchType="FARGATE",), | |
) | |
@task | |
def say_hi(): | |
logger = prefect.context.get("logger") | |
logger.info("Hi from Prefect %s", prefect.__version__) | |
with Flow(FLOW_NAME, storage=STORAGE, run_config=RUN_CONFIG,) as flow: | |
say_hi() | |
if __name__ == "__main__": | |
flow.register("ECS_Flows") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment