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

feat: add command to dump data to clickhouse #594

Merged
merged 3 commits into from
Feb 12, 2024
Merged
Show file tree
Hide file tree
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
6 changes: 3 additions & 3 deletions .github/workflows/integration-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ jobs:
run: tutor local do importdemocourse
- name: Test commands
run: |
tutor local do dump-courses-to-clickhouse --options "--force"
tutor local do dump-data-to-clickhouse --options "--object course_overviews"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

make extract_translations
- name: Tutor stop
run: tutor local stop
Expand Down Expand Up @@ -118,7 +118,7 @@ jobs:
- name: Import demo course
run: tutor dev do importdemocourse
- name: Test commands
run: tutor dev do dump-courses-to-clickhouse --options "--force"
run: tutor dev do dump-data-to-clickhouse --options "--object course_overviews"
- name: Tutor stop
run: tutor dev stop

Expand Down Expand Up @@ -190,7 +190,7 @@ jobs:
- name: Import demo course
run: tutor k8s do importdemocourse
- name: Test commands
run: tutor k8s do dump-courses-to-clickhouse --options "--force"
run: tutor k8s do dump-data-to-clickhouse --options "--object course_overviews"
- name: Check failure logs
if: failure()
run: |
Expand Down
3 changes: 1 addition & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,7 @@ At this point you should have a working Tutor / Aspects environment, but with no

#. Sink course data from the LMS to clickhouse (see https://github.com/openedx/openedx-event-sink-clickhouse for more information)::

tutor local do dump-courses-to-clickhouse --options "--force"

tutor local do dump-data-to-clickhouse --options "--object course_overviews"

#. Sink Historical event data to ClickHouse::

Expand Down
15 changes: 8 additions & 7 deletions tutoraspects/commands_v0.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,20 +93,21 @@ def alembic(context, command) -> None:
runner.run_job("aspects", command)


@click.command(help="Dump courses to ClickHouse.")
@click.command(help="Dump data to ClickHouse.")
@click.option("--service", default="lms", help="The service to run the command on.")
@click.option("--options", default="")
@click.pass_obj
def dump_courses_to_clickhouse(context, options) -> None:
def dump_data_to_clickhouse(context, service, options) -> None:
"""
Job that proxies the dump_courses_to_clickhouse commands.
Job that proxies the dump_data_to_clickhouse commands.
"""
config = tutor_config.load(context.root)
runner = context.job_runner(config)

command = f"""
./manage.py cms dump_courses_to_clickhouse {options}
./manage.py {service} dump_data_to_clickhouse {options}
"""
runner.run_job("cms", command)
runner.run_job(f"{service}", command)


# pylint: disable=line-too-long
Expand Down Expand Up @@ -175,7 +176,7 @@ def dump_courses_to_clickhouse(context, options) -> None:
@click.pass_obj
def transform_tracking_logs(context, deduplicate, **kwargs) -> None:
"""
Job that proxies the dump_courses_to_clickhouse commands.
Job that proxies the transform_tracking_logs commands.
"""
config = tutor_config.load(context.root)
runner = context.job_runner(config)
Expand Down Expand Up @@ -210,6 +211,6 @@ def transform_tracking_logs(context, deduplicate, **kwargs) -> None:
load_xapi_test_data,
dbt,
alembic,
dump_courses_to_clickhouse,
dump_data_to_clickhouse,
transform_tracking_logs,
)
16 changes: 11 additions & 5 deletions tutoraspects/commands_v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,20 @@ def alembic(command: string) -> list[tuple[str, str]]:
]


# Ex: "tutor local do dump_courses_to_clickhouse "
# Ex: "tutor local do dump_data_to_clickhouse "
@click.command(context_settings={"ignore_unknown_options": True})
@click.option(
"--service",
default="lms",
type=click.UNPROCESSED,
help="The service to run the command on.",
)
@click.option("--options", default="", type=click.UNPROCESSED)
def dump_courses_to_clickhouse(options) -> list[tuple[str, str]]:
def dump_data_to_clickhouse(service, options) -> list[tuple[str, str]]:
"""
Job that proxies the dump_courses_to_clickhouse commands.
Job that proxies the dump_data_to_clickhouse commands.
"""
return [("cms", f"./manage.py cms dump_courses_to_clickhouse {options}")]
return [(f"{service}", f"./manage.py {service} dump_data_to_clickhouse {options}")]


# pylint: disable=line-too-long
Expand Down Expand Up @@ -272,7 +278,7 @@ def check_superset_assets():
load_xapi_test_data,
dbt,
alembic,
dump_courses_to_clickhouse,
dump_data_to_clickhouse,
transform_tracking_logs,
)

Expand Down
2 changes: 1 addition & 1 deletion tutoraspects/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
(
"OPENEDX_EXTRA_PIP_REQUIREMENTS",
[
"openedx-event-sink-clickhouse==1.0.0",
"openedx-event-sink-clickhouse==1.1.0",
"edx-event-routing-backends==v7.2.0",
],
),
Expand Down
Loading