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

File object support in the Python API (fsspec) #598

Open
2 tasks done
daweim0 opened this issue Nov 7, 2023 · 0 comments
Open
2 tasks done

File object support in the Python API (fsspec) #598

daweim0 opened this issue Nov 7, 2023 · 0 comments
Assignees

Comments

@daweim0
Copy link

daweim0 commented Nov 7, 2023

Preliminary Checks

  • This issue is not a duplicate. Before opening a new issue, please search existing issues.
  • This issue is not a question, bug report, or anything other than a feature request directly related to this project.

Proposal

Currently, pyzed functions involving files require a path to a file physically on disk. For example, the following code is valid:

init_params = sl.InitParameters()
init_params.set_from_svo_file("path/to/svo.svo")

However, this chunk of code is not

with open("path/to/svo.svo", "rb") as svo_file_obj:
    init_params = sl.InitParameters()
    init_params.set_from_svo_file(svo_file_obj)

My request is to modify set_from_svo_file() to accept file objects, not just paths to files.

Use-Case

This is extremely useful when SVO files are stored remotely. For example, I record SVO files on a computationally limited device, then save the SVO files to S3. Many Python libraries (including Numpy, Pandas, and PyAV) can read/write files directly from S3 like so

import fsspec
fs = fsspec.filesystem("filecache", target_protocol="s3")
with fs.open("s3://bucket/path/to/numpy/archive.npz", "rb") as numpy_archive:
    numpy_data = np.load(npz)

This is very convenient in two ways:

  1. I (the user) don't have to download files I need ahead of time
  2. Numpy maintainers don't have to write any s3 specific code. They add ~5 lines to the start of their functions involving files and suddenly they support every blob store under the sun.

I currently download SVO files before processing them, but I work with all other files (mp4, csv, ...) directly in s3.

Anything else?

I don't think SVO streaming solves my problem, since S3 servers aren't going to run ZED-specific code.

@daweim0 daweim0 changed the title File object support in the python API (fsspec) File object support in the Python API (fsspec) Nov 8, 2023
@Myzhar Myzhar assigned Myzhar, mattrouss and alassagne-sl and unassigned Myzhar Feb 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

4 participants