generated from snakemake-workflows/snakemake-workflow-template
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- instead of a final() wrapper, the bids() function is overloaded to append storage() when the file has a remote URI in it - this way, we can just add the gcs:// or s3:// prefix to the root (output folder) config variable, and avoid having a write_to_remote flag. - however, it complicates a couple other things, e.g. expand() cannot be applied to files with the storage tag, so we make another wrapper, expand_bids() to make sure storage() is applied after expanding.. - also refactored the fsspec code, which now lives in workflow/lib/cloud_io.py - I considered moving it to zarrnii, but it is actually snakemake specific so probably better to stay as a helper function in the snakemake workflow
- Loading branch information
Showing
10 changed files
with
218 additions
and
238 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
from upath import UPath as Path | ||
|
||
def is_remote(uri_string): | ||
uri = Path(uri_string) | ||
if uri.protocol == 'gcs' or uri.protocol == 's3': | ||
return True | ||
else: | ||
return False | ||
|
||
def get_fsspec(uri_string,storage_provider_settings=None,creds=None): | ||
uri = Path(uri_string) | ||
if uri.protocol == 'gcs': | ||
print('is gcs') | ||
from gcsfs import GCSFileSystem | ||
gcsfs_opts={} | ||
gcsfs_opts={'project': storage_provider_settings['gcs'].get_settings().project, | ||
'token': creds} | ||
fs = GCSFileSystem(**gcsfs_opts) | ||
elif uri.protocol == 's3': | ||
from s3fs import S3FileSystem | ||
s3fs_opts={'anon': False} | ||
fs = S3FileSystem(**s3fs_opts) | ||
elif uri.protocol == 'file' or uri.protocol == 'local' or uri.protocol == '': | ||
#assumed to be local file | ||
from fsspec import LocalFileSystem | ||
fs = LocalFileSystem() | ||
else: | ||
print(f'unsupported protocol for remote data') | ||
return fs | ||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.