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

Await "on batch" callback before allowing admin to run the batch #416

Open
2 tasks done
JamesPHoughton opened this issue Sep 29, 2023 · 0 comments
Open
2 tasks done
Labels
enhancement New feature or request

Comments

@JamesPHoughton
Copy link
Contributor

JamesPHoughton commented Sep 29, 2023

Is there an existing issue for this?

  • I have searched the existing issues

Is your feature request related to a problem?

Currently I'm using a callback when a batch is created to do a bunch of initialization stuff, in an async way:

Empirica.on("batch", async (ctx, { batch }) => {
  // fetch data
  // check that I have all the required resources
  // check configs
  // validate the treatment
  // etc.
}

the problem (and its a small one) is that I can start the batch (and run all the batch start callbacks) before this has finished. Then, if the batch start callback is expecting the batch creation callback to have finished its initialization stuff, it either can check for initialization and intentionally go to a "failed" state batch.set("status", "failed") or (more likely, as I assumed the initialization had finished) behave unpredictably.

Describe the solution you'd like

Possibly create an additional state a batch can be in that is created by not ready to start yet. (Initializing?) that gets set when the batch creation callback resolves.

Describe alternatives you've considered

Currently I manually check that initialization has finished in the batch start callback, and if it has not, fail the batch.

Teachability, Documentation, Adoption, Migration Strategy

Should be transparent to most users.

Code of Conduct

  • I agree to follow this project's Code of Conduct
@JamesPHoughton JamesPHoughton added the enhancement New feature or request label Sep 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant