Skip to content

Commit

Permalink
echo statements in src/scripts/describe_enums_by_slots_using.py to st…
Browse files Browse the repository at this point in the history
…art showing
  • Loading branch information
sujaypatil96 committed Oct 15, 2024
1 parent dad7c25 commit 9ef3e42
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions src/scripts/describe_enums_by_slots_using.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,19 @@


@click.command()
@click.option('--schema_file', type=str, default="../mixs/schema/mixs.yaml", help="Path to the input schema file.")
@click.option('--output_file', type=str, default='../../mixs_with_enum_descriptions.yaml', show_default=True,
help="Path to the output schema file with updated enum descriptions.")
@click.option(
"--schema_file",
type=str,
default="../mixs/schema/mixs.yaml",
help="Path to the input schema file.",
)
@click.option(
"--output_file",
type=str,
default="../../mixs_with_enum_descriptions.yaml",
show_default=True,
help="Path to the output schema file with updated enum descriptions.",
)
def update_enum_descriptions(schema_file: str, output_file: str) -> None:
"""
Update enum descriptions in the given schema file.
Expand All @@ -15,7 +25,7 @@ def update_enum_descriptions(schema_file: str, output_file: str) -> None:
by other terms (slots). The descriptions will indicate whether an enum is used by any term, and if so,
by how many terms and which ones.
Does not overwrite existing descriptions
Note: Does not overwrite existing descriptions
:param schema_file: Path to the input schema file.
:param output_file: Path to the output schema file where the updated schema will be saved.
Expand All @@ -30,7 +40,7 @@ def update_enum_descriptions(schema_file: str, output_file: str) -> None:

new_desc = ""

if ev.description is None or ev.description != "":
if ev.description is None or ev.description == "":
if len(user_names) == 0:
new_desc = "Permissible values, not used by any term"
elif len(user_names) == 1:
Expand All @@ -40,11 +50,12 @@ def update_enum_descriptions(schema_file: str, output_file: str) -> None:
ev.description = new_desc
else:
click.echo(
f"Permissible value {ek} already has description '{ev.description}'. Refusing to overwrite with {new_desc}.")
f"Enum {ek} already has description '{ev.description}'. Do not overwrite with new description."
)

yaml_dumper.dump(schema_view.schema, output_file)
click.echo(f"Enum descriptions updated and saved to {output_file}")


if __name__ == '__main__':
if __name__ == "__main__":
update_enum_descriptions()

0 comments on commit 9ef3e42

Please sign in to comment.