in mozilla_schema_generator/__main__.py [0:0]
def generate_glean_pings(config, out_dir, pretty, mps_branch, repo, generic_schema):
if out_dir:
out_dir = Path(out_dir)
repos = GleanPing.get_repos()
if repo is not None:
repos = [r for r in repos if r["app_id"] == repo]
with open(config, "r") as f:
config_data = yaml.safe_load(f)
glean_config = Config("glean", config_data)
# validate that the config has mappings for every single metric type specified in the
# Glean schema (see: https://bugzilla.mozilla.org/show_bug.cgi?id=1739239)
glean_schema = GleanPing(repos[0]).get_schema()
glean_matched_metrics_in_config = set(config_data["metrics"].keys())
glean_metrics_in_schema = set(
glean_schema.get(["properties", "metrics", "properties"]).keys()
)
new_unmatched_glean_types = (
glean_metrics_in_schema - glean_matched_metrics_in_config
)
if new_unmatched_glean_types:
raise click.ClickException(
"Unknown metric types in Glean Schema: {}. Please add them to {}".format(
", ".join(sorted(new_unmatched_glean_types)), config
)
)
for repo in repos:
write_schema(
repo,
glean_config,
out_dir,
pretty,
generic_schema,
mps_branch,
)