Skip to content

Commit

Permalink
Check for existing valid catalog (#52)
Browse files Browse the repository at this point in the history
  • Loading branch information
delucchi-cmu authored Jan 6, 2025
1 parent 7bf4b2a commit e39a051
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
14 changes: 14 additions & 0 deletions tests/hats_import/test_create_margin.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import hats_import.margin_cache.margin_cache as mc
import pytest
from hats import read_hats
from hats_import.margin_cache.margin_cache_arguments import MarginCacheArguments

Expand Down Expand Up @@ -64,3 +65,16 @@ def test_margin_cache_gen_read_from_cloud(
catalog = read_hats(args.catalog_path)
assert catalog.on_disk
assert catalog.catalog_path == args.catalog_path


def test_no_margin_cache_overwrite(small_sky_order1_dir_cloud):
"""Runner should refuse to generate margin cache which overwrites valid catalog"""
catalog_dir = small_sky_order1_dir_cloud.parent
catalog_name = small_sky_order1_dir_cloud.name
with pytest.raises(ValueError, match="already contains a valid catalog"):
MarginCacheArguments(
input_catalog_path=small_sky_order1_dir_cloud,
output_path=catalog_dir,
margin_threshold=10.0,
output_artifact_name=catalog_name,
)
13 changes: 13 additions & 0 deletions tests/hats_import/test_run_catalog_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,16 @@ def test_read_csv_cloud(small_sky_parts_dir_cloud):
assert len(frame) == 25

assert total_chunks == 1


def test_no_import_overwrite(small_sky_order1_dir_cloud, small_sky_parts_dir_local):
"""Runner should refuse to overwrite a valid catalog"""
catalog_dir = small_sky_order1_dir_cloud.parent
catalog_name = small_sky_order1_dir_cloud.name
with pytest.raises(ValueError, match="already contains a valid catalog"):
ImportArguments(
input_path=small_sky_parts_dir_local,
output_path=catalog_dir,
output_artifact_name=catalog_name,
file_reader="parquet",
)

0 comments on commit e39a051

Please sign in to comment.