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

Wish: Programmatic workflow management #906

Open
pringshia opened this issue Oct 3, 2022 · 0 comments
Open

Wish: Programmatic workflow management #906

pringshia opened this issue Oct 3, 2022 · 0 comments
Milestone

Comments

@pringshia
Copy link
Contributor

pringshia commented Oct 3, 2022

It may be nice to have a programmatic approach to designing workflows for a task. Here's an example:

# when a worker accepts a task, a stateful workflow
# method gets called, which yields task data

async def workflow(state):

  state.set("role", lambda: random("speaker", "listener"))

  # throws if worker fails onboarding, no more tasks sent:
  assert await onboarding_task()
  for x in range(3):
    for n in range(10):
      await task(state.role)
    # throws if worker fails gold task, no more tasks sent:
    assert await gold_task()

Some implementation notes

The workflow method is designed to be resumable. This means that it needs to keep track of state. It also means that "side-effects" are cached. For example, the first time a user accepts a HIT, the await suspends for onboarding_task. The next time a user accepts a HIT, the await is instantaneous for onboarding_task because the workflow fn is state-aware and caches the previous result.

  • Open question: do we allow users to modify the file in between runs? That could mess things up big time, and cause inconsistencies
@pringshia pringshia added this to the Mephisto X.0 milestone Oct 3, 2022
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

1 participant