mirror of
https://github.com/chanzuckerberg/cellxgene.git
synced 2026-10-01 18:58:11 +08:00
Use DataLocator consistently on backend (#1208)
* allow DataLocator to accept another locator as init param * migrate to DataLocator * migrate to DataLocator * lint * migrate to DataLocator * add check for erroroneous use of remote path and annotations * lint * revert default data location - now back go CWD * remove unused import
This commit is contained in:
@@ -26,10 +26,18 @@ class DataLocator:
|
||||
"""
|
||||
|
||||
def __init__(self, uri_or_path):
|
||||
self.uri_or_path = uri_or_path
|
||||
self.protocol, self.path = DataLocator._get_protocol_and_path(uri_or_path)
|
||||
# work-around for LocalFileSystem not treating file: and None as the same scheme/protocol
|
||||
self.cname = self.path if self.protocol == "file" else self.uri_or_path
|
||||
if isinstance(uri_or_path, DataLocator):
|
||||
locator = uri_or_path
|
||||
self.uri_or_path = locator.uri_or_path
|
||||
self.protocol = locator.protocol
|
||||
self.path = locator.path
|
||||
self.cname = locator.cname
|
||||
else:
|
||||
self.uri_or_path = uri_or_path
|
||||
self.protocol, self.path = DataLocator._get_protocol_and_path(uri_or_path)
|
||||
# work-around for LocalFileSystem not treating file: and None as the same scheme/protocol
|
||||
self.cname = self.path if self.protocol == "file" else self.uri_or_path
|
||||
|
||||
# will throw RuntimeError if the protocol is unsupported
|
||||
self.fs = fsspec.filesystem(self.protocol)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user