Skip to content

Commit

Permalink
fix: address suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
Henrrypg committed Oct 27, 2023
1 parent 6cb9e6c commit f6fecc5
Show file tree
Hide file tree
Showing 36 changed files with 59 additions and 43 deletions.
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ To contribute assets to Aspects:
their actual SQL. If you haven't changed the SQL of these queries (stored in
`tutoraspects/templates/openedx-assets/queries` you can just revert that change back
to their `include` values such as:
`sql: "{% include 'aspects/build/aspects-superset/openedx-assets/queries/fact_enrollments_by_day.sql' %}"`
`sql: "{% include 'openedx-assets/queries/fact_enrollments_by_day.sql' %}"`
#. The script will also warn about missing `_roles` in dashboards. Superset does not export
these, so you will need to manually add this key with the roles that are necessary to
view the dashboard. See the existing dashboards for how this is done.
Expand All @@ -172,7 +172,7 @@ To make it easier for developers to manage virtual datasets, there is an extra s

.. code-block:: yaml
sql: "{% include 'aspects/build/aspects-superset/openedx-assets/queries/query.sql' %}"
sql: "{% include 'openedx-assets/queries/query.sql' %}"
However, please keep in mind that the assets declaration is itself a jinja template. That means that any jinja used in the dataset definition should be escaped. There are examples of how to handle this in the existing queries, such as `dim_courses.sql`_.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,15 @@ def create_assets():
continue

# Process the asset directly
if FILE_NAME_ATTRIBUTE in asset:
file_name = asset.pop(FILE_NAME_ATTRIBUTE)

# Find the right folder to create the asset in
for asset_name, folder in ASSET_FOLDER_MAPPING.items():
if asset_name in asset:
write_asset_to_file(asset, asset_name, folder, file_name, roles)
break
if FILE_NAME_ATTRIBUTE not in asset:
raise Exception(f"Asset {asset} has no {FILE_NAME_ATTRIBUTE}")
file_name = asset.pop(FILE_NAME_ATTRIBUTE)

# Find the right folder to create the asset in
for asset_name, folder in ASSET_FOLDER_MAPPING.items():
if asset_name in asset:
write_asset_to_file(asset, asset_name, folder, file_name, roles)
break

with open(ASSETS_FILE_PATH, "r") as file:
extra_assets = yaml.safe_load(file)
Expand Down
15 changes: 15 additions & 0 deletions tutoraspects/templates/aspects/apps/superset/pythonpath/test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import yaml

def func():
with open("./xx.yml", "r") as file:
extra_assets = yaml.safe_load(file)

if not extra_assets:
return

# For each asset, create a file in the right folder
print("yes")

print ("no")

