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

Make sure that metadata friendly_name and description are not None #4513

Merged
merged 7 commits into from
Nov 17, 2023
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
13 changes: 10 additions & 3 deletions bigquery_etl/metadata/parse_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import enum
import os
import re
import string
from pathlib import Path
from typing import Any, Dict, List, Optional

import attr
Expand Down Expand Up @@ -230,9 +232,14 @@ def from_file(cls, metadata_file):
with open(metadata_file, "r") as yaml_stream:
try:
metadata = yaml.safe_load(yaml_stream)

friendly_name = metadata.get("friendly_name", None)
description = metadata.get("description", None)
table_name = str(Path(metadata_file).parent.name)
friendly_name = metadata.get(
"friendly_name", string.capwords(table_name.replace("_", " "))
)
description = metadata.get(
"description",
"Please provide a description for the query",
)

if "labels" in metadata:
for key, label in metadata["labels"].items():
Expand Down
2 changes: 1 addition & 1 deletion tests/metadata/test_parse_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def test_from_file(self):
metadata = Metadata.from_file(metadata_file)

assert metadata.friendly_name == "Test metadata file"
assert metadata.description is None
assert metadata.description == "Please provide a description for the query"
assert "schedule" in metadata.labels
assert metadata.labels["schedule"] == "daily"
assert "public_json" in metadata.labels
Expand Down