fsspec / fsspec/filesystem_spec

Unable to use "simplecache" to write NETCDF to Open Storage Network S3 storage

Open
#1,131 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
1.4k
Forks
490
Avg merge
2d 3h
Merged PRs (30d)
38

Description

Hello, I'm running into a bug where I am unable to write NETCDF files to permissioned storage on Open Storage Network without having to explicitly create a local copy and then use put. The code is being run in parallel using Dask and Xarray on a kubernetes cluster.

I've used the code snippet below with simplecache to write to permissioned S3 storage before.

outfile = fsspec.open('simplecache::s3://file/path/to/OSN/ds.nc', 
                      mode='wb', s3=dict(profile='profile'))
with outfile as f:
    ds.load().to_netcdf(f, compute=True)

The modified code to include the OSN endpoint URL looks would then look like this:

fs_write = fsspec.filesystem('s3', 
        profile='profile', 
        skip_instance_cache=True, 
        client_kwargs={'endpoint_url': 'https://renc.osn.xsede.org'}
        )

outfile = fs_write .open('simplecache::s3://file/path/to/OSN/ds.nc', 
                      mode='wb', s3=dict(profile='profile'))
with outfile as f:
    ds.load().to_netcdf(f, compute=True)

When I run the above code, I get a regex error about the simplecache not matching making S3 filepaths.

So, I have had to revert to creating a local file and then using put to add it to OSN

# xarray dataset with dask to NETCDF
ds.to_netcdf("ds.nc", compute=True, mode='w', engine='h5netcdf')

# use put to transfer file from local to OSN
_ = fs_write.put("ds.nc", "file/path/to/OSN/ds.nc")

A fix could be to add the simplecache functionality to the open method of fsspec.filesystem.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the reported regex error with fsspec.filesystem('s3', ...) and the simplecache/open snippet against the OSN endpoint. Inspect the filesystem open path and simplecache handling; done means permissioned OSN S3 NETCDF output works through simplecache without requiring a local file and put transfer.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cloud
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.