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

Add support to http headers again #410

Closed
Schwarzam opened this issue Nov 1, 2024 · 4 comments
Closed

Add support to http headers again #410

Schwarzam opened this issue Nov 1, 2024 · 4 comments
Labels
enhancement New feature or request

Comments

@Schwarzam
Copy link
Contributor

Since version 0.4, HTTP headers are no longer passed into the reader anymore (previously contained in the storage_options), which affects access to protected data that relies on these headers (e.g., for authentication).

To address this, we can use **kwargs in the appropriate places to reintroduce header support. I’ll create a PR to implement this fix.

@delucchi-cmu
Copy link
Contributor

I would rather not proliferate **storage_options back into the API. You should be able to pass the headers into the construction of a universal_pathlib.UPath object, and pass that to all methods that accept it. The headers will be handled via fsspec for all file system calls.

@Schwarzam
Copy link
Contributor Author

Yes! This is much much better now with this new version!
I just did this below:

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, **storage_options)

Maybe I should just rename the storage_options to something else.

@delucchi-cmu
Copy link
Contributor

Ah! I meant that you can call the upath constructor in your user code instead. e.g.

from upath import UPath
import lsdb

my_path = UPath(my_path, **storage_options)
my_catalog = lsdb.read_hats(my_path)

@Schwarzam
Copy link
Contributor Author

That's wonderful, works perfectly!
I wasn't able to think that far ahead.

Im closing the PRs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: Done
Development

No branches or pull requests

2 participants