Skip to content

Commit

Permalink
use fsspec.download for S3 artifacts + additional logging (#2536)
Browse files Browse the repository at this point in the history
  • Loading branch information
ebezzi authored Jul 29, 2022
1 parent 6c86216 commit d2b2012
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
5 changes: 2 additions & 3 deletions server/common/utils/data_locator.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,9 @@ def local_handle(self):
# do our best to create a file with the same.
ext = os.path.splitext(self.path)
suffix = None if ext[1] == "" else ext[1]
with self.open() as src, tempfile.NamedTemporaryFile(prefix="cellxgene_", suffix=suffix, delete=False) as tmp:
tmp.write(src.read())
with tempfile.NamedTemporaryFile(prefix="cellxgene_", suffix=suffix, delete=False) as tmp:
self.fs.download(self.uri_or_path, tmp.name)
tmp.close()
src.close()
tmp_path = tmp.name
return LocalFilePath(tmp_path, delete=True)

Expand Down
8 changes: 6 additions & 2 deletions server/data_anndata/anndata_adaptor.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,10 +174,14 @@ def _load_data(self, data_locator):
except MemoryError:
raise DatasetAccessError("Out of memory - file is too large for available memory.")
except Exception:
raise DatasetAccessError(
import traceback
message = (
"File not found or is inaccessible. File must be an .h5ad object. "
"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):
if anndata_version_is_pre_070():
Expand Down

0 comments on commit d2b2012

Please sign in to comment.