func()
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ normalize_columns: true
offset: 0
params: null
schema: main
sql: "{% include 'aspects/build/aspects-superset/openedx-assets/queries/dim_course_problems.sql' %}"
sql: "{% include 'openedx-assets/queries/dim_course_problems.sql' %}"
table_name: dim_course_problems
template_params: {}
uuid: 008e2907-fc6b-45ef-bf85-73a04c5791ff
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ normalize_columns: true
offset: 0
params: null
schema: main
sql: "{% include 'aspects/build/aspects-superset/openedx-assets/queries/dim_course_videos.sql' %}"
sql: "{% include 'openedx-assets/queries/dim_course_videos.sql' %}"
table_name: dim_course_videos
template_params: {}
uuid: 417b2035-8fa1-4c60-a405-4b1947c3c966
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ normalize_columns: true
offset: 0
params: null
schema: main
sql: "{% include 'aspects/build/aspects-superset/openedx-assets/queries/fact_course_grades.sql' %}"
sql: "{% include 'openedx-assets/queries/fact_course_grades.sql' %}"
table_name: fact_course_grades
template_params: {}
uuid: d777bd95-2110-46db-a1c4-8358be81a85a
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ normalize_columns: true
offset: 0
params: null
schema: main
sql: "{% include 'aspects/build/aspects-superset/openedx-assets/queries/fact_enrollments.sql' %}"
sql: "{% include 'openedx-assets/queries/fact_enrollments.sql' %}"
table_name: fact_enrollments
template_params: {}
uuid: a234545d-08ff-480d-8361-961c3d15f14f
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ normalize_columns: true
offset: 0
params: null
schema: main
sql: "{% include 'aspects/build/aspects-superset/openedx-assets/queries/fact_enrollments_by_day.sql' %}"
sql: "{% include 'openedx-assets/queries/fact_enrollments_by_day.sql' %}"
table_name: fact_enrollments_by_day
template_params: {}
uuid: 352311fe-12f0-470c-8b8c-d4f6a3936b3d
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ normalize_columns: true
offset: 0
params: null
schema: main
sql: "{% include 'aspects/build/aspects-superset/openedx-assets/queries/fact_forum_interactions.sql' %}"
sql: "{% include 'openedx-assets/queries/fact_forum_interactions.sql' %}"
table_name: fact_forum_interactions
template_params: {}
uuid: 39d1e786-c0c8-4c56-81c8-56fb0df88001
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ normalize_columns: true
offset: 0
params: null
schema: main
sql: "{% include 'aspects/build/aspects-superset/openedx-assets/queries/fact_learner_problem_course_summary.sql' %}"
sql: "{% include 'openedx-assets/queries/fact_learner_problem_course_summary.sql' %}"
table_name: fact_learner_problem_course_summary
template_params: null
uuid: 981f30d9-b2f0-4a0b-9e95-0ee0e06db806
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ normalize_columns: true
offset: 0
params: null
schema: main
sql: "{% include 'aspects/build/aspects-superset/openedx-assets/queries/fact_learner_problem_summary.sql' %}"
sql: "{% include 'openedx-assets/queries/fact_learner_problem_summary.sql' %}"
table_name: fact_learner_problem_summary
template_params: null
uuid: 9362354c-1541-43c2-b769-da9818236298
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ normalize_columns: true
offset: 0
params: null
schema: main
sql: "{% include 'aspects/build/aspects-superset/openedx-assets/queries/fact_problem_grades.sql' %}"
sql: "{% include 'openedx-assets/queries/fact_problem_grades.sql' %}"
table_name: fact_problem_grades
template_params: {}
uuid: b31154e0-afed-4445-b90d-a501d555784e
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ normalize_columns: true
offset: 0
params: null
schema: main
sql: "{% include 'aspects/build/aspects-superset/openedx-assets/queries/fact_problem_responses.sql' %}"
sql: "{% include 'openedx-assets/queries/fact_problem_responses.sql' %}"
table_name: fact_problem_responses
template_params: null
uuid: 511dd5f1-3925-4e9e-ad8a-a227b5680047
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ normalize_columns: true
offset: 0
params: null
schema: main
sql: "{% include 'aspects/build/aspects-superset/openedx-assets/queries/fact_transcript_usage.sql' %}"
sql: "{% include 'openedx-assets/queries/fact_transcript_usage.sql' %}"
table_name: fact_transcript_usage
template_params: {}
uuid: a96a4b13-a429-442d-83ca-5d6f94010909
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ normalize_columns: true
offset: 0
params: null
schema: main
sql: "{% include 'aspects/build/aspects-superset/openedx-assets/queries/fact_video_plays.sql' %}"
sql: "{% include 'openedx-assets/queries/fact_video_plays.sql' %}"
table_name: fact_video_plays
template_params: {}
uuid: 6ec360a5-e247-42e7-b301-fa8275fc93f9
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ normalize_columns: true
offset: 0
params: null
schema: main
sql: "{% include 'aspects/build/aspects-superset/openedx-assets/queries/fact_watched_video_segments.sql' %}"
sql: "{% include 'openedx-assets/queries/fact_watched_video_segments.sql' %}"
table_name: fact_watched_video_segments
template_params: null
uuid: c2c391b3-3403-4f05-bc0b-3de53bd366ec
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ normalize_columns: true
offset: 0
params: null
schema: main
sql: "{% include 'aspects/build/aspects-superset/openedx-assets/queries/hints_per_success.sql' %}"
sql: "{% include 'openedx-assets/queries/hints_per_success.sql' %}"
table_name: hints_per_success
template_params: null
uuid: a5db584d-c8dd-4acc-889e-074288c38433
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ normalize_columns: true
offset: 0
params: null
schema: main
sql: "{% include 'aspects/build/aspects-superset/openedx-assets/queries/posts_per_user.sql' %}"
sql: "{% include 'openedx-assets/queries/posts_per_user.sql' %}"
table_name: posts_per_user
template_params: {}
uuid: a2823d2e-54c4-4378-98c2-817f000c14ab
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ with grades as (
and 0=1
{% endif %}
{% endraw %}
{% include 'aspects/build/aspects-superset/openedx-assets/queries/common_filters.sql' %}
{% include 'openedx-assets/queries/common_filters.sql' %}
),
most_recent_grades as (
select
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ select *
from {{ DBT_PROFILE_TARGET_DATABASE }}.fact_enrollments
where
1=1
{% include 'aspects/build/aspects-superset/openedx-assets/queries/common_filters.sql' %}
{% include 'openedx-assets/queries/common_filters.sql' %}
)

