Skip to content

Commit

Permalink
Merge pull request #165 from astronomy-commons/issue/140/create-outpu…
Browse files Browse the repository at this point in the history
…t-dir

Create output directory
  • Loading branch information
camposandro committed Nov 10, 2023
2 parents fac2b7a + d3a51eb commit 151d2ed
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 27 deletions.
3 changes: 0 additions & 3 deletions src/hipscat_import/runtime_arguments.py
Expand Up @@ -65,9 +65,6 @@ def _check_arguments(self):
if self.dask_threads_per_worker <= 0:
raise ValueError("dask_threads_per_worker should be greater than 0")

if not file_io.does_file_or_directory_exist(self.output_path):
raise FileNotFoundError(f"output_path ({self.output_path}) not found on local storage")

self.catalog_path = file_io.append_paths_to_pointer(self.output_path, self.output_catalog_name)
if not self.overwrite:
if file_io.directory_has_contents(self.catalog_path):
Expand Down
3 changes: 3 additions & 0 deletions src/hipscat_import/verification/arguments.py
Expand Up @@ -4,6 +4,7 @@
from typing import List, Optional

from hipscat.catalog import Catalog
from hipscat.io.validation import is_valid_catalog

from hipscat_import.runtime_arguments import RuntimeArguments

Expand Down Expand Up @@ -32,6 +33,8 @@ def _check_arguments(self):
if not self.input_catalog_path and not self.input_catalog:
raise ValueError("input catalog is required (either input_catalog_path or input_catalog)")
if not self.input_catalog:
if not is_valid_catalog(self.input_catalog_path):
raise ValueError("input_catalog_path not a valid catalog")
self.input_catalog = Catalog.read_from_hipscat(catalog_path=self.input_catalog_path)
if not self.input_catalog_path:
self.input_catalog_path = self.input_catalog.catalog_path
Expand Down
16 changes: 3 additions & 13 deletions tests/hipscat_import/index/test_index_argument.py
Expand Up @@ -52,22 +52,12 @@ def test_invalid_paths(tmp_path, small_sky_object_catalog):
output_path=tmp_path,
output_catalog_name="small_sky_object_index",
)

## Bad input path
with pytest.raises(FileNotFoundError):
IndexArguments(
input_catalog_path="path",
indexing_column="id",
output_path="path",
output_catalog_name="small_sky_object_index",
)

## Input path has no files
with pytest.raises(FileNotFoundError):
## Input path is invalid catalog
with pytest.raises(ValueError, match="input_catalog_path not a valid catalog"):
IndexArguments(
input_catalog_path="path",
indexing_column="id",
output_path="path",
output_path=f"{tmp_path}/path",
output_catalog_name="small_sky_object_index",
)

Expand Down
7 changes: 0 additions & 7 deletions tests/hipscat_import/test_runtime_arguments.py
Expand Up @@ -49,13 +49,6 @@ def test_catalog_name(tmp_path):

def test_invalid_paths(tmp_path):
"""Required arguments are provided, but paths aren't found."""
## Bad output path
with pytest.raises(FileNotFoundError):
RuntimeArguments(
output_catalog_name="catalog",
output_path="/foo/path",
)

## Bad temp path
with pytest.raises(FileNotFoundError):
RuntimeArguments(output_catalog_name="catalog", output_path=tmp_path, tmp_dir="/foo/path")
Expand Down
@@ -1,6 +1,5 @@
"""Tests of argument validation"""


import pytest
from hipscat.catalog import Catalog

Expand Down Expand Up @@ -32,11 +31,11 @@ def test_invalid_paths(tmp_path, small_sky_object_catalog):
output_catalog_name="small_sky_object_verification_report",
)

## Bad input path
with pytest.raises(FileNotFoundError):
## Input path is invalid catalog
with pytest.raises(ValueError, match="input_catalog_path not a valid catalog"):
VerificationArguments(
input_catalog_path="path",
output_path="path",
output_path=f"{tmp_path}/path",
output_catalog_name="small_sky_object_verification_report",
)

Expand Down

0 comments on commit 151d2ed

Please sign in to comment.