insitro / redun

Yet another redundant workflow engine
https://insitro.github.io/redun/
Apache License 2.0
520 stars 45 forks source link

Conda executor and initial example #29

Closed spitz-dan-l closed 1 year ago

spitz-dan-l commented 2 years ago

Greetings @mattrasmus and team!

This is a preliminary PR with an executor for running tasks within local conda environments. I'll be curious to hear your feedback on it!

Overview of function

Similar to the Batch executor in debug=True mode, we construct a command to call redun oneshot for tasks (or for scripts, we just use redun's existing script preparation). Then we pass that command to conda run, conda's non-interactive execution entrypoint. We maintain a pool of thread workers to actually run the commands in a subprocess and post-process the results.

Some points of discussion

I think it ought to be possible to abstract most of the machinery here into a more generic "local custom shell executor". Then you could support conda, arbitrary local virtual envs, local docker or other containers, etc.

I wasn't able to reuse any existing utility code for constructing the oneshot commands, due to how redun.executors.aws_batch.submit_task() is currently factored. However, my implementation is heavily inspired by what the batch executor does. I'd be happy to try refactoring things a bit in the interest of unification.

Have not added tests yet. I assume you don't want to add conda as a dependency so I'm planning to mock the actual subprocess calls.

Happy to answer any questions and open to all suggestions.

Cheers! Dan Spitz

adamgayoso commented 1 year ago

A conda executor would be a great addition!