Rename subcollection_type to map_over_type to avoid the need for an api depreciation

This commit is contained in:
guerler
2023-09-09 13:38:38 +03:00
parent 7ac7c82920
commit 092c5c034c
7 changed files with 48 additions and 50 deletions
@@ -29,7 +29,7 @@ const defaultOptions = {
dce: [
{ id: "dce1", name: "dceName1", src: "dce", is_dataset: true },
{ id: "dce2", name: "dceName2", src: "dce" },
{ id: "dce3", name: "dceName3", src: "dce", subcollection_type: "subcollectionType" },
{ id: "dce3", name: "dceName3", src: "dce", map_over_type: "mapOverType" },
{ id: "dce4", name: "dceName4", src: "dce", is_dataset: true },
],
hda: [
@@ -55,12 +55,12 @@ describe("FormData", () => {
const value_0 = {
batch: false,
product: false,
values: [{ id: "hda3", src: "hda", subcollection_type: null }],
values: [{ id: "hda3", src: "hda", map_over_type: null }],
};
const value_1 = {
batch: false,
product: false,
values: [{ id: "hda1", src: "hda", subcollection_type: null }],
values: [{ id: "hda1", src: "hda", map_over_type: null }],
};
const options = wrapper.find(".btn-group").findAll("button");
expect(options.length).toBe(4);
@@ -114,8 +114,8 @@ describe("FormData", () => {
batch: false,
product: false,
values: [
{ id: "hda2", subcollection_type: null, src: "hda" },
{ id: "hda3", subcollection_type: null, src: "hda" },
{ id: "hda2", map_over_type: null, src: "hda" },
{ id: "hda3", map_over_type: null, src: "hda" },
],
});
expect(wrapper.emitted().input.length).toEqual(1);
@@ -127,8 +127,8 @@ describe("FormData", () => {
batch: false,
product: false,
values: [
{ id: "hda2", subcollection_type: null, src: "hda" },
{ id: "hda3", subcollection_type: null, src: "hda" },
{ id: "hda2", map_over_type: null, src: "hda" },
{ id: "hda3", map_over_type: null, src: "hda" },
],
};
expect(wrapper.emitted().input[0][0]).toEqual(value_0);
@@ -136,7 +136,7 @@ describe("FormData", () => {
const value_1 = {
batch: false,
product: false,
values: [{ id: "hda2", subcollection_type: null, src: "hda" }],
values: [{ id: "hda2", map_over_type: null, src: "hda" }],
};
expect(wrapper.emitted().input[1][0]).toEqual(value_1);
await wrapper.setProps({ value: value_1 });
@@ -144,7 +144,7 @@ describe("FormData", () => {
const value_2 = {
batch: false,
product: false,
values: [{ id: "hda2", subcollection_type: null, src: "hda" }],
values: [{ id: "hda2", map_over_type: null, src: "hda" }],
};
expect(wrapper.emitted().input[1][0]).toEqual(value_2);
await wrapper.setProps({ value: value_2 });
@@ -160,7 +160,7 @@ describe("FormData", () => {
const value_0 = {
batch: false,
product: false,
values: [{ id: "dce1", subcollection_type: null, src: "dce" }],
values: [{ id: "dce1", map_over_type: null, src: "dce" }],
};
expect(wrapper.emitted().input[0][0]).toEqual(value_0);
expect(wrapper.emitted().input.length).toEqual(1);
@@ -180,12 +180,12 @@ describe("FormData", () => {
expect(wrapper.emitted().input.length).toEqual(2);
});
it("dataset collection element as hdca without subcollection_type", async () => {
it("dataset collection element as hdca without map_over_type", async () => {
const wrapper = createTarget({
value: { values: [{ id: "dce2", src: "dce" }] },
options: defaultOptions,
});
const value_0 = { batch: true, product: false, values: [{ id: "dce2", subcollection_type: null, src: "dce" }] };
const value_0 = { batch: true, product: false, values: [{ id: "dce2", map_over_type: null, src: "dce" }] };
expect(wrapper.emitted().input[0][0]).toEqual(value_0);
const messageBatch = wrapper.find("[data-description='form data batch label']");
expect(messageBatch.text()).toBe("This data input will be submitted in batch mode.");
@@ -199,7 +199,7 @@ describe("FormData", () => {
const value_0 = {
batch: true,
product: false,
values: [{ id: "dce3", subcollection_type: "subcollectionType", src: "dce" }],
values: [{ id: "dce3", map_over_type: "mapOverType", src: "dce" }],
};
expect(wrapper.emitted().input[0][0]).toEqual(value_0);
const message = wrapper.findAll("[data-description='form data label']");
@@ -207,7 +207,7 @@ describe("FormData", () => {
expect(message.at(0).text()).toBe("1. dceName3 (as dataset collection)");
const messageSubcollection = wrapper.findAll("[data-description='form data collection type']");
expect(messageSubcollection.length).toBe(1);
expect(messageSubcollection.at(0).text()).toBe("Batch mode input with collection type: subcollectionType.");
expect(messageSubcollection.at(0).text()).toBe("Batch mode input with collection type: mapOverType.");
});
it("dataset collection element as hdca mapped to non-batch field", async () => {
@@ -219,7 +219,7 @@ describe("FormData", () => {
const value_0 = {
batch: true,
product: false,
values: [{ id: "dce3", subcollection_type: "subcollectionType", src: "dce" }],
values: [{ id: "dce3", map_over_type: "mapOverType", src: "dce" }],
};
expect(wrapper.emitted().input[0][0]).toEqual(value_0);
});
@@ -233,7 +233,7 @@ describe("FormData", () => {
const value_0 = {
batch: false,
product: false,
values: [{ id: "hdca4", subcollection_type: null, src: "hdca" }],
values: [{ id: "hdca4", map_over_type: null, src: "hdca" }],
};
expect(wrapper.emitted().input[0][0]).toEqual(value_0);
});
@@ -252,8 +252,8 @@ describe("FormData", () => {
batch: true,
product: false,
values: [
{ id: "dce1", subcollection_type: null, src: "dce" },
{ id: "dce4", subcollection_type: null, src: "dce" },
{ id: "dce1", map_over_type: null, src: "dce" },
{ id: "dce4", map_over_type: null, src: "dce" },
],
};
expect(wrapper.emitted().input[0][0]).toEqual(value_0);
@@ -270,7 +270,7 @@ describe("FormData", () => {
expect(wrapper.emitted().input[1][0]).toEqual({
batch: true,
product: false,
values: [{ id: "hdca4", subcollection_type: null, src: "hdca" }],
values: [{ id: "hdca4", map_over_type: null, src: "hdca" }],
});
eventStore.setDragData({ id: "hda2", history_content_type: "dataset" });
dispatchEvent(wrapper, "dragenter");
@@ -278,7 +278,7 @@ describe("FormData", () => {
expect(wrapper.emitted().input[2][0]).toEqual({
batch: false,
product: false,
values: [{ id: "hda2", subcollection_type: null, src: "hda" }],
values: [{ id: "hda2", map_over_type: null, src: "hda" }],
});
});
@@ -291,7 +291,7 @@ describe("FormData", () => {
expect(wrapper.emitted().input[0][0]).toEqual({
batch: false,
product: false,
values: [{ id: "hda3", subcollection_type: null, src: "hda" }],
values: [{ id: "hda3", map_over_type: null, src: "hda" }],
});
const noCheckLinked = wrapper.find("input[type='checkbox']");
expect(noCheckLinked.exists()).toBeFalsy();
@@ -299,7 +299,7 @@ describe("FormData", () => {
expect(wrapper.emitted().input[1][0]).toEqual({
batch: true,
product: false,
values: [{ id: "hda3", subcollection_type: null, src: "hda" }],
values: [{ id: "hda3", map_over_type: null, src: "hda" }],
});
const checkLinked = wrapper.find("input[type='checkbox']");
expect(wrapper.find(".custom-switch span").text()).toBe(
@@ -313,7 +313,7 @@ describe("FormData", () => {
expect(wrapper.emitted().input[2][0]).toEqual({
batch: true,
product: true,
values: [{ id: "hda3", subcollection_type: null, src: "hda" }],
values: [{ id: "hda3", map_over_type: null, src: "hda" }],
});
});
@@ -334,7 +334,7 @@ describe("FormData", () => {
expect(wrapper.emitted().input[i][0]).toEqual({
batch: false,
product: false,
values: [{ id: "hdca4", subcollection_type: null, src: "hdca" }],
values: [{ id: "hdca4", map_over_type: null, src: "hdca" }],
});
}
expect(wrapper.emitted().input.length).toEqual(2);
@@ -346,7 +346,7 @@ describe("FormData", () => {
expect(wrapper.emitted().input[2][0]).toEqual({
batch: false,
product: false,
values: [{ id: "hda3", subcollection_type: null, src: "hda" }],
values: [{ id: "hda3", map_over_type: null, src: "hda" }],
});
const newSelectedValues = wrapper.findAll(SELECTED_VALUE);
expect(newSelectedValues.at(0).text()).toBe("3: hdaName3");
@@ -181,8 +181,8 @@ const isLDDA = computed(() => {
const matchedBatchMode = computed(() => {
const values = matchedValues.value;
if (variant.value && values.length > 0 && values[0]) {
const hasSubcollectionType = values.find((v) => !!v.subcollection_type);
if (hasSubcollectionType) {
const hasMapOverType = values.find((v) => !!v.map_over_type);
if (hasMapOverType) {
return true;
}
const isMultiple = values.length > 1;
@@ -247,7 +247,7 @@ function createValue(val: Array<DataOption> | DataOption | null) {
if (val) {
const values = Array.isArray(val) ? val : [val];
if (variant.value && values.length > 0 && values[0]) {
const hasSubcollectionType = values.find((v) => !!v.subcollection_type);
const hasMapOverType = values.find((v) => !!v.map_over_type);
const isMultiple = values.length > 1;
// Determine source representation (uses only the initial value)
@@ -277,12 +277,12 @@ function createValue(val: Array<DataOption> | DataOption | null) {
// Emit new value
return {
batch: batch !== BATCH.DISABLED || !!hasSubcollectionType,
batch: batch !== BATCH.DISABLED || !!hasMapOverType,
product: batch === BATCH.ENABLED && !currentLinked.value,
values: values.map((entry) => ({
id: entry.id,
src: entry.src,
subcollection_type: entry.subcollection_type || null,
map_over_type: entry.map_over_type || null,
})),
};
}
@@ -491,8 +491,8 @@ watch(
<span>{{ v.name }}</span>
<span>(as {{ getSourceLabel(getSourceType(v)) }})</span>
</div>
<small v-if="v.subcollection_type" class="ml-2" data-description="form data collection type">
Batch mode input with collection type: {{ v.subcollection_type }}.
<small v-if="v.map_over_type" class="ml-2" data-description="form data collection type">
Batch mode input with collection type: {{ v.map_over_type }}.
</small>
</div>
</b-alert>
@@ -3,8 +3,8 @@ export interface DataOption {
hid: number;
is_dataset?: boolean;
keep: boolean;
map_over_type?: string;
name: string;
src: string;
subcollection_type?: string;
tags: Array<string>;
}
+2 -2
View File
@@ -2299,7 +2299,7 @@ class DataToolParameter(BaseDataToolParameter):
"keep": keep,
}
if subcollection_type:
value["subcollection_type"] = subcollection_type
value["map_over_type"] = subcollection_type
return list.append(value)
def append_dce(dce):
@@ -2553,8 +2553,8 @@ class DataCollectionToolParameter(BaseDataToolParameter):
d["options"]["hdca"].append(
{
"id": trans.security.encode_id(hdca.id),
"subcollection_type": subcollection_type,
"hid": hdca.hid,
"map_over_type": subcollection_type,
"name": name,
"src": "hdca",
"tags": [t.user_tname if not t.value else f"{t.user_tname}:{t.value}" for t in hdca.tags],
+1 -1
View File
@@ -260,7 +260,7 @@ def __expand_collection_parameter(trans, input_key, incoming_val, collections_to
if src != "hdca":
raise exceptions.ToolMetaParameterException(f"Invalid dataset collection source type {src}")
encoded_hdc_id = incoming_val["id"]
subcollection_type = incoming_val.get("subcollection_type", None)
subcollection_type = incoming_val.get("map_over_type", None)
except TypeError:
encoded_hdc_id = incoming_val
subcollection_type = None
+3 -5
View File
@@ -841,14 +841,14 @@ steps:
list_id_a = self.__history_with_ok_collection(collection_type="list:pair", history_id=history_id)
inputs = json.dumps(
{
"f1": {"batch": True, "values": [{"src": "hdca", "id": list_id_a, "subcollection_type": "paired"}]},
"f1": {"batch": True, "values": [{"src": "hdca", "id": list_id_a, "map_over_type": "paired"}]},
}
)
self._job_search(tool_id="collection_paired_test", history_id=history_id, inputs=inputs)
def _get_simple_rerun_params(self, history_id, private=False):
list_id_a = self.__history_with_ok_collection(collection_type="list:pair", history_id=history_id)
inputs = {"f1": {"batch": True, "values": [{"src": "hdca", "id": list_id_a, "subcollection_type": "paired"}]}}
inputs = {"f1": {"batch": True, "values": [{"src": "hdca", "id": list_id_a, "map_over_type": "paired"}]}}
run_response = self._run(
history_id=history_id,
tool_id="collection_paired_test",
@@ -907,9 +907,7 @@ steps:
assert first_element["element_type"] == "dataset_collection"
assert first_element["element_identifier"] == "test0"
assert first_element["model_class"] == "DatasetCollectionElement"
inputs = {
"input1": {"batch": True, "values": [{"src": "hdca", "id": list_list_id, "subcollection_type": "list"}]}
}
inputs = {"input1": {"batch": True, "values": [{"src": "hdca", "id": list_list_id, "map_over_type": "list"}]}}
run_response = self._run(
history_id=history_id,
tool_id="identifier_collection",
+9 -9
View File
@@ -609,7 +609,7 @@ class TestToolsApi(ApiTestCase, TestsTools):
inputs = {
"input": {
"batch": True,
"values": [{"src": "hdca", "subcollection_type": "paired", "id": hdca_id}],
"values": [{"src": "hdca", "map_over_type": "paired", "id": hdca_id}],
}
}
response = self._run("__UNZIP_COLLECTION__", history_id, inputs, assert_ok=True)
@@ -795,7 +795,7 @@ class TestToolsApi(ApiTestCase, TestsTools):
inputs = {
"input": {
"batch": batch,
"values": [{"subcollection_type": "list:paired", "src": "hdca", "id": failed_hdca_id}],
"values": [{"map_over_type": "list:paired", "src": "hdca", "id": failed_hdca_id}],
},
}
else:
@@ -1691,7 +1691,7 @@ class TestToolsApi(ApiTestCase, TestsTools):
@skip_without_tool("output_action_change_format_paired")
def test_map_over_with_nested_paired_output_format_actions(self, history_id):
hdca_id = self.__build_nested_list(history_id)
inputs = {"input": {"batch": True, "values": [dict(subcollection_type="paired", src="hdca", id=hdca_id)]}}
inputs = {"input": {"batch": True, "values": [dict(map_over_type="paired", src="hdca", id=hdca_id)]}}
create = self._run("output_action_change_format_paired", history_id, inputs).json()
outputs = create["outputs"]
jobs = create["jobs"]
@@ -2109,7 +2109,7 @@ class TestToolsApi(ApiTestCase, TestsTools):
def test_paired_input_map_over_nested_collections(self, history_id):
hdca_id = self.__build_nested_list(history_id)
inputs = {
"input1": {"batch": True, "values": [dict(subcollection_type="paired", src="hdca", id=hdca_id)]},
"input1": {"batch": True, "values": [dict(map_over_type="paired", src="hdca", id=hdca_id)]},
}
self.dataset_populator.wait_for_history(history_id, assert_ok=True)
create = self._run("collection_paired_structured_like", history_id, inputs, assert_ok=True)
@@ -2127,7 +2127,7 @@ class TestToolsApi(ApiTestCase, TestsTools):
hdca_id = self.__build_nested_list(history_id)
inputs = {
"cond|cond_param": "paired",
"cond|input1": {"batch": True, "values": [dict(subcollection_type="paired", src="hdca", id=hdca_id)]},
"cond|input1": {"batch": True, "values": [dict(map_over_type="paired", src="hdca", id=hdca_id)]},
}
self.dataset_populator.wait_for_history(history_id, assert_ok=True)
create = self._run("collection_paired_conditional_structured_like", history_id, inputs, assert_ok=True)
@@ -2440,7 +2440,7 @@ class TestToolsApi(ApiTestCase, TestsTools):
"f1": {"src": "hdca", "id": hdca1_id},
"f2": {
"batch": True,
"values": [{"src": "hdca", "subcollection_type": "list", "id": hdca2_id}],
"values": [{"src": "hdca", "map_over_type": "list", "id": hdca2_id}],
},
}
create = self._run("multi_data_param", history_id, inputs, assert_ok=True)
@@ -2569,7 +2569,7 @@ class TestToolsApi(ApiTestCase, TestsTools):
inputs = {
"f1": {
"batch": True,
"values": [{"src": "hdca", "subcollection_type": "paired", "id": hdca_list_id}],
"values": [{"src": "hdca", "map_over_type": "paired", "id": hdca_list_id}],
}
}
self._check_simple_subcollection_mapping(history_id, inputs)
@@ -2598,7 +2598,7 @@ class TestToolsApi(ApiTestCase, TestsTools):
inputs = {
"f1": {
"batch": True,
"values": [{"src": "hdca", "subcollection_type": "paired", "id": nested_list_id}],
"values": [{"src": "hdca", "map_over_type": "paired", "id": nested_list_id}],
},
"f2": {
"batch": True,
@@ -2975,7 +2975,7 @@ class TestToolsApi(ApiTestCase, TestsTools):
dataset_collection = self.dataset_collection_populator.wait_for_fetched_collection(fetch_response)
hdca_id = dataset_collection["id"]
inputs = {
"input1": {"batch": True, "values": [dict(subcollection_type="paired", src="hdca", id=hdca_id)]},
"input1": {"batch": True, "values": [dict(map_over_type="paired", src="hdca", id=hdca_id)]},
}
self.dataset_populator.wait_for_history(history_id, assert_ok=True)
create = self._run("collection_paired_structured_like", history_id, inputs, assert_ok=True)