Skip to content

Commit

Permalink
Input parameter schema.
Browse files Browse the repository at this point in the history
  • Loading branch information
jmchilton committed Jan 25, 2024
1 parent 4fe497f commit e58ffb7
Show file tree
Hide file tree
Showing 97 changed files with 6,133 additions and 188 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/framework.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ jobs:
strategy:
matrix:
python-version: ['3.7']
use-legacy-api: ['0', '1']
services:
postgres:
image: postgres:13
Expand Down Expand Up @@ -66,7 +67,7 @@ jobs:
path: 'galaxy root/.venv'
key: gxy-venv-${{ runner.os }}-${{ steps.full-python-version.outputs.version }}-${{ hashFiles('galaxy root/requirements.txt') }}-framework
- name: Run tests
run: ./run_tests.sh --coverage --framework
run: GALAXY_TEST_USE_LEGACY_TOOL_API="${{ matrix.use-legacy-api }}" ./run_tests.sh --coverage --framework
working-directory: 'galaxy root'
- uses: codecov/codecov-action@v3
with:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ doc/build
doc/schema.md
doc/source/admin/config_logging_default_yaml.rst
doc/source/dev/schema.md
doc/source/dev/plantuml.jar
client/docs/dist

# Webpack stats
Expand Down
228 changes: 156 additions & 72 deletions client/src/components/Tool/ToolForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@
@onChange="onChange"
@onValidation="onValidation" />
</div>

<div
v-if="emailAllowed(config, currentUser) || remapAllowed || reuseAllowed(currentUser)"
class="mt-2 mb-4">
Expand Down Expand Up @@ -81,15 +80,15 @@
<template v-slot:header-buttons>
<ButtonSpinner
id="execute"
title="Run Tool"
title="runButtonTitle"
class="btn-sm"
:wait="showExecuting"
:tooltip="tooltip"
@onClick="onExecute(config, currentHistoryId)" />
</template>
<template v-slot:buttons>
<ButtonSpinner
title="Run Tool"
title="runButtonTitle"
class="mt-3 mb-3"
:wait="showExecuting"
:tooltip="tooltip"
Expand All @@ -101,13 +100,15 @@
</template>

