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

Adding http header possibility #411

Closed
wants to merge 1 commit into from
Closed
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
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