Skip to content

Commit

Permalink
Create new dryrun implemented
Browse files Browse the repository at this point in the history
- todo: input files
  • Loading branch information
AleenaThomas-gh committed Jul 10, 2023
1 parent e42ff42 commit d1cb884
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 31 deletions.
6 changes: 4 additions & 2 deletions frontend-dev/src/queries/create_dry_run.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { gql } from 'graphql-request';

const createDryRunMutation = gql`
mutation createDryRun($argoWorkflow: ArgoWorkflow, $projectId: String, $dryRunId: String) {
createDryRun(argoWorkflow: $argoWorkflow, projectId: $projectId, dryRunId: $dryRunId)
mutation createDryRun($input: CreateDryRunInput!) {
createDryRun(input: $input) {
id
}
}
`;

Expand Down
1 change: 1 addition & 0 deletions frontend-dev/src/queries/get_all_dryruns.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const allDryRunsQuery = gql`
query($projectId: String!) {
project(projectId: $projectId) {
name
id
workflowTemplates {
argoWorkflowTemplate
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
import { modalStore } from '@skeletonlabs/skeleton';
import { selectedProject, graphQLClient } from '../../../../stores/stores.js';
import createDryRunMutation from '../../../../queries/create_dry_run.js';
import createWorkflowTemplateMutation from '../../../../queries/create_workflow_template.js';
import allDryRunsQuery from '../../../../queries/get_all_dryruns.js';
import type { Project } from '../../../../types.js';
export let parent: any;
type Parameters = {
Expand Down Expand Up @@ -43,42 +44,33 @@
}
const taskList = parseTaskList();
// modify workflow template from project to create a valid argoWorkflow input for create new dryrun
function newWorkflowTemplate(template: { metadata: any; spec: any }) {
const newWorkflowTemplate = template;
newWorkflowTemplate.metadata =
formData.name == ''
? { generateName: newWorkflowTemplate.metadata.generateName }
: { name: formData.name };
return newWorkflowTemplate;
}
async function onCreateDryRunSubmit(): Promise<void> {
// TODO: work in progress
modalStore.close();
const newName = (Math.random() + 1).toString(36).substring(7);
// create a new workflow template with the updated env values
const variables1 = {
input: {
argoWorkflowTemplate: $selectedProject?.workflowTemplates[0].argoWorkflowTemplate,
name: newName,
projectId: $selectedProject?.id
}
};
const newWorkflowTemplateResponse = await $graphQLClient.request(
createWorkflowTemplateMutation,
variables1
);
// create a new argoworkflowtemplate with the updated env values
const newDryRun = {
metadata: {
generateName: $selectedProject?.name
},
spec: {
workflowTemplateRef: {
name: newName
},
entrypoint: $selectedProject?.workflowTemplates[0].argoWorkflowTemplate.metadata.enr
}
};
const variables = {
input: {
projectId: $selectedProject?.id,
argoWorkflow: newDryRun
argoWorkflow: newWorkflowTemplate(
$selectedProject?.workflowTemplates[0].argoWorkflowTemplate
)
}
};
const responseCreateDryRun = await $graphQLClient.request(createDryRunMutation, variables);
// refresh dry runs list
const response: { project: Project } = await $graphQLClient.request(allDryRunsQuery, {
projectId: $selectedProject?.id
});
$selectedProject = response.project;
}
</script>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,12 @@
const variables1 = {
project: {name: formData.name},
};
const responseCreateProject : {createProject: Project}= await get(graphQLClient).request(createProjectMutation, variables1);
if (formData.template != '') {
const variables2 = {
input: {
argoWorkflowTemplate: formData.template,
argoWorkflowTemplate: JSON.parse(formData.template),
name: formData.name,
projectId: responseCreateProject.createProject.id,
}
Expand Down

0 comments on commit d1cb884

Please sign in to comment.