Add option to publish metadata to GCS to entrypoint script

This commit is contained in:
Anna Scholtz 2020-04-03 16:41:05 -07:00
Родитель 750738898d
Коммит f3a6d7c490
6 изменённых файлов: 15 добавлений и 10 удалений

Просмотреть файл

@ -55,6 +55,8 @@ class Metadata:
try:
metadata = yaml.safe_load(yaml_stream)
print(metadata["friendly_name"])
friendly_name = metadata.get("friendly_name", None)
description = metadata.get("description", None)

Просмотреть файл

@ -33,6 +33,12 @@ elif [ "$1" = "query" ]; then
# For queries with public_json set in the metadata, the results will be
# exported as JSON to Cloud storage.
python script/publish_public_data_json --query_file="${@: -1}" ${@:1:$#-1}
elif [ "$1" = "publish_gcs_metadata" ]; then
# For an invocation like:
# publish_gcs_metadata [options]
# we dispatch to a script that publishes metadata files to GCS for datasets
# that have previsously been made public on GCS.
exec script/publish_public_data_gcs_metadata ${@:2}
elif [ "$XCOM_PUSH" = "true" ]; then
# KubernetesPodOperator will extract the contents of /airflow/xcom/return.json as an xcom
# if the xcom_push parameter is true

Просмотреть файл

@ -1 +1 @@
{"test": {"non_incremental_query": {"v1": {"friendly_name": "Test table for a non-incremental query\n", "description": "Test table for a non-incremental query\n", "incremental": false, "incremental_export": false, "review_link": "https://bugzilla.mozilla.org/show_bug.cgi?id=1999999", "files_uri": "http://test.endpoint.mozilla.com/api/v1/tables/test/non_incremental_query/v1/files"}}, "incremental_query": {"v1": {"friendly_name": "Test table for an incremental query", "description": "Test table for an incremental query\n", "incremental": true, "incremental_export": true, "files_uri": "http://test.endpoint.mozilla.com/api/v1/tables/test/incremental_query/v1/files"}}}}
{"test": {"non_incremental_query": {"v1": {"friendly_name": "Test table for a non-incremental query", "description": "Test table for a non-incremental query", "incremental": false, "incremental_export": false, "review_link": "https://bugzilla.mozilla.org/show_bug.cgi?id=1999999", "files_uri": "http://test.endpoint.mozilla.com/api/v1/tables/test/non_incremental_query/v1/files"}}, "incremental_query": {"v1": {"friendly_name": "Test table for an incremental query", "description": "Test table for an incremental query", "incremental": true, "incremental_export": true, "files_uri": "http://test.endpoint.mozilla.com/api/v1/tables/test/incremental_query/v1/files"}}}}

Просмотреть файл

@ -84,8 +84,8 @@ class TestPublishGcsMetadata(object):
result = gcs_table_metadata.table_metadata_to_json()
assert len(result.items()) == 6
assert result["description"] == "Test table for a non-incremental query\n"
assert result["friendly_name"] == "Test table for a non-incremental query\n"
assert result["description"] == "Test table for a non-incremental query"
assert result["friendly_name"] == "Test table for a non-incremental query"
assert result["incremental"] == False
assert result["incremental_export"] == False
assert (

Просмотреть файл

@ -1,6 +1,5 @@
friendly_name: Test table for an incremental query
description: >
Test table for an incremental query
friendly_name: "Test table for an incremental query"
description: "Test table for an incremental query"
owners:
- ascholtz@mozilla.com
labels:

Просмотреть файл

@ -1,7 +1,5 @@
friendly_name: >
Test table for a non-incremental query
description: >
Test table for a non-incremental query
friendly_name: "Test table for a non-incremental query"
description: "Test table for a non-incremental query"
owners:
- ascholtz@mozilla.com
labels: