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

fix: defer V0 init task to fix TemplateNotFound #30

Draft
wants to merge 1 commit into
base: release
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 18 additions & 7 deletions tutor/plugins/v0.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,17 +182,16 @@ def _load_tasks(self) -> None:
)
# Pre-init scripts: hooks = {"pre-init": ["myservice1", "myservice2"]}
for service in pre_init_tasks:
hooks.Filters.CLI_DO_INIT_TASKS.add_item(
(
service,
env.read_template_file(self.name, "hooks", service, "pre-init"),
),
template_path = (self.name, "hooks", service, "pre-init")
hooks.Filters.CLI_DO_INIT_TASKS.add(
_make_add_task_callback(service, template_path),
priority=hooks.priorities.HIGH,
)
# Init scripts: hooks = {"init": ["myservice1", "myservice2"]}
for service in init_tasks:
hooks.Filters.CLI_DO_INIT_TASKS.add_item(
(service, env.read_template_file(self.name, "hooks", service, "init"))
template_path = (self.name, "hooks", service, "init")
hooks.Filters.CLI_DO_INIT_TASKS.add(
_make_add_task_callback(service, template_path),
)

def _load_templates_root(self) -> None:
Expand Down Expand Up @@ -236,6 +235,18 @@ def _version(self) -> t.Optional[str]:
return None


def _make_add_task_callback(service: str, path: list[str]):
"""
TODO
"""
def add_task_callback(tasks: list[tuple[str, str]]) -> list[tuple[str, str]]:
new_task = (service, env.read_template_file(*path))
tasks.append(new_task)
return tasks
return add_task_callback



class EntrypointPlugin(BasePlugin):
"""
Entrypoint plugins are regular python packages that have a 'tutor.plugin.v0' entrypoint.
Expand Down