Skip to content

Commit

Permalink
added http header possibility
Browse files Browse the repository at this point in the history
  • Loading branch information
Schwarzam committed Nov 1, 2024
1 parent 8e1d456 commit 5e8cc98
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/hats/catalog/dataset/table_properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,9 @@ def __str__(self):
return formatted_string

@classmethod
def read_from_dir(cls, catalog_dir: Union[str, Path, UPath]) -> Self:
def read_from_dir(cls, catalog_dir: Union[str, Path, UPath], **storage_options) -> Self:
"""Read field values from a java-style properties file."""
file_path = file_io.get_upath(catalog_dir) / "properties"
file_path = file_io.get_upath(catalog_dir, **storage_options) / "properties"
if not file_io.does_file_or_directory_exist(file_path):
raise FileNotFoundError(f"No properties file found where expected: {str(file_path)}")
p = Properties()
Expand Down
2 changes: 2 additions & 0 deletions src/hats/io/file_io/file_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,5 +282,7 @@ def read_parquet_file_to_pandas(
file_pointer = get_upath(file_pointer)
if file_open_kwargs is None:
file_open_kwargs = {}

with file_pointer.open("rb", **file_open_kwargs) as parquet_file:
kwargs.pop("headers", None)
return pd.read_parquet(parquet_file, **kwargs)
5 changes: 3 additions & 2 deletions src/hats/io/file_io/file_pointer.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@
from upath import UPath


def get_upath(path: str | Path | UPath) -> UPath:
def get_upath(path: str | Path | UPath, **storage_options) -> UPath:
"""Returns a file pointer from a path string"""
if not path:
return None
if isinstance(path, UPath):
return path
return UPath(path)

return UPath(path, **storage_options)


def append_paths_to_pointer(pointer: str | Path | UPath, *paths: str) -> UPath:
Expand Down
4 changes: 2 additions & 2 deletions src/hats/loaders/read_hats.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@
}


def read_hats(catalog_path: str | Path | UPath) -> Dataset:
def read_hats(catalog_path: str | Path | UPath, **kwargs) -> Dataset:
"""Reads a HATS Catalog from a HATS directory
Args:
catalog_path (str): path to the root directory of the catalog
Returns:
The initialized catalog object
"""
catalog_path = file_io.get_upath(catalog_path)
catalog_path = file_io.get_upath(catalog_path, **kwargs)
try:
properties = TableProperties.read_from_dir(catalog_path)
dataset_type = properties.catalog_type
Expand Down

0 comments on commit 5e8cc98

Please sign in to comment.