mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-24 16:30:27 +08:00
Move one more flush out of dicovering outputs
This commit is contained in:
@@ -2307,6 +2307,11 @@ class StorableObject:
|
||||
else:
|
||||
self.uuid = UUID(str(uuid))
|
||||
|
||||
def flush(self):
|
||||
sa_session = object_session(self)
|
||||
if sa_session:
|
||||
sa_session.flush()
|
||||
|
||||
|
||||
class Dataset(StorableObject, RepresentById):
|
||||
states = Bunch(NEW='new',
|
||||
|
||||
@@ -283,7 +283,6 @@ class ModelPersistenceContext(metaclass=abc.ABCMeta):
|
||||
association_name = f'__new_primary_file_{name}|{element_identifier_str}__'
|
||||
self.add_output_dataset_association(association_name, dataset)
|
||||
|
||||
self.flush()
|
||||
self.update_object_store_with_datasets(datasets=element_datasets['datasets'], paths=element_datasets['paths'], extra_files=element_datasets['extra_files'])
|
||||
add_datasets_timer = ExecutionTimer()
|
||||
self.add_datasets_to_history(element_datasets['datasets'])
|
||||
|
||||
@@ -256,7 +256,11 @@ class BaseObjectStore(ObjectStore):
|
||||
|
||||
def _get_object_id(self, obj):
|
||||
if hasattr(obj, self.store_by):
|
||||
return getattr(obj, self.store_by)
|
||||
obj_id = getattr(obj, self.store_by)
|
||||
if obj_id is None:
|
||||
obj.flush()
|
||||
return obj.id
|
||||
return obj_id
|
||||
else:
|
||||
# job's don't have uuids, so always use ID in this case when creating
|
||||
# job working directories.
|
||||
|
||||
@@ -81,6 +81,7 @@ def test_job_context_discover_outputs_flushes_once(mocker):
|
||||
final_job_state=job_context.final_job_state,
|
||||
)
|
||||
collection_builder.populate()
|
||||
assert spy.call_count == 1
|
||||
assert spy.call_count == 0
|
||||
sa_session.flush()
|
||||
assert len(collection.dataset_instances) == 10
|
||||
assert collection.dataset_instances[0].dataset.file_size == 1
|
||||
|
||||
Reference in New Issue
Block a user