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

Remove pandas metadata in hipscat conversion #413

Merged
merged 3 commits into from
Oct 18, 2024
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
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 @@
.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 @@
except Exception: # pylint: disable=broad-exception-caught
pass
dask_print(exception)
raise exception

Check warning on line 155 in src/hats_import/hipscat_conversion/run_conversion.py

View check run for this annotation

Codecov / codecov/patch

src/hats_import/hipscat_conversion/run_conversion.py#L155

Added line #L155 was not covered by tests


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