From 3d3d45a41112fab93b3d65b798794adefb26b922 Mon Sep 17 00:00:00 2001 From: guerler Date: Wed, 23 Aug 2023 15:23:14 +0200 Subject: [PATCH] Add consistent support for ldda's, should probably re-consider this use case --- .../Form/Elements/FormData/FormData.test.js | 2 +- .../Form/Elements/FormData/FormData.vue | 29 +++++++++++++------ .../Form/Elements/FormData/variants.ts | 2 +- lib/galaxy/tools/parameters/basic.py | 23 ++++++++++++++- lib/galaxy_test/selenium/test_tool_form.py | 2 +- 5 files changed, 45 insertions(+), 13 deletions(-) diff --git a/client/src/components/Form/Elements/FormData/FormData.test.js b/client/src/components/Form/Elements/FormData/FormData.test.js index cb6254395305..6a2d9ef8ce85 100644 --- a/client/src/components/Form/Elements/FormData/FormData.test.js +++ b/client/src/components/Form/Elements/FormData/FormData.test.js @@ -153,7 +153,7 @@ describe("FormData", () => { expect(wrapper.emitted().input.length).toEqual(1); const message = wrapper.findAll(".form-data-entry-label"); expect(message.length).toBe(1); - expect(message.at(0).text()).toBe("1. dceName1"); + expect(message.at(0).text()).toBe("1. dceName1 (dce)"); const closeButton = wrapper.find(".alert .close"); await closeButton.trigger("click"); expect(wrapper.emitted().input[1][0]).toEqual(null); diff --git a/client/src/components/Form/Elements/FormData/FormData.vue b/client/src/components/Form/Elements/FormData/FormData.vue index 5234b6577d5b..821c49fd78e4 100644 --- a/client/src/components/Form/Elements/FormData/FormData.vue +++ b/client/src/components/Form/Elements/FormData/FormData.vue @@ -191,7 +191,13 @@ const isDCE = computed(() => { return false; } }); - +const isLDDA = computed(() => { + if (props.value && props.value.values.length > 0) { + return props.value.values.findIndex((v) => v.src !== SOURCE.LIBRARY_DATASET) === -1; + } else { + return false; + } +}); /** * Provides placeholder label for select field */ @@ -228,7 +234,8 @@ function handleIncoming(incoming: Record, partial = true) { const newHid = v.hid; const newId = v.id; const newName = v.name ? v.name : newId; - const newSrc = v.history_content_type === "dataset_collection" ? SOURCE.COLLECTION : SOURCE.DATASET; + const newSrc = + v.src || (v.history_content_type === "dataset_collection" ? SOURCE.COLLECTION : SOURCE.DATASET); const newValue = { id: newId, src: newSrc, @@ -288,7 +295,9 @@ function matchOption(entry: DataOption) { */ function matchName(entry: DataOption) { const option = matchOption(entry); - return option?.name || entry.id; + const name = option?.name || entry.id; + const src = option?.src || "unknown"; + return `${name} (${src})`; } /** @@ -310,8 +319,8 @@ function matchValues(entries: Array) { */ function onBrowse() { if (currentVariant.value) { - const library = currentVariant.value.library; - const multiple = currentVariant.value.multiple; + const library = !!currentVariant.value.library; + const multiple = !!currentVariant.value.multiple; getGalaxyInstance().data.dialog( (response: Record) => { handleIncoming(response, false); @@ -372,6 +381,8 @@ function setValue(val: Array | DataOption | null) { let sourceType: string | null = null; if (isDCE.value) { sourceType = values[0].hda ? SOURCE.DATASET : SOURCE.COLLECTION; + } else if (isLDDA.value) { + sourceType = SOURCE.DATASET; } else { sourceType = values[0].src; } @@ -383,7 +394,7 @@ function setValue(val: Array | DataOption | null) { let batch: string = BATCH.DISABLED; if (variantIndex >= 0) { const variantDetails = variant.value[variantIndex]; - if (isDCE.value && variantDetails && variantDetails.batch) { + if ((isLDDA.value || isDCE.value) && variantDetails && variantDetails.batch) { batch = variantDetails.batch; } else { // Switch to another field type if source differs from current field @@ -414,7 +425,7 @@ onMounted(() => { eventBus.$on("waiting", (value: boolean) => { waiting.value = value; }); - if (isDCE.value && props.value && props.value.values) { + if ((isLDDA.value || isDCE.value) && props.value && props.value.values) { setValue(matchValues(props.value.values)); } else { setValue(currentValue.value); @@ -439,10 +450,10 @@ watch( @dragleave.prevent="onDragLeave" @dragover.prevent="onDragOver" @drop.prevent="onDrop"> - + Using the following datasets (dismiss to reset):
- +
diff --git a/client/src/components/Form/Elements/FormData/variants.ts b/client/src/components/Form/Elements/FormData/variants.ts index dd46804fe8a7..1b73712514fe 100644 --- a/client/src/components/Form/Elements/FormData/variants.ts +++ b/client/src/components/Form/Elements/FormData/variants.ts @@ -12,7 +12,7 @@ interface VariantInterface { export const BATCH = { DISABLED: "disabled", ENABLED: "enabled", LINKED: "linked" }; /** Data source variations */ -export const SOURCE = { DATASET: "hda", COLLECTION: "hdca", COLLECTION_ELEMENT: "dce" }; +export const SOURCE = { DATASET: "hda", COLLECTION: "hdca", COLLECTION_ELEMENT: "dce", LIBRARY_DATASET: "ldda" }; /** List of available data input variations */ export const VARIANTS: Record> = { diff --git a/lib/galaxy/tools/parameters/basic.py b/lib/galaxy/tools/parameters/basic.py index 26bbe51a9487..6fb7406c72d5 100644 --- a/lib/galaxy/tools/parameters/basic.py +++ b/lib/galaxy/tools/parameters/basic.py @@ -2137,6 +2137,9 @@ def from_json(self, value, trans, other_values=None): elif isinstance(value, (HistoryDatasetAssociation, LibraryDatasetDatasetAssociation)): rval.append(value) elif isinstance(value, dict) and "src" in value and "id" in value: + if value["src"] == "ldda": + decoded_id = trans.security.decode_id(value["id"]) + rval.append(trans.sa_session.query(LibraryDatasetDatasetAssociation).get(decoded_id)) if value["src"] == "hda": decoded_id = trans.security.decode_id(value["id"]) rval.append(trans.sa_session.query(HistoryDatasetAssociation).get(decoded_id)) @@ -2272,7 +2275,7 @@ def to_dict(self, trans, other_values=None): # For consistency, should these just always be in the dict? d["min"] = self.min d["max"] = self.max - d["options"] = {"dce": [], "hda": [], "hdca": []} + d["options"] = {"dce": [], "ldda": [], "hda": [], "hdca": []} d["tag"] = self.tag # return dictionary without options if context is unavailable @@ -2311,11 +2314,27 @@ def append_dce(dce): } ) + def append_ldda(ldda): + d["options"]["ldda"].append( + { + "id": trans.security.encode_id(ldda.id), + "name": ldda.name, + "src": "ldda", + "tags": [], + "keep": True, + } + ) + # append DCE if isinstance(other_values.get(self.name), DatasetCollectionElement): dce = other_values[self.name] append_dce(dce) + # append LDDA + if isinstance(other_values.get(self.name), LibraryDatasetDatasetAssociation): + ldda = other_values[self.name] + append_ldda(ldda) + # add datasets hda_list = util.listify(other_values.get(self.name)) # Prefetch all at once, big list of visible, non-deleted datasets. @@ -2337,6 +2356,8 @@ def append_dce(dce): append(d["options"]["hda"], hda, f"({hda_state}) {hda.name}", "hda", True) elif isinstance(hda, DatasetCollectionElement): append_dce(hda) + elif isinstance(hda, LibraryDatasetDatasetAssociation): + append_ldda(hda) # add dataset collections dataset_collection_matcher = dataset_matcher_factory.dataset_collection_matcher(dataset_matcher) diff --git a/lib/galaxy_test/selenium/test_tool_form.py b/lib/galaxy_test/selenium/test_tool_form.py index c5e02ce52b88..7f37dedcdc47 100644 --- a/lib/galaxy_test/selenium/test_tool_form.py +++ b/lib/galaxy_test/selenium/test_tool_form.py @@ -243,7 +243,7 @@ def test_rerun_dataset_collection_element(self): self.hda_click_primary_action_button(1, "rerun") self.sleep_for(self.wait_types.UX_RENDER) entry_label = self.components.tool_form.parameter_data_entry_label(parameter="input1").wait_for_visible() - assert entry_label.text == "1. test0" + assert entry_label.text == "1. test0 (dce)" self.tool_form_execute() self.components.history_panel.collection_view.back_to_history.wait_for_and_click() self.history_panel_wait_for_hid_ok(9)