<script>
import { getAppRoot } from "onload/loadConfig";
import axios from "axios";
import { getGalaxyInstance } from "app";
import { useUserStore } from "@/stores/userStore";
import { useHistoryStore } from "@/stores/historyStore";
import { useHistoryItemsStore } from "stores/history/historyItemsStore";
import { useJobStore } from "stores/jobStore";
import { mapState, mapActions } from "pinia";
import { getToolFormData, updateToolFormData, submitJob } from "./services";
import { getToolFormData, getToolInputs, updateToolFormData, submitJob, submitToolRequest } from "./services";
import { allowCachedJobs } from "./utilities";
import { refreshContentsWrapper } from "utils/data";
import ToolCard from "./ToolCard";
Expand All @@ -119,6 +120,7 @@ import FormElement from "components/Form/FormElement";
import ToolEntryPoints from "components/ToolEntryPoints/ToolEntryPoints";
import ToolRecommendation from "../ToolRecommendation";
import Heading from "components/Common/Heading";
import { structuredInputs } from "./structured";
export default {
components: {
Expand Down Expand Up @@ -178,6 +180,8 @@ export default {
validationScrollTo: null,
currentVersion: this.version,
preferredObjectStoreId: null,
toolInputs: null,
submissionStateMessage: null,
};
},
computed: {
Expand Down Expand Up @@ -216,6 +220,17 @@ export default {
initialized() {
return this.formData !== undefined;
},
runButtonTitle() {
if (this.showExecuting) {
if (this.submissionStateMessage) {
return this.submissionStateMessage;
} else {
return "Run Tool";
}
} else {
return "Run Tool";
}
},
},
watch: {
currentHistoryId() {
Expand Down Expand Up @@ -266,10 +281,37 @@ export default {
onChangeVersion(newVersion) {
this.requestTool(newVersion);
},
waitOnRequest(response, requestContent, config, prevRoute) {
const toolRequestId = response.tool_request_id;
const handleRequestState = (toolRequestStateResponse) => {
const state = toolRequestStateResponse.data;
console.log(`state is ${state}`);
if (["new"].indexOf(state) !== -1) {
setTimeout(doRequestCheck, 1000);
} else if (state == "failed") {
this.handleError(null, requestContent);
} else {
refreshContentsWrapper();
this.showForm = false;
this.showSuccess = true;
this.handleSubmissionComplete(config, prevRoute);
}
};
const doRequestCheck = () => {
axios
.get(`${getAppRoot()}api/tool_requests/${toolRequestId}/state`)
.then(handleRequestState)
.catch((e) => this.handleError(e, requestContent));
};
setTimeout(doRequestCheck, 1000);
},
requestTool(newVersion) {
this.currentVersion = newVersion || this.currentVersion;
this.disabled = true;
console.debug("ToolForm - Requesting tool.", this.id);
getToolInputs(this.id, this.currentVersion).then((data) => {
this.toolInputs = data;
});
return getToolFormData(this.id, this.currentVersion, this.job_id, this.history_id)
.then((data) => {
this.formConfig = data;
Expand All @@ -294,87 +336,129 @@ export default {
onUpdatePreferredObjectStoreId(preferredObjectStoreId) {
this.preferredObjectStoreId = preferredObjectStoreId;
},
handleSubmissionComplete(config, prevRoute) {
const changeRoute = prevRoute === this.$route.fullPath;
if (changeRoute) {
this.$router.push(`/jobs/submission/success`);
} else {
if ([true, "true"].includes(config.enable_tool_recommendations)) {
this.showRecommendation = true;
}
document.querySelector(".center-panel").scrollTop = 0;
}
},
handleError(e, errorContent) {
this.errorMessage = e?.response?.data?.err_msg;
this.showExecuting = false;
this.submissionStateMessage = null;
let genericError = true;
const errorData = e && e.response && e.response.data && e.response.data.err_data;
if (errorData) {
const errorEntries = Object.entries(errorData);
if (errorEntries.length > 0) {
this.validationScrollTo = errorEntries[0];
genericError = false;
}
}
if (genericError) {
this.showError = true;
this.errorTitle = "Job submission failed.";
this.errorContent = errorContent;
}
},
onExecute(config, historyId) {
if (this.validationInternal) {
this.validationScrollTo = this.validationInternal.slice();
return;
}
this.showExecuting = true;
const jobDef = {
history_id: historyId,
tool_id: this.formConfig.id,
tool_version: this.formConfig.version,
inputs: {
...this.formData,
},
this.submissionStateMessage = "Preparing Request";
const inputs = {
...this.formData,
};
if (this.useEmail) {
jobDef.inputs["send_email_notification"] = true;
}
if (this.useJobRemapping) {
jobDef.inputs["rerun_remap_job_id"] = this.job_id;
}
if (this.useCachedJobs) {
jobDef.inputs["use_cached_job"] = true;
const toolId = this.formConfig.id;
const toolVersion = this.formConfig.version;
let validatedInputs = null;
try {
validatedInputs = structuredInputs(inputs, this.toolInputs);
} catch {
// failed validation, just use legacy API
}
if (this.preferredObjectStoreId) {
jobDef.preferred_object_store_id = this.preferredObjectStoreId;
}
console.debug("toolForm::onExecute()", jobDef);
const prevRoute = this.$route.fullPath;
submitJob(jobDef).then(
(jobResponse) => {
this.showExecuting = false;
let changeRoute = false;
refreshContentsWrapper();
if (jobResponse.produces_entry_points) {
this.showEntryPoints = true;
this.entryPoints = jobResponse.jobs;
}
const nJobs = jobResponse && jobResponse.jobs ? jobResponse.jobs.length : 0;
if (nJobs > 0) {
this.showForm = false;
const toolName = this.toolName;
this.saveLatestResponse({
jobDef,
jobResponse,
toolName,
});
changeRoute = prevRoute === this.$route.fullPath;
} else {
this.showError = true;
this.showForm = true;
this.errorTitle = "Job submission rejected.";
this.errorContent = jobResponse;
if (validatedInputs) {
const toolRequest = {
history_id: historyId,
tool_id: toolId,
tool_version: toolVersion,
inputs: validatedInputs,
};
if (this.useCachedJobs) {
toolRequest.use_cached_jobs = true;
}
if (this.preferredObjectStoreId) {
toolRequest.preferred_object_store_id = this.preferredObjectStoreId;
}
this.submissionStateMessage = "Sending Request";
submitToolRequest(toolRequest).then(
(jobResponse) => {
this.submissionStateMessage = "Processing Request";
console.log(jobResponse);
this.waitOnRequest(jobResponse, toolRequest, config, prevRoute);
},
(e) => {
this.handleError(e, toolRequest);
}
if (changeRoute) {
this.$router.push(`/jobs/submission/success`);
} else {
if ([true, "true"].includes(config.enable_tool_recommendations)) {
this.showRecommendation = true;
);
} else {
const jobDef = {
history_id: historyId,
tool_id: toolId,
tool_version: toolVersion,
inputs: inputs,
};
if (this.useEmail) {
jobDef.inputs["send_email_notification"] = true;
}
if (this.useJobRemapping) {
jobDef.inputs["rerun_remap_job_id"] = this.job_id;
}
if (this.useCachedJobs) {
jobDef.inputs["use_cached_job"] = true;
}
if (this.preferredObjectStoreId) {
jobDef.preferred_object_store_id = this.preferredObjectStoreId;
}
console.debug("toolForm::onExecute()", jobDef);
submitJob(jobDef).then(
(jobResponse) => {
this.showExecuting = false;
refreshContentsWrapper();
if (jobResponse.produces_entry_points) {
this.showEntryPoints = true;
this.entryPoints = jobResponse.jobs;
}
document.querySelector("#center").scrollTop = 0;
}
},
(e) => {
this.errorMessage = e?.response?.data?.err_msg;
this.showExecuting = false;
let genericError = true;
const errorData = e && e.response && e.response.data && e.response.data.err_data;
if (errorData) {
const errorEntries = Object.entries(errorData);
if (errorEntries.length > 0) {
this.validationScrollTo = errorEntries[0];
genericError = false;
const nJobs = jobResponse && jobResponse.jobs ? jobResponse.jobs.length : 0;
if (nJobs > 0) {
this.showForm = false;
const toolName = this.toolName;
this.saveLatestResponse({
jobDef,
jobResponse,
toolName,
});
} else {
this.showError = true;
this.showForm = true;
this.errorTitle = "Job submission rejected.";
this.errorContent = jobResponse;
}
this.handleSubmissionComplete(config, prevRoute);
},
(e) => {
this.handleError(e, jobDef);
}
if (genericError) {
this.showError = true;
this.errorTitle = "Job submission failed.";
this.errorContent = jobDef;
}
}
);
);
}
},
},
};
Expand Down
3 changes: 2 additions & 1 deletion client/src/components/Tool/ToolSuccess.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const jobStore = useJobStore();
const router = useRouter();
const jobDef = computed(() => responseVal.value.jobDef);
const usedToolRequest = computed(() => responseVal.value.usedToolRequest);
const jobResponse = computed(() => responseVal.value.jobResponse);
const responseVal = computed(() => jobStore.getLatestResponse);
const showRecommendation = computed(() => config.value.enable_tool_recommendations);
Expand All @@ -32,7 +33,7 @@ onMounted(() => {
<div v-if="jobResponse.produces_entry_points">
<ToolEntryPoints v-for="job in jobResponse.jobs" :key="job.id" :job-id="job.id" />
</div>
<ToolSuccessMessage :job-response="jobResponse" :tool-name="toolName" />
<ToolSuccessMessage :job-response="jobResponse" :tool-name="toolName" :used-tool-request="usedToolRequest"/>
<Webhook type="tool" :tool-id="jobDef.tool_id" />
<ToolRecommendation v-if="showRecommendation" :tool-id="jobDef.tool_id" />
</section>
Expand Down
Loading

0 comments on commit e58ffb7

Please sign in to comment.