-
Notifications
You must be signed in to change notification settings - Fork 0
Create a pluggable "jobs"/"tasks" interface #75
Comments
tutor tasks
interface
@regisb Lower priority, but when you have time, can you look at this issue as well as its sister issue and let me know what you think of the proposed solutions? |
Note that solution 2) is now possible, as plugins can render files outside of their own plugin folder. Still, I think that solution is not the best one because (as you mentioned) users need to rebuild their Docker images. Also, the same solution cannot be applied to images other than openedx. I think that solution 1) is the best, with one caveat: each task should support running multiple commands in different containers. Thus, the filter signature would be: |
@regisb Sounds good! I'll get to work on this sooner than later since it affects a couple other open issues. Here's the Filter doc I'll work off of. I came up with a slightly different type signature than you: I have #: List command line interface (CLI) tasks.
#:
#: :parameter list[tuple[str, list[tuple[str, str]]]] tasks:
#:
#: A list of (``task_name``, ``task_commands``) tuples. Each tuple describes a CLI task:
#:
#: - ``task_name`` is the string used to invoke the task on the CLI, e.g. ``tutor local task <task_name>``
#: - ``task_commands`` are a list of (``service``, ``command``) tuples. When the task
#: is invoked, each shell ``command`` in the list will be run in its corresponding ``service``.
CLI_TASKS = filters.get("cli:tasks") |
Oh, and @regisb , what exact syntax do you prefer? Considering a task named "dostuff", we could have:
I have slight lean towards 2 or 4, because they follow the general The other nice thing about form 4 is that we could implement built-in things like |
Yes it does, and it's more elegant. 👌
Hmmm I'm not sure. Implementing (4) would be awkward because the "dostuff" task would need to be added as a subcommand of the "local" group. "runtask dostuff" would work, but... consider the case when we want to do more with tasks than just executing them. For instance, we might want to print out a list of available tasks. To do that we would have to run I guess that the "logical" way of running a task would be with
But that 4th level command is really a mouthful... I'm not being very constructive here... To summarize, I'd like to use
If we go with "do" I feel like "job" is a better noun than "task". Long story short: I don't have a very strong opinion here. I'll trust your judgement. |
@regisb If we called them "jobs" would that conflict with the existing meaning of "job" in Tutor? |
I like this syntax. I'll start work on it. |
@regisb I've begun work on this and found it to be a very interesting feature. You can see my progress and notes here: kdmccormick/tutor#13 |
A few notes for anyone following along:
Also, I've been thinking about the terminology. To me, a "task" seems like a part of a "job" (the GitHub Actions YAML schema agrees). So, I think:
As for the filter names and schemas, I am leaning:
|
@regisb will be taking it from here. |
We introduce a new filter to implement custom commands in arbitrary containers. It becomes easy to write convenient ad-hoc commands that users will then be able to run either on Kubernetes or locally using a documented CLI. Pluggable jobs are declared as Click commands and are responsible for parsing their own arguments. See the new CLI_DO_COMMANDS filter. Close openedx-unsupported/wg-developer-experience#75
We introduce a new filter to implement custom commands in arbitrary containers. It becomes easy to write convenient ad-hoc commands that users will then be able to run either on Kubernetes or locally using a documented CLI. Pluggable jobs are declared as Click commands and are responsible for parsing their own arguments. See the new CLI_DO_COMMANDS filter. Close openedx-unsupported/wg-developer-experience#75
We introduce a new filter to implement custom commands in arbitrary containers. It becomes easy to write convenient ad-hoc commands that users will then be able to run either on Kubernetes or locally using a documented CLI. Pluggable jobs are declared as Click commands and are responsible for parsing their own arguments. See the new CLI_DO_COMMANDS filter. Close openedx-unsupported/wg-developer-experience#75
We introduce a new filter to implement custom commands in arbitrary containers. It becomes easy to write convenient ad-hoc commands that users will then be able to run either on Kubernetes or locally using a documented CLI. Pluggable jobs are declared as Click commands and are responsible for parsing their own arguments. See the new CLI_DO_COMMANDS filter. Close openedx-unsupported/wg-developer-experience#75
We introduce a new filter to implement custom commands in arbitrary containers. It becomes easy to write convenient ad-hoc commands that users will then be able to run either on Kubernetes or locally using a documented CLI. Pluggable jobs are declared as Click commands and are responsible for parsing their own arguments. See the new CLI_DO_COMMANDS filter. Close openedx-unsupported/wg-developer-experience#75
We introduce a new filter to implement custom commands in arbitrary containers. It becomes easy to write convenient ad-hoc commands that users will then be able to run either on Kubernetes or locally using a documented CLI. Pluggable jobs are declared as Click commands and are responsible for parsing their own arguments. See the new CLI_DO_COMMANDS filter. Close openedx-unsupported/wg-developer-experience#75
This is complete. |
Context
Originally discussed here: overhangio/tutor#643 (comment) .
Problem
There is no perfect way for Tutor or its plugins to define "tasks" (initialization tasks, setup tasks, test data provisioning, whatever) to be run within containers
Of course, Tutor/plugins can define runnable scripts by putting them in their own services' /openedx/bin folder; for example, Tutor adds /openedx/bin/openedx-assets to the openedx image, allowing us to run
tutor dev run openedx-assets build
. However, this only works within the plugin that defines the image's Dockerfile. One could not easily write a plugin that runs data management commands in the LMS container, because the openedx Dockerfile is in Tutor core, which plugins cannot easily add scripts to.Relevant issues:
Proposals
(For what it's worth: I like proposal 1 better, and I'm not sure proposal 2 would even work. I just want to make sure we're considering existing extension points before adding a new one.)
1. Introduce a
tasks
subcommand and filtertutor dev tasks ...
.tutor MODE tasks TASKNAME [ARGS...]
would:TASKNAME
fromCLI_TASKS
in order to find the list of(service, command)
pairs.command
withinservice
docker-compose run
for dev/local, and usekubectl exec
for k8s.2. Allow plugins to add files to the openedx build context
Currently, plugin templates are all rendered into
$(tutor config printroot)/env/plugins/
folder. The openedx Docker image is built from$(tutor config printroot)/env/build/openedx/
. So, plugins cannot possibly add new templates that would be rendered into the openedx build context.But what if they could? What if the openedx Docker build context was at, say,
$(tutor config printroot)/env/plugins/tutor-openedx/build
? I think a plugin could then define a script atmyplugin/templates/tutor-openedx/build/bin/my-cool-task-script
, for the openedx Dockerfile to make available when it runs:The task would be runnable via:
A large, obvious downside to this is that it would require an image rebuild.
Acceptance Criteria
Per discussion below, implement Proposal 1.
The text was updated successfully, but these errors were encountered: