mirror of
https://github.com/chanzuckerberg/cellxgene.git
synced 2026-10-06 19:18:11 +08:00
use fsspec.download for S3 artifacts + additional logging (#2536)
This commit is contained in:
@@ -113,10 +113,9 @@ class DataLocator:
|
|||||||
# do our best to create a file with the same.
|
# do our best to create a file with the same.
|
||||||
ext = os.path.splitext(self.path)
|
ext = os.path.splitext(self.path)
|
||||||
suffix = None if ext[1] == "" else ext[1]
|
suffix = None if ext[1] == "" else ext[1]
|
||||||
with self.open() as src, tempfile.NamedTemporaryFile(prefix="cellxgene_", suffix=suffix, delete=False) as tmp:
|
with tempfile.NamedTemporaryFile(prefix="cellxgene_", suffix=suffix, delete=False) as tmp:
|
||||||
tmp.write(src.read())
|
self.fs.download(self.uri_or_path, tmp.name)
|
||||||
tmp.close()
|
tmp.close()
|
||||||
src.close()
|
|
||||||
tmp_path = tmp.name
|
tmp_path = tmp.name
|
||||||
return LocalFilePath(tmp_path, delete=True)
|
return LocalFilePath(tmp_path, delete=True)
|
||||||
|
|
||||||
|
|||||||
@@ -174,10 +174,14 @@ class AnndataAdaptor(DataAdaptor):
|
|||||||
except MemoryError:
|
except MemoryError:
|
||||||
raise DatasetAccessError("Out of memory - file is too large for available memory.")
|
raise DatasetAccessError("Out of memory - file is too large for available memory.")
|
||||||
except Exception:
|
except Exception:
|
||||||
raise DatasetAccessError(
|
import traceback
|
||||||
|
message = (
|
||||||
"File not found or is inaccessible. File must be an .h5ad object. "
|
"File not found or is inaccessible. File must be an .h5ad object. "
|
||||||
"Please check your input and try again."
|
"Please check your input and try again."
|
||||||
)
|
)
|
||||||
|
if self.server_config.app__verbose:
|
||||||
|
message += f"\n{traceback.format_exc()}"
|
||||||
|
raise DatasetAccessError(message)
|
||||||
|
|
||||||
def _validate_and_initialize(self):
|
def _validate_and_initialize(self):
|
||||||
if anndata_version_is_pre_070():
|
if anndata_version_is_pre_070():
|
||||||
|
|||||||
Reference in New Issue
Block a user