mirror of
https://github.com/ChristianLight/tutor.git
synced 2024-06-27 17:03:29 +00:00
16e6131f96
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 https://github.com/overhangio/2u-tutor-adoption/issues/75
31 lines
794 B
Python
31 lines
794 B
Python
from tutor.tasks import BaseTaskRunner
|
|
from tutor.types import Config
|
|
|
|
|
|
class Context:
|
|
"""
|
|
Context object that is passed to all subcommands.
|
|
|
|
The project `root` is passed to all subcommands of `tutor`; that's because
|
|
it is defined as an argument of the top-level command. For instance:
|
|
|
|
$ tutor --root=... local run ...
|
|
"""
|
|
|
|
def __init__(self, root: str) -> None:
|
|
self.root = root
|
|
|
|
|
|
class BaseTaskContext(Context):
|
|
"""
|
|
Specialized context that subcommands may use.
|
|
|
|
For instance `dev`, `local` and `k8s` define custom runners to run jobs.
|
|
"""
|
|
|
|
def job_runner(self, config: Config) -> BaseTaskRunner:
|
|
"""
|
|
Return a runner capable of running docker-compose/kubectl commands.
|
|
"""
|
|
raise NotImplementedError
|