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

Check for existing valid catalog #52

Merged
merged 1 commit into from
Jan 6, 2025
Merged
Show file tree
Hide file tree
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
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",
)
Loading