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

upgrade to redwood #39

Closed
wants to merge 6 commits into from
Closed
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
15 changes: 15 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,21 @@ Postgresql/Superset settings
- ``CAIRN_POSTGRESQL_PASSWORD`` (default: ``"{{ 20|random_string }}"``): Postgresql password.
- ``CAIRN_SUPERSET_SECRET_KEY`` (default: ``"{{ 20|random_string }}"``): randomly-generated secret key for the Superset frontend.

Add/Update Superset Configurations
----------------------------------

Use ``cairn-superset-settings`` patch to add or update `Superset configurations <https://github.com/apache/superset/blob/master/superset/config.py>`__.

e.g, to customize visualizations, add following configurations in ``cairn-superset-settings`` patch::

APP_NAME = "<APP_NAME>"
APP_ICON = "<APP_ICON>"
APP_ICON_WIDTH = <APP_ICON_WIDTH>

Then apply changes with::

tutor local launch

Troubleshooting
---------------

Expand Down
1 change: 1 addition & 0 deletions changelog.d/20240416_165758_fahad.khalid.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- [Improvement] Added CORS for embeded Dashboards. (by @Fahadkhalid210)
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- 💥[Feature] Upgrade Clickhouse version to `24.1.8.22` and fix query issues due to deprecation of Live views. (by @Fahadkhalid210)
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
RENAME TABLE _openedx_course_enrollments TO openedx_course_enrollments;
RENAME TABLE _openedx_user_profiles TO openedx_user_profiles;
RENAME TABLE _openedx_users TO openedx_users;

DROP TABLE course_enrollments;
CREATE VIEW course_enrollments AS
SELECT
openedx_course_enrollments.course_id AS course_id,
openedx_course_enrollments.created AS enrollment_created,
openedx_course_enrollments.is_active AS enrollment_is_active,
openedx_course_enrollments.mode AS enrollment_mode,
openedx_course_enrollments.user_id AS user_id,
openedx_users.username AS username,
openedx_users.email AS user_email,
openedx_user_profiles.year_of_birth AS user_year_of_birth,
openedx_user_profiles.gender AS user_gender,
openedx_user_profiles.level_of_education AS user_level_of_education,
openedx_user_profiles.city AS user_city,
openedx_user_profiles.state AS user_state,
openedx_user_profiles.country AS user_country
FROM openedx_course_enrollments
INNER JOIN openedx_user_profiles ON openedx_course_enrollments.user_id = openedx_user_profiles.user_id
INNER JOIN openedx_users ON openedx_course_enrollments.user_id = openedx_users.id;
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
RENAME TABLE _openedx_block_completion TO openedx_block_completion;

DROP TABLE course_block_completion;

CREATE VIEW course_block_completion AS
SELECT
openedx_block_completion.course_key AS course_id,
openedx_block_completion.block_key AS block_key,
openedx_block_completion.user_id AS user_id,
openedx_block_completion.completion AS completion,
course_blocks.position as position,
course_blocks.display_name as display_name,
course_blocks.full_name as full_name
FROM openedx_block_completion
INNER JOIN course_blocks ON openedx_block_completion.block_key = course_blocks.block_key;
17 changes: 15 additions & 2 deletions tutorcairn/templates/cairn/apps/superset/superset_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,17 +84,22 @@
db=REDIS_CACHE_DB,
key_prefix="superset_results",
)
OPENEDX_LMS_ROOT_URL = "{% if ENABLE_HTTPS %}https{% else %}http{% endif %}://{{ LMS_HOST }}"
OPENEDX_CMS_ROOT_URL = "{% if ENABLE_HTTPS %}https{% else %}http{% endif %}://{{ CMS_HOST }}"

if os.environ.get("FLASK_ENV") == "development":
OPENEDX_LMS_ROOT_URL = "http://{{ LMS_HOST }}:8000"
OPENEDX_CMS_ROOT_URL = "http://{{ CMS_HOST }}:8001"

{% if CAIRN_ENABLE_SSO %}
# Authentication
# https://superset.apache.org/docs/installation/configuring-superset/#custom-oauth2-configuration
# https://flask-appbuilder.readthedocs.io/en/latest/security.html#authentication-oauth
from flask_appbuilder.security.manager import AUTH_OAUTH
AUTH_TYPE = AUTH_OAUTH
OPENEDX_LMS_ROOT_URL = "{% if ENABLE_HTTPS %}https{% else %}http{% endif %}://{{ LMS_HOST }}"

OPENEDX_SSO_CLIENT_ID = "{{ CAIRN_SSO_CLIENT_ID }}"
if os.environ.get("FLASK_ENV") == "development":
OPENEDX_LMS_ROOT_URL = "http://{{ LMS_HOST }}:8000"
OPENEDX_SSO_CLIENT_ID = "{{ CAIRN_SSO_CLIENT_ID }}-dev"
OAUTH_PROVIDERS = [
{
Expand Down Expand Up @@ -162,4 +167,12 @@ class CeleryConfig: # pylint: disable=too-few-public-methods
"EMBEDDED_SUPERSET": True
}

ENABLE_CORS=True
CORS_OPTIONS={
"origins": [
f"{OPENEDX_LMS_ROOT_URL}",
f"{OPENEDX_CMS_ROOT_URL}"
],
}

{{ patch("cairn-superset-settings") }}
9 changes: 2 additions & 7 deletions tutorcairn/templates/cairn/build/cairn-clickhouse/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
# https://hub.docker.com/r/yandex/clickhouse-server/tags
FROM docker.io/yandex/clickhouse-server:22.1.3.7
# https://hub.docker.com/r/clickhouse/clickhouse-server/tags
FROM docker.io/clickhouse/clickhouse-server:24.1.8.22

# The clickhouse repo is currently unavailable in some parts of the world. If we don't
# remove this repo here then `apt update` will fail. Check if the problem is resolved with:
# curl https://repo.yandex.ru/clickhouse/deb/stable/
# The above command should be a 200, and not a 404.
RUN rm /etc/apt/sources.list.d/clickhouse.list
RUN apt update && apt install -y python3
COPY ./scripts /scripts
RUN chmod a+x /scripts/*
Expand Down
16 changes: 11 additions & 5 deletions tutorcairn/templates/cairn/build/cairn-superset/cairn/bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,17 @@ def grant_clickhouse_row_based_access(clickhouse_username, course_ids=None):
for table in make_clickhouse_query("SHOW TABLES").split("\n"):
if not table.startswith("_"):
make_clickhouse_query(
f"""GRANT SELECT ON {table} TO '{clickhouse_username}';"""
)
make_clickhouse_query(
f"""CREATE ROW POLICY OR REPLACE '{clickhouse_username}' ON {table} AS RESTRICTIVE FOR SELECT USING {condition} TO '{clickhouse_username}';"""
)
f"""GRANT SELECT ON {table} TO '{clickhouse_username}';"""
)

if table in ["openedx_users", "openedx_user_profiles", "openedx_block_completion"]:
make_clickhouse_query(
f"""CREATE ROW POLICY OR REPLACE '{clickhouse_username}' ON {table} AS RESTRICTIVE FOR SELECT USING 1 TO '{clickhouse_username}';"""
)
else:
make_clickhouse_query(
f"""CREATE ROW POLICY OR REPLACE '{clickhouse_username}' ON {table} AS RESTRICTIVE FOR SELECT USING {condition} TO '{clickhouse_username}';"""
)


def make_clickhouse_query(query):
Expand Down
Loading