Skip to content

Commit

Permalink
Reorganize to limit lines per function, per pylint.
Browse files Browse the repository at this point in the history
  • Loading branch information
gitosaurus committed Jan 2, 2025
1 parent 422662c commit c3fb952
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/hats_import/catalog/run_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,27 @@
from hats_import.catalog.resume_plan import ResumePlan


def run(args, client):
"""Run catalog creation pipeline."""
def _validate_arguments(args):
"""
Verify that the args for run are valid: they exist, are of the appropriate type,
and do not specify an output which is a valid catalog.
Raises ValueError if they are invalid.
"""
if not args:
raise ValueError("args is required and should be type ImportArguments")
if not isinstance(args, ImportArguments):
raise ValueError("args must be type ImportArguments")

# Verify that the planned output path is not occupied by a valid catalog
potential_path = Path(args.output_path) / args.output_artifact_name
if is_valid_catalog(potential_path):
raise ValueError(f"Output path {potential_path} already contains a valid catalog")


def run(args, client):
"""Run catalog creation pipeline."""
_validate_arguments(args)

resume_plan = ResumePlan(import_args=args)

pickled_reader_file = os.path.join(resume_plan.tmp_path, "reader.pickle")
Expand Down

0 comments on commit c3fb952

Please sign in to comment.