Skip to content

Commit

Permalink
Revise object store changes based on PR review.
Browse files Browse the repository at this point in the history
  • Loading branch information
jmchilton committed May 14, 2024
1 parent ec00edf commit 4147b38
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 11 deletions.
13 changes: 5 additions & 8 deletions lib/galaxy/objectstore/_caching_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
from galaxy.objectstore import ConcreteObjectStore
from galaxy.util import (
directory_hash_id,
ExecutionTimer,
unlink,
)
from galaxy.util.path import safe_relpath
Expand Down Expand Up @@ -99,15 +98,13 @@ def _in_cache(self, rel_path: str) -> bool:
return os.path.exists(cache_path)

def _pull_into_cache(self, rel_path) -> bool:
ipt_timer = ExecutionTimer()
# Ensure the cache directory structure exists (e.g., dataset_#_files/)
rel_path_dir = os.path.dirname(rel_path)
if not os.path.exists(self._get_cache_path(rel_path_dir)):
os.makedirs(self._get_cache_path(rel_path_dir), exist_ok=True)
# Now pull in the file
file_ok = self._download(rel_path)
fix_permissions(self.config, self._get_cache_path(rel_path_dir))
log.debug("_pull_into_cache: %s\n\n\n\n\n\n", ipt_timer)
return file_ok

def _get_data(self, obj, start=0, count=-1, **kwargs):
Expand Down Expand Up @@ -146,7 +143,7 @@ def _exists(self, obj, **kwargs):

# TODO: Sync should probably not be done here. Add this to an async upload stack?
if in_cache and not exists_remotely:
self._push_to_os(rel_path, source_file=self._get_cache_path(rel_path))
self._push_to_storage(rel_path, source_file=self._get_cache_path(rel_path))
return True
elif exists_remotely:
return True
Expand Down Expand Up @@ -180,7 +177,7 @@ def _create(self, obj, **kwargs):
if not dir_only:
rel_path = os.path.join(rel_path, alt_name if alt_name else f"dataset_{self._get_object_id(obj)}.dat")
open(os.path.join(self.staging_path, rel_path), "w").close()
self._push_to_os(rel_path, from_string="")
self._push_to_storage(rel_path, from_string="")
return self

def _caching_allowed(self, rel_path: str, remote_size: Optional[int] = None) -> bool:
Expand All @@ -196,7 +193,7 @@ def _caching_allowed(self, rel_path: str, remote_size: Optional[int] = None) ->
return False
return True

def _push_to_os(self, rel_path, source_file=None, from_string=None):
def _push_to_storage(self, rel_path, source_file=None, from_string=None):
source_file = source_file or self._get_cache_path(rel_path)
if from_string is None and not os.path.exists(source_file):
log.error(
Expand Down Expand Up @@ -338,7 +335,7 @@ def _update_from_file(self, obj, file_name=None, create=False, **kwargs):
else:
source_file = self._get_cache_path(rel_path)

self._push_to_os(rel_path, source_file)
self._push_to_storage(rel_path, source_file)

else:
raise ObjectNotFound(
Expand Down Expand Up @@ -376,7 +373,7 @@ def _delete_existing_remote(self, rel_path) -> bool:
def _delete_remote_all(self, rel_path) -> bool:
raise NotImplementedError()

# Do not need to override these if instead replacing _push_to_os
# Do not need to override these if instead replacing _push_to_storage
def _push_string_to_path(self, rel_path: str, from_string: str) -> bool:
raise NotImplementedError()

Expand Down
4 changes: 2 additions & 2 deletions lib/galaxy/objectstore/irods.py
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ def _download(self, rel_path):
finally:
log.debug("irods_pt _download: %s", ipt_timer)

def _push_to_os(self, rel_path, source_file=None, from_string=None):
def _push_to_storage(self, rel_path, source_file=None, from_string=None):
"""
Push the file pointed to by ``rel_path`` to the iRODS. Extract folder name
from rel_path as iRODS collection name, and extract file name from rel_path
Expand Down Expand Up @@ -448,7 +448,7 @@ def _push_to_os(self, rel_path, source_file=None, from_string=None):
)
return True
finally:
log.debug("irods_pt _push_to_os: %s", ipt_timer)
log.debug("irods_pt _push_to_storage: %s", ipt_timer)

def _delete(self, obj, entire_dir=False, **kwargs):
ipt_timer = ExecutionTimer()
Expand Down
2 changes: 1 addition & 1 deletion lib/galaxy/objectstore/s3.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ def _download(self, rel_path):
log.exception("Problem downloading key '%s' from S3 bucket '%s'", rel_path, self._bucket.name)
return False

def _push_to_os(self, rel_path, source_file=None, from_string=None):
def _push_to_storage(self, rel_path, source_file=None, from_string=None):
"""
Push the file pointed to by ``rel_path`` to the object store naming the key
``rel_path``. If ``source_file`` is provided, push that file instead while
Expand Down

0 comments on commit 4147b38

Please sign in to comment.