Skip to content

Commit

Permalink
Pass user to ObjectStorePopulator.
Browse files Browse the repository at this point in the history
Not used yet in Galaxy core yet, but useful for applications where you want object store selection to be based on user in some way. This code was taken from galaxyproject#4840. Part of this is trying to reduce the number of files that branch touches to make review easier - but I'm confident this extension point is good regardless. Also it makes it clear we need to keep the user object in the picture when assigning the object store ID in the future.
  • Loading branch information
jmchilton committed Sep 10, 2020
1 parent c4f911d commit addb56d
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/galaxy/jobs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1456,7 +1456,7 @@ def _set_object_store_ids(self, job):
# jobs may have this set. Skip this following code if that is the case.
return

object_store_populator = ObjectStorePopulator(self.app)
object_store_populator = ObjectStorePopulator(self.app, job.user)
object_store_id = self.get_destination_configuration("object_store_id", None)
if object_store_id:
object_store_populator.object_store_id = object_store_id
Expand Down
3 changes: 2 additions & 1 deletion lib/galaxy/objectstore/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1070,9 +1070,10 @@ class ObjectStorePopulator:
datasets from a job end up with the same object_store_id.
"""

def __init__(self, app):
def __init__(self, app, user):
self.object_store = app.object_store
self.object_store_id = None
self.user = user

def set_object_store_id(self, data):
# Create an empty file immediately. The first dataset will be
Expand Down
2 changes: 1 addition & 1 deletion lib/galaxy/tools/actions/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ def execute(self, tool, trans, incoming=None, return_job=False, set_output_hid=T
# datasets first, then create the associations
parent_to_child_pairs = []
child_dataset_names = set()
object_store_populator = ObjectStorePopulator(app)
object_store_populator = ObjectStorePopulator(app, trans.user)
async_tool = tool.tool_type == 'data_source_async'

def handle_output(name, output, hidden=None):
Expand Down
2 changes: 1 addition & 1 deletion test/unit/tools/test_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ def _create_output_dataset(self, **kwd):
**kwd
)
self.history.add_dataset(output_dataset)
ObjectStorePopulator(self.app).set_object_store_id(output_dataset)
ObjectStorePopulator(self.app, user=self.job.user).set_object_store_id(output_dataset)
return output_dataset

def _write_work_dir_file(self, filename, contents):
Expand Down

0 comments on commit addb56d

Please sign in to comment.