Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

module 3.6 - adjust human in the loop implementation #142

Open
sgbaird opened this issue Jan 14, 2025 · 6 comments
Open

module 3.6 - adjust human in the loop implementation #142

sgbaird opened this issue Jan 14, 2025 · 6 comments
Assignees

Comments

@sgbaird
Copy link
Member

sgbaird commented Jan 14, 2025

I was going to share a human-in-the-loop workflow orchestration example from the robotics microcourse, and noticed a mention of it here:

https://ac-microcourses.readthedocs.io/en/latest/courses/robotics/3.6-solid-sample-transfer.html#error-handling

@task
def notify_operator(task_id):
    print(f"ALERT: Task {task_id} has failed. An operator needs to check the robot.")
    # In a real scenario, this could send an email, SMS, or trigger an alert system
    operator_response = input("Has the issue been resolved? (yes/no): ")
    return operator_response.lower() == "yes"

However, this should be using Prefect's built in functionality and should be adjusted to follow what's shown in https://youtu.be/4tnaL9ts6CQ?si=A9v8bF5LfNFekStB with slack notifications and include a link to that YouTube video.

@SissiFeng
Copy link
Contributor

SissiFeng commented Jan 14, 2025

截屏2025-01-14 17 09 06

The screenshot is a modified version. How about it?

@sgbaird
Copy link
Member Author

sgbaird commented Jan 14, 2025

Nice! Thanks for using the slack webhook. Maybe add an optional comment input from the user? (Just to show that data can be passed from the user back to the orchestrator)

@SissiFeng
Copy link
Contributor

longshot20250115094858

what about the above modification?
Added parse_slack_response function to parse user responses; simulated slack API calls and threaded response handling.

@sgbaird
Copy link
Member Author

sgbaird commented Jan 15, 2025

Similar, but not quite. The input would be by the user on the Prefect interface, not by replying on slack directly. On slack, they would get a link to the corresponding Prefect run, as shown in https://youtu.be/4tnaL9ts6CQ?si=A9v8bF5LfNFekStB

See

https://github.com/AccelerationConsortium/ac-training-lab/blob/ec10e7b99e6e220d49e5cd00e104c19343595b55/scripts/prefect_scripts/my_gh_sample_transfer_workflow.py#L43-L51

and the corresponding interface (assuming lines 46 and 47 from above are uncommented)

image

@SissiFeng
Copy link
Contributor

Image

Based on the above I made another change.

@sgbaird
Copy link
Member Author

sgbaird commented Jan 16, 2025

For clarity, remove the try except and timeout.

Either replace the input validation with pydantic, which is natively supported, or remove. See https://docs.prefect.io/v3/develop/inputs

Then should be good to go

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants