Skip to content

Commit

Permalink
Merge branch 'main' into sean/assosciation-catalog
Browse files Browse the repository at this point in the history
  • Loading branch information
smcguire-cmu committed Dec 18, 2023
2 parents 924328d + 296d50c commit ea48bbb
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<img src="https://www.lsstcorporation.org/lincc/sites/default/files/PastedGraphic-8.png" width="300" height="100">
<img src="https://github.com/lincc-frameworks/tape/blob/main/docs/DARK_Combo_sm.png?raw=true" width="300" height="100">
<img src="https://user-images.githubusercontent.com/113376043/211332292-4705c34c-5e74-4f12-85e2-be4bacaa8700.jpg" width="300">

# LSDB
Expand Down
4 changes: 2 additions & 2 deletions docs/notebooks/import_catalogs.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -188,14 +188,14 @@
"outputs": [],
"source": [
"args = ImportArguments(\n",
" id_column=\"id\",\n",
" sort_columns=\"id\",\n",
" ra_column=\"ra\",\n",
" dec_column=\"dec\",\n",
" highest_healpix_order=5,\n",
" pixel_threshold=100,\n",
" input_path=catalog_dir,\n",
" input_format=f\"small_sky_order1.csv\",\n",
" output_catalog_name=catalog_from_importer,\n",
" output_artifact_name=catalog_from_importer,\n",
" output_path=\".\",\n",
" dask_tmp=\".\",\n",
" overwrite=True,\n",
Expand Down
3 changes: 2 additions & 1 deletion src/lsdb/catalog/catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@ def to_hipscat(
self,
base_catalog_path: str,
catalog_name: Union[str, None] = None,
overwrite: bool = False,
storage_options: Union[Dict[Any, Any], None] = None,
**kwargs,
):
Expand All @@ -316,7 +317,7 @@ def to_hipscat(
storage_options (dict): Dictionary that contains abstract filesystem credentials
**kwargs: Arguments to pass to the parquet write operations
"""
io.to_hipscat(self, base_catalog_path, catalog_name, storage_options, **kwargs)
io.to_hipscat(self, base_catalog_path, catalog_name, overwrite, storage_options, **kwargs)

def join(
self,
Expand Down
4 changes: 3 additions & 1 deletion src/lsdb/io/to_hipscat.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ def to_hipscat(
catalog: Catalog,
base_catalog_path: str,
catalog_name: Union[str, None] = None,
overwrite: bool = False,
storage_options: Union[Dict[Any, Any], None] = None,
**kwargs,
):
Expand All @@ -62,12 +63,13 @@ def to_hipscat(
catalog (Catalog): A catalog to export
base_catalog_path (str): Location where catalog is saved to
catalog_name (str): The name of the output catalog
overwrite (bool): If True existing catalog is overwritten
storage_options (dict): Dictionary that contains abstract filesystem credentials
**kwargs: Arguments to pass to the parquet write operations
"""
# Create base directory
base_catalog_dir_fp = hc.io.get_file_pointer_from_path(base_catalog_path)
hc.io.file_io.make_directory(base_catalog_dir_fp)
hc.io.file_io.make_directory(base_catalog_dir_fp, overwrite, storage_options)
# Save partition parquet files
pixel_to_partition_size_map = write_partitions(catalog, base_catalog_dir_fp, storage_options, **kwargs)
# Save parquet metadata
Expand Down
8 changes: 8 additions & 0 deletions tests/lsdb/catalog/test_catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,3 +121,11 @@ def test_save_catalog(small_sky_catalog, tmp_path):
assert expected_catalog.hc_structure.catalog_info == small_sky_catalog.hc_structure.catalog_info
assert expected_catalog.get_healpix_pixels() == small_sky_catalog.get_healpix_pixels()
pd.testing.assert_frame_equal(expected_catalog.compute(), small_sky_catalog._ddf.compute())


def test_save_catalog_overwrite(small_sky_catalog, tmp_path):
base_catalog_path = os.path.join(tmp_path, "small_sky")
small_sky_catalog.to_hipscat(base_catalog_path)
with pytest.raises(FileExistsError):
small_sky_catalog.to_hipscat(base_catalog_path)
small_sky_catalog.to_hipscat(base_catalog_path, overwrite=True)

0 comments on commit ea48bbb

Please sign in to comment.