Unverified Commit b97825b7 authored by John Davis's avatar John Davis Committed by GitHub
Browse files

Merge pull request #18036 from mvdbeek/implicit_conversion_no_hid_fix

[24.0] Fix History Dataset Association creation so that hid is always set
parents 7722cf0e 121f27e2
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -3751,7 +3751,7 @@ export interface components {
             * Element Type
             * @description The type of the element. Used to interpret the `object` field.
             */
            element_type: components["schemas"]["DCEType"];
            element_type?: components["schemas"]["DCEType"] | null;
            /**
             * Dataset Collection Element ID
             * @example 0123456789ABCDEF
@@ -3767,10 +3767,11 @@ export interface components {
             * Object
             * @description The element's specific data depending on the value of `element_type`.
             */
            object:
            object?:
                | components["schemas"]["HDAObject"]
                | components["schemas"]["HDADetailed"]
                | components["schemas"]["DCObject"];
                | components["schemas"]["DCObject"]
                | null;
        };
        /**
         * DCEType
+5 −1
Original line number Diff line number Diff line
@@ -842,7 +842,11 @@ class Data(metaclass=DataMeta):
        # Make the target datatype available to the converter
        params["__target_datatype__"] = target_type
        # Run converter, job is dispatched through Queue
        job, converted_datasets, *_ = converter.execute(trans, incoming=params, set_output_hid=visible, history=history)
        job, converted_datasets, *_ = converter.execute(
            trans, incoming=params, set_output_hid=visible, history=history, flush_job=False
        )
        for converted_dataset in converted_datasets.values():
            original_dataset.attach_implicitly_converted_dataset(trans.sa_session, converted_dataset, target_type)
        trans.app.job_manager.enqueue(job, tool=converter)
        if len(params) > 0:
            trans.log_event(f"Converter params: {str(params)}", tool_id=converter.id)
+1 −17
Original line number Diff line number Diff line
@@ -11,7 +11,6 @@ from urllib.parse import quote_plus

from galaxy.datatypes.data import Data
from galaxy.model import DatasetInstance
from galaxy.model.base import transaction
from galaxy.schema.schema import DatasetState
from galaxy.util import string_as_bool
from galaxy.util.template import fill_template
@@ -182,22 +181,7 @@ class DisplayApplicationDataParameter(DisplayApplicationParameter):
                if target_ext and not converted_dataset:
                    if isinstance(data, DisplayDataValueWrapper):
                        data = data.value
                    new_data = next(
                        iter(
                            data.datatype.convert_dataset(
                                trans, data, target_ext, return_output=True, visible=False
                            ).values()
                        )
                    )
                    new_data.hid = data.hid
                    new_data.name = data.name
                    trans.sa_session.add(new_data)
                    assoc = trans.app.model.ImplicitlyConvertedDatasetAssociation(
                        parent=data, file_type=target_ext, dataset=new_data, metadata_safe=False
                    )
                    trans.sa_session.add(assoc)
                    with transaction(trans.sa_session):
                        trans.sa_session.commit()
                    data.datatype.convert_dataset(trans, data, target_ext, return_output=True, visible=False)
                elif converted_dataset and converted_dataset.state == DatasetState.ERROR:
                    raise Exception(f"Dataset conversion failed for data parameter: {self.name}")
        return self.get_value(other_values, dataset_hash, user_hash, trans)
+2 −0
Original line number Diff line number Diff line
@@ -85,5 +85,7 @@ class DatasetProtocol(

    def set_peek(self) -> None: ...

    def attach_implicitly_converted_dataset(self, session, new_dataset, target_ext: str) -> None: ...


class DatasetHasHidProtocol(DatasetProtocol, HasHid, Protocol): ...
+4 −4
Original line number Diff line number Diff line
@@ -95,7 +95,7 @@ class DatasetCollectionManager:
        # TODO: prebuild all required HIDs and send them in so no need to flush in between.
        dataset_collection = self.precreate_dataset_collection(
            structure,
            allow_unitialized_element=implicit_output_name is not None,
            allow_uninitialized_element=implicit_output_name is not None,
            completed_collection=completed_collection,
            implicit_output_name=implicit_output_name,
        )
@@ -112,10 +112,10 @@ class DatasetCollectionManager:
        return instance

    def precreate_dataset_collection(
        self, structure, allow_unitialized_element=True, completed_collection=None, implicit_output_name=None
        self, structure, allow_uninitialized_element=True, completed_collection=None, implicit_output_name=None
    ):
        has_structure = not structure.is_leaf and structure.children_known
        if not has_structure and allow_unitialized_element:
        if not has_structure and allow_uninitialized_element:
            dataset_collection = model.DatasetCollectionElement.UNINITIALIZED_ELEMENT
        elif not has_structure:
            collection_type_description = structure.collection_type_description
@@ -143,7 +143,7 @@ class DatasetCollectionManager:
                        element = model.DatasetCollectionElement.UNINITIALIZED_ELEMENT
                    else:
                        element = self.precreate_dataset_collection(
                            substructure, allow_unitialized_element=allow_unitialized_element
                            substructure, allow_uninitialized_element=allow_uninitialized_element
                        )

                element = model.DatasetCollectionElement(
Loading