Skip to content

Commit

Permalink
Merge pull request #581 from openedx/cag/database-connection
Browse files Browse the repository at this point in the history
fix: import databases from settings
  • Loading branch information
Ian2012 authored Jan 30, 2024
2 parents 478fe07 + a971529 commit 3118191
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
6 changes: 2 additions & 4 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,6 @@ Aspects is implemented as a Tutor plugin. Documentation will be coming soon to c

tutor images build openedx --no-cache

#. Because we need to bake the Aspects assets (charts, datasets, dashboards) into the Superset image you will need to rebuild it::

tutor images build aspects-superset --no-cache

#. Run the initialization scripts::

tutor local do init
Expand Down Expand Up @@ -99,6 +95,8 @@ when you update your deployment. To prevent your local changes from being overwr
please create new assets and make your changes there instead. You can copy an existing
asset by editing the asset in Superset and selecting "Save As" to save it to a new name.

# Note: If you are using custom assets you will need to rebuild your aspects-superset
# image on your local machine with `tutor images build aspects-superset --no-cache`.

Sharing Charts and Dashboards
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down
7 changes: 7 additions & 0 deletions tutoraspects/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,13 @@
"mysql://{{SUPERSET_DB_USERNAME}}:{{SUPERSET_DB_PASSWORD}}"
"@{{SUPERSET_DB_HOST}}/{{SUPERSET_DB_METADATA_NAME}}",
),
(
"SUPERSET_DATABASES",
{
"OpenedX Clickhouse": "{{CLICKHOUSE_REPORT_SQLALCHEMY_URI}}",
"Superset Metadata": "{{SUPERSET_METADATA_SQLALCHEMY_URI}}",
},
),
("SUPERSET_SENTRY_DSN", ""),
(
"SUPERSET_TALISMAN_CONFIG",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,19 @@ def create_assets():
write_asset_to_file(asset, asset_name, folder, file_name, roles)
break

import_databases()
import_assets()
update_dashboard_roles(roles)
update_embeddable_uuids()


def import_databases():
"""Import databases from settings"""
databases = {{SUPERSET_DATABASES}}
for database_name, uri in databases.items():
create_superset_db(database_name, uri)


def get_uuid5(base_uuid, name):
"""Generate an idempotent uuid."""
base_uuid = uuid.UUID(base_uuid)
Expand All @@ -118,7 +126,6 @@ def get_uuid5(base_uuid, name):
def write_asset_to_file(asset, asset_name, folder, file_name, roles):
"""Write an asset to a file and generated translated assets"""
if folder == "databases":
# This will fix the URI connection string by setting the right password.
create_superset_db(asset["database_name"], asset["sqlalchemy_uri"])

if folder in ["charts", "dashboards"]:
Expand Down

0 comments on commit 3118191

Please sign in to comment.