Skip to content

Commit

Permalink
Merge ebb816d into 5717268
Browse files Browse the repository at this point in the history
  • Loading branch information
delucchi-cmu authored Oct 18, 2024
2 parents 5717268 + ebb816d commit aeb83c4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/hats_import/hipscat_conversion/run_conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ def _convert_partition_file(pixel, args, schema, ra_column, dec_column):
.append_column("Dir", [np.full(num_rows, fill_value=pixel.dir, dtype=np.int64)])
.append_column("Npix", [np.full(num_rows, fill_value=pixel.pixel, dtype=np.int64)])
)
table = table.replace_schema_metadata()

destination_file = paths.pixel_catalog_file(args.catalog_path, pixel)
destination_file.parent.mkdir(parents=True, exist_ok=True)
Expand All @@ -151,6 +152,7 @@ def _convert_partition_file(pixel, args, schema, ra_column, dec_column):
except Exception: # pylint: disable=broad-exception-caught
pass
dask_print(exception)
raise exception


def _write_nested_fits_map(input_dir, output_dir):
Expand Down
15 changes: 15 additions & 0 deletions tests/hats_import/hipscat_conversion/test_run_conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import pyarrow as pa
import pyarrow.parquet as pq
import pytest
from hats.io.file_io import file_io

import hats_import.hipscat_conversion.run_conversion as runner
from hats_import.hipscat_conversion.arguments import ConversionArguments
Expand Down Expand Up @@ -70,10 +71,21 @@ def test_run_conversion_object(
)
schema = pq.read_metadata(output_file).schema.to_arrow_schema()
assert schema.equals(expected_parquet_schema, check_metadata=False)
assert schema.metadata is None
schema = pq.read_metadata(args.catalog_path / "dataset" / "_metadata").schema.to_arrow_schema()
assert schema.equals(expected_parquet_schema, check_metadata=False)
assert schema.metadata is None
schema = pq.read_metadata(args.catalog_path / "dataset" / "_common_metadata").schema.to_arrow_schema()
assert schema.equals(expected_parquet_schema, check_metadata=False)
assert schema.metadata is None

data = file_io.read_parquet_file_to_pandas(
output_file,
columns=["id", "ra", "dec", "_healpix_29"],
engine="pyarrow",
)
assert "_healpix_29" in data.columns
assert data.index.name is None


@pytest.mark.dask
Expand Down Expand Up @@ -118,7 +130,10 @@ def test_run_conversion_source(
]
schema = pq.read_metadata(output_file).schema
npt.assert_array_equal(schema.names, source_columns)
assert schema.to_arrow_schema().metadata is None
schema = pq.read_metadata(args.catalog_path / "dataset" / "_metadata").schema
npt.assert_array_equal(schema.names, source_columns)
assert schema.to_arrow_schema().metadata is None
schema = pq.read_metadata(args.catalog_path / "dataset" / "_common_metadata").schema
npt.assert_array_equal(schema.names, source_columns)
assert schema.to_arrow_schema().metadata is None

0 comments on commit aeb83c4

Please sign in to comment.