select
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
with enrollments as (
{% include 'aspects/build/aspects-superset/openedx-assets/queries/fact_enrollments.sql' %}
{% include 'openedx-assets/queries/fact_enrollments.sql' %}
), enrollments_ranked as (
select
emission_time,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
select *
from {{ DBT_PROFILE_TARGET_DATABASE }}.fact_forum_interactions
where 1=1
{% include 'openedx-assets/queries/common_filters.sql' %}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
WITH problem_responses AS (
{% include 'aspects/build/aspects-superset/openedx-assets/queries/int_problem_responses.sql' %}
{% include 'openedx-assets/queries/int_problem_responses.sql' %}
), outcomes AS (
SELECT
emission_time,
Expand Down Expand Up @@ -116,7 +116,7 @@ WITH problem_responses AS (
and emission_time < '{{ to_dttm }}'
{% endif %}
{% endraw %}
{% include 'aspects/build/aspects-superset/openedx-assets/queries/common_filters.sql' %}
{% include 'openedx-assets/queries/common_filters.sql' %}
)

SELECT
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
WITH problem_responses AS (
{% include 'aspects/build/aspects-superset/openedx-assets/queries/int_problem_responses.sql' %}
{% include 'openedx-assets/queries/int_problem_responses.sql' %}
), outcomes AS (
SELECT
emission_time,
Expand Down Expand Up @@ -100,7 +100,7 @@ WITH problem_responses AS (
FROM {{ DBT_PROFILE_TARGET_DATABASE }}.int_problem_hints
WHERE
1=1
{% include 'aspects/build/aspects-superset/openedx-assets/queries/common_filters.sql' %}
{% include 'openedx-assets/queries/common_filters.sql' %}
)

SELECT
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ with grades as (
{% endif %}
{% endraw %}

{% include 'aspects/build/aspects-superset/openedx-assets/queries/common_filters.sql' %}
{% include 'openedx-assets/queries/common_filters.sql' %}
),
most_recent_grades as (
select
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
with problem_responses as (
{% include 'aspects/build/aspects-superset/openedx-assets/queries/int_problem_responses.sql' %}
{% include 'openedx-assets/queries/int_problem_responses.sql' %}
)

select
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ where
0=1
{% endif %}
{% endraw %}
{% include 'aspects/build/aspects-superset/openedx-assets/queries/common_filters.sql' %}
{% include 'openedx-assets/queries/common_filters.sql' %}
)

select
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ where
1=0
{% endif %}
{% endraw %}
{% include 'aspects/build/aspects-superset/openedx-assets/queries/common_filters.sql' %}
{% include 'openedx-assets/queries/common_filters.sql' %}
)

select
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ with video_events as (
video_position
from {{ ASPECTS_XAPI_DATABASE }}.{{ ASPECTS_VIDEO_PLAYBACK_EVENTS_TABLE }}
where 1=1
{% include 'aspects/build/aspects-superset/openedx-assets/queries/common_filters.sql' %}
{% include 'openedx-assets/queries/common_filters.sql' %}
), starts as (
select *
from video_events
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
with summary as (
{% include 'aspects/build/aspects-superset/openedx-assets/queries/fact_learner_problem_summary.sql' %}
{% include 'openedx-assets/queries/fact_learner_problem_summary.sql' %}
)

select
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ with problem_responses as (
select *
from {{ DBT_PROFILE_TARGET_DATABASE }}.fact_problem_responses
where 1=1
{% include 'aspects/build/aspects-superset/openedx-assets/queries/common_filters.sql' %}
{% include 'openedx-assets/queries/common_filters.sql' %}
)

select
Expand Down

0 comments on commit f6fecc5

Please sign in to comment.