chia berry
02/23/2022, 7:46 PMEmailTask
instead of the transform_and_show task. I want to send the data result in the body of the email. However, I am getting the message AttributeError: 'FunctionTask' object has no attribute 'encode'
. If I make it a string, I get an empty email. I’d like to send the actual result and not the functiontask.Kevin Kho
02/23/2022, 7:48 PMchia berry
02/23/2022, 7:49 PM@task(name="First", result=PrefectResult(), slug="first-slug")
def first():
logger = prefect.context.get("logger")
<http://logger.info|logger.info>("ONE!")
return {"users": "thing"}
email_task = EmailTask(
name="email_task",
subject="Test from ATD",
msg="this is a test",
email_to="chia.berry@***.gov", # <- Type your email here
email_from=email_config["email_from"],
smtp_server=email_config["smtp_server"],
smtp_port=email_config["smtp_port"],
smtp_type=email_config["smtp_type"],
attachments=None
)
with Flow(
f"dependent_flow_one_{current_environment}",
storage=GitHub(
repo="cityofaustin/atd-prefect",
path="flows/test/dependent_flows.py",
ref="7368-knack-banner", # The branch name
),
run_config=UniversalRun(
labels=[current_environment]
),
result=PrefectResult()
) as first_flow:
email_data = first()
with Flow(
f"dependent_flows_email_{current_environment}",
storage=GitHub(
repo="cityofaustin/atd-prefect",
path="flows/test/dependent_flows.py",
ref="7368-knack-banner", # The branch name
),
run_config=UniversalRun(
labels=[current_environment]
),
) as second_flow:
first_flow_run_id = create_flow_run(flow_name=first_flow.name)
first_data = get_task_run_result(first_flow_run_id, task_slug="first-slug-copy")
second_flow.add_edge(first_data, email_task(task_args=dict(msg_plain=first_data)))
if __name__ == "__main__":
second_flow.run()
Kevin Kho
02/23/2022, 7:52 PMsecond_flow.add_edge(first_data, email_task(task_args=dict(msg_plain=first_data)))
to email_task(msg_plain=first_data)
chia berry
02/23/2022, 7:54 PMemail_config = get_key_value(key="aws_email_config")
and i am successfully getting emails sent to meKevin Kho
02/23/2022, 7:54 PMtask_args
wrong. task_args
is to change the stuff like timeout=…
and max_retries=...
. Stuff that goes into the task decoratorchia berry
02/23/2022, 7:55 PMKevin Kho
02/23/2022, 7:55 PMchia berry
02/23/2022, 7:58 PMKevin Kho
02/23/2022, 8:01 PMchia berry
02/23/2022, 8:17 PMKevin Kho
02/23/2022, 8:17 PM