Merge pull request #10619 from OlegZharkov/trs-auto-import

auto-import workflow with trs
This commit is contained in:
John Chilton
2020-11-08 08:02:42 -05:00
committed by GitHub
6 changed files with 69 additions and 28 deletions
+44 -18
View File
@@ -1,22 +1,29 @@
<template>
<b-card title="GA4GH Tool Registry Server (TRS) Workflow Import">
<b-alert :show="hasErrorMessage" variant="danger">{{ errorMessage }}</b-alert>
<div>
<b>TRS Server:</b>
<TrsServerSelection
:query-trs-server="queryTrsServer"
:query-trs-id="queryTrsId"
@onTrsSelection="onTrsSelection"
@onError="onTrsSelectionError"
/>
</div>
<div>
<b>TRS ID:</b>
<b-form-input v-model="toolId" />
</div>
<trs-tool :trs-tool="trsTool" v-if="trsTool != null" @onImport="importVersion(trsTool.id, $event)" />
</b-card>
<div>
<b-card title="GA4GH Tool Registry Server (TRS) Workflow Import">
<b-alert :show="hasErrorMessage" variant="danger">{{ errorMessage }}</b-alert>
<div>
<b>TRS Server:</b>
<TrsServerSelection
:query-trs-server="queryTrsServer"
:query-trs-id="queryTrsId"
@onTrsSelection="onTrsSelection"
@onError="onTrsSelectionError"
/>
</div>
<div v-if="isAutoImport" class="text-center my-2">
<b-spinner class="align-middle"></b-spinner>
<strong>Loading your Workflow...</strong>
</div>
<div v-else>
<div>
<b>TRS ID:</b>
<b-form-input v-model="toolId" />
</div>
<trs-tool :trs-tool="trsTool" v-if="trsTool" @onImport="importVersion(trsTool.id, $event)" />
</div>
</b-card>
</div>
</template>
<script>
@@ -24,6 +31,7 @@ import Vue from "vue";
import BootstrapVue from "bootstrap-vue";
import { Services } from "./services";
import TrsMixin from "./trsMixin";
import { Toast } from "ui/toast";
Vue.use(BootstrapVue);
@@ -38,6 +46,14 @@ export default {
type: String,
default: null,
},
queryTrsVersionId: {
type: String,
default: null,
},
isRun: {
type: Boolean,
default: false,
},
},
created() {
this.services = new Services();
@@ -49,6 +65,7 @@ export default {
toolId: null,
trsTool: null,
errorMessage: null,
isAutoImport: this.queryTrsVersionId && this.queryTrsServer && this.queryTrsId,
};
},
computed: {
@@ -80,6 +97,15 @@ export default {
.then((tool) => {
this.trsTool = tool;
this.errorMessage = null;
if (this.isAutoImport) {
const version = this.trsTool.versions.find((version) => version.id === this.queryTrsVersionId);
if (version) {
this.importVersion(this.trsTool.id, version, this.isRun);
} else {
Toast.warning(`Specified version: ${this.queryTrsVersionId} doesn't exist`);
this.isAutoImport = false;
}
}
})
.catch((errorMessage) => {
this.trsTool = null;
@@ -31,6 +31,7 @@ import { getGalaxyInstance } from "app";
import axios from "axios";
import Vue from "vue";
import BootstrapVue from "bootstrap-vue";
import { redirectOnImport } from "./utils";
Vue.use(BootstrapVue);
@@ -67,9 +68,7 @@ export default {
axios
.post(`${getAppRoot()}api/workflows`, formData)
.then((response) => {
window.location = `${getAppRoot()}workflows/list?message=${
response.data.message
}&status=success`;
redirectOnImport(getAppRoot(), response.data);
})
.catch((error) => {
const message = error.response.data && error.response.data.err_msg;
+3 -3
View File
@@ -1,6 +1,7 @@
import { getAppRoot } from "onload/loadConfig";
import TrsServerSelection from "./TrsServerSelection";
import TrsTool from "./TrsTool";
import { redirectOnImport } from "./utils";
export default {
components: {
@@ -8,12 +9,11 @@ export default {
TrsTool,
},
methods: {
importVersion(toolId, version) {
importVersion(toolId, version, isRunFormRedirect = false) {
this.services
.importTrsTool(this.trsSelection.id, toolId, version.name)
.then((response_data) => {
// copied from the WorkflowImport, de-duplicate somehow
window.location = `${getAppRoot()}workflows/list?message=${response_data.message}&status=success`;
redirectOnImport(getAppRoot(), response_data, isRunFormRedirect);
})
.catch((errorMessage) => {
this.errorMessage = errorMessage || "Import failed for an unknown reason.";
+5
View File
@@ -0,0 +1,5 @@
export function redirectOnImport(appRoot, response, isRunFormRedirect = false) {
isRunFormRedirect
? (window.location = `${appRoot}workflows/run?id=${response.id}`)
: (window.location = `${appRoot}workflows/list?message=${response.message}&status=success`);
}
@@ -342,9 +342,13 @@ export const getAnalysisRouter = (Galaxy) =>
show_workflows_trs_import: function () {
const queryTrsServer = QueryStringParsing.get("trs_server");
const queryTrsId = QueryStringParsing.get("trs_id");
const queryTrsVersionId = QueryStringParsing.get("trs_version");
const isRun = QueryStringParsing.get("run_form") === "true";
const propsData = {
queryTrsServer,
queryTrsId,
queryTrsVersionId,
isRun,
};
this._display_vue_helper(TrsImport, propsData);
},
+11 -4
View File
@@ -678,14 +678,21 @@ class WorkflowsAPIController(BaseAPIController, UsesStoredWorkflowMixin, UsesAnn
raise exceptions.MessageException("The data content is missing.")
raw_workflow_description = self.__normalize_workflow(trans, data)
workflow, missing_tool_tups = self._workflow_from_dict(trans, raw_workflow_description, source=source)
workflow_id = workflow.id
workflow = workflow.latest_workflow
response = {"message": "Workflow '%s' imported successfully." % escape(workflow.name), "status": "success",
"id": trans.security.encode_id(workflow_id)}
if workflow.has_errors:
return {"message": "Imported, but some steps in this workflow have validation errors.", "status": "error"}
response["message"] = "Imported, but some steps in this workflow have validation errors."
response["status"] = "error"
elif len(workflow.steps) == 0:
return {"message": "Imported, but this workflow has no steps.", "status": "error"}
response["message"] = "Imported, but this workflow has no steps."
response["status"] = "error"
elif workflow.has_cycles:
return {"message": "Imported, but this workflow contains cycles.", "status": "error"}
return {"message": "Workflow '%s' imported successfully." % escape(workflow.name), "status": "success"}
response["message"] = "Imported, but this workflow contains cycles."
response["status"] = "error"
return response
def __api_import_new_workflow(self, trans, payload, **kwd):
data = payload['workflow']