-
Notifications
You must be signed in to change notification settings - Fork 3
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 for arbritary remote storages #24
Conversation
Codecov Report
@@ Coverage Diff @@
## master #24 +/- ##
==========================================
- Coverage 83.01% 82.66% -0.36%
==========================================
Files 6 6
Lines 689 721 +32
==========================================
+ Hits 572 596 +24
- Misses 117 125 +8
Continue to review full report at Codecov.
|
sparsity/io.py
Outdated
} | ||
|
||
try: | ||
import s3fs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's already s3fs
import above. Wrapping this one in try
doesn't seem to make sense.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
true I'll remove the one above
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Forgot about this one? :P
sparsity/io.py
Outdated
if not filename.startswith('s3://'): | ||
|
||
protocol = urlparse(filename).scheme or 'file' | ||
if protocol == 'file': | ||
fp = open(filename, 'wb') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we leave the file open here? O.o
sparsity/io.py
Outdated
def _save_remote(buffer, filename, block_size=None, storage_options=None): | ||
if storage_options is None: | ||
storage_options = {} | ||
protocol = urlparse(filename).scheme or 'file' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
scheme
shouldn't be 'file'
here. I think leaving this as an option is misleading.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that's correct
sparsity/io.py
Outdated
if storage_options is None: | ||
storage_options = {} | ||
protocol = urlparse(filename).scheme or 'file' | ||
open_f = FILE_SYSTEMS[protocol](**storage_options).open | ||
fp = open_f(filename, 'rb') | ||
|
||
loader = np.load(fp) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here - we're not closing the file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm I think numpy closes it will check if that's true for sure though
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Numpy documentation doesn't say that they close the file.
defaults back to minimal implementation.
@michcio1234 Ok to merge? |
Argh closed this accidentally |
Mainly to support gcsfs