Skip to content

Commit 9f75ac4

Browse files
committed
feat: backfill course data at start up
1 parent fa75965 commit 9f75ac4

File tree

6 files changed

+38
-3
lines changed

6 files changed

+38
-3
lines changed

README.rst

+4
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@ Usage
5858

5959
tutor [dev|local] do load-xapi-test-data
6060

61+
#. (Optional) Sink course data from the LMS to clickhouse (see `https://github.com/openedx/openedx-event-sink-clickhouse` for more information)::
62+
63+
tutor [dev|local] do dump-courses-to-clickhouse --options "--force"
64+
6165

6266
Superset Assets
6367
---------------

tutoraspects/commands_v0.py

+21-1
Original file line numberDiff line numberDiff line change
@@ -92,4 +92,24 @@ def alembic(context, command) -> None:
9292
runner.run_job("aspects", command)
9393

9494

95-
COMMANDS = (load_xapi_test_data, dbt, alembic)
95+
@click.option("--options", default="")
96+
@click.pass_obj
97+
def dump_courses_to_clickhouse(context, options) -> None:
98+
"""
99+
Job that proxies the dump_courses_to_clickhouse commands.
100+
"""
101+
config = tutor_config.load(context.root)
102+
runner = context.job_runner(config)
103+
104+
command = f"""
105+
./manage.py cms dump_courses_to_clickhouse {options}
106+
"""
107+
runner.run_job("cms", command)
108+
109+
110+
COMMANDS = (
111+
load_xapi_test_data,
112+
dbt,
113+
alembic,
114+
dump_courses_to_clickhouse,
115+
)

tutoraspects/commands_v1.py

+11
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,19 @@ def alembic(command: string) -> list[tuple[str, str]]:
9494
]
9595

9696

97+
# Ex: "tutor local do dump_courses_to_clickhouse "
98+
@click.command(context_settings={"ignore_unknown_options": True})
99+
@click.option("--options", default="", type=click.UNPROCESSED)
100+
def dump_courses_to_clickhouse(options) -> list[tuple[str, str]]:
101+
"""
102+
Job that proxies the dump_courses_to_clickhouse commands.
103+
"""
104+
return [("cms", f"./manage.py cms dump_courses_to_clickhouse {options}")]
105+
106+
97107
COMMANDS = (
98108
load_xapi_test_data,
99109
dbt,
100110
alembic,
111+
dump_courses_to_clickhouse,
101112
)

tutoraspects/plugin.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -323,11 +323,11 @@
323323
# and then add it to the MY_INIT_TASKS list. Each task is in the format:
324324
# ("<service>", ("<path>", "<to>", "<script>", "<template>"))
325325
MY_INIT_TASKS: list[tuple[str, tuple[str, ...], int]] = [
326-
("mysql", ("aspects", "jobs", "init", "superset", "init-mysql.sh"), 92),
326+
("mysql", ("aspects", "jobs", "init", "init-mysql.sh"), 92),
327327
("clickhouse", ("aspects", "jobs", "init", "clickhouse", "init-clickhouse.sh"), 93),
328328
("aspects", ("aspects", "jobs", "init", "aspects", "init-aspects.sh"), 94),
329329
("superset", ("aspects", "jobs", "init", "superset", "init-superset.sh"), 95),
330-
("lms", ("aspects", "jobs", "init", "superset", "init-openedx.sh"), 96),
330+
("lms", ("aspects", "jobs", "init", "init-lms.sh"), 96),
331331
]
332332

333333
# For each task added to MY_INIT_TASKS, we load the task template

0 commit comments

Comments
 (0)