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

✨ match-variables: check validity of output_file #1423

Merged
merged 3 commits into from
Aug 4, 2023
Merged
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
8 changes: 7 additions & 1 deletion etl/match_variables.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

import json
import os
from pathlib import Path
from typing import Any, Dict, List, Tuple, Union, cast

import click
Expand Down Expand Up @@ -41,7 +42,7 @@
"-f",
"--output-file",
type=str,
help="Path to output json file.",
help="Path to output JSON file.",
required=True,
)
@click.option(
Expand Down Expand Up @@ -116,6 +117,11 @@ def main(
similarity_name: str = SIMILARITY_NAME,
max_suggestions: int = N_MAX_SUGGESTIONS,
) -> None:
if os.path.isdir(output_file):
raise ValueError(f"`output_file` ({output_file}) should point to a JSON file ('*.json') and not a directory!")
if Path(output_file).suffix != ".json":
raise ValueError(f"`output_file` ({output_file}) should point to a JSON file ('*.json')!")

with db.get_connection() as db_conn:
# Get old and new dataset ids.
old_dataset_id = db.get_dataset_id(db_conn=db_conn, dataset_name=old_dataset_name)
Expand Down