Skip to content

Commit

Permalink
Fix step type serialization for StoredWorkflowDetailed models
Browse files Browse the repository at this point in the history
  • Loading branch information
mvdbeek committed Mar 14, 2024
1 parent 42581d7 commit 0fafdfa
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 62 deletions.
54 changes: 24 additions & 30 deletions client/src/api/schema/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6852,10 +6852,11 @@ export interface components {
tool_version?: string | null;
/**
* Type
* @description The type of workflow module.
* @default data_collection_input
* @constant
*/
type?: components["schemas"]["WorkflowModuleType"];
type: "data_collection_input";
/** When */
when: string | null;
};
/** InputDataStep */
InputDataStep: {
Expand Down Expand Up @@ -6893,10 +6894,11 @@ export interface components {
tool_version?: string | null;
/**
* Type
* @description The type of workflow module.
* @default data_input
* @constant
*/
type?: components["schemas"]["WorkflowModuleType"];
type: "data_input";
/** When */
when: string | null;
};
/** InputParameterStep */
InputParameterStep: {
Expand Down Expand Up @@ -6934,10 +6936,11 @@ export interface components {
tool_version?: string | null;
/**
* Type
* @description The type of workflow module.
* @default parameter_input
* @constant
*/
type?: components["schemas"]["WorkflowModuleType"];
type: "parameter";
/** When */
when: string | null;
};
/** InputReferenceByLabel */
InputReferenceByLabel: {
Expand Down Expand Up @@ -9705,10 +9708,11 @@ export interface components {
};
/**
* Type
* @description The type of workflow module.
* @default pause
* @constant
*/
type?: components["schemas"]["WorkflowModuleType"];
type: "pause";
/** When */
when: string | null;
};
/** Person */
Person: {
Expand Down Expand Up @@ -11111,10 +11115,11 @@ export interface components {
};
/**
* Type
* @description The type of workflow module.
* @default subworkflow
* @constant
*/
type?: components["schemas"]["WorkflowModuleType"];
type: "subworkflow";
/** When */
when: string | null;
/**
* Workflow ID
* @description The encoded ID of the workflow that will be run on this step.
Expand Down Expand Up @@ -11301,10 +11306,11 @@ export interface components {
tool_version?: string | null;
/**
* Type
* @description The type of workflow module.
* @default tool
* @constant
*/
type?: components["schemas"]["WorkflowModuleType"];
type: "tool";
/** When */
when: string | null;
};
/** Tour */
Tour: {
Expand Down Expand Up @@ -12303,18 +12309,6 @@ export interface components {
[key: string]: number | undefined;
};
};
/**
* WorkflowModuleType
* @description Available types of modules that represent a step in a Workflow.
* @enum {string}
*/
WorkflowModuleType:
| "data_input"
| "data_collection_input"
| "parameter_input"
| "subworkflow"
| "tool"
| "pause";
/** WriteInvocationStoreToPayload */
WriteInvocationStoreToPayload: {
/**
Expand Down
6 changes: 3 additions & 3 deletions lib/galaxy/managers/workflows.py
Original file line number Diff line number Diff line change
Expand Up @@ -1615,9 +1615,9 @@ def callback(input, prefixed_name, **kwargs):
def _workflow_to_dict_instance(self, trans, stored, workflow, legacy=True):
encode = self.app.security.encode_id
sa_session = self.app.model.context
item = stored.to_dict(view="element", value_mapper={"id": encode})
item = stored.to_dict(view="element")
item["name"] = workflow.name
item["url"] = trans.url_builder("workflow", id=item["id"])
item["url"] = trans.url_builder("workflow", id=encode(stored.id))
item["owner"] = stored.user.username
item["email_hash"] = md5_hash_str(stored.user.email)
item["slug"] = stored.slug
Expand Down Expand Up @@ -1668,7 +1668,7 @@ def _workflow_to_dict_instance(self, trans, stored, workflow, legacy=True):
del step_dict["tool_id"]
del step_dict["tool_version"]
del step_dict["tool_inputs"]
step_dict["workflow_id"] = encode(step.subworkflow.id)
step_dict["workflow_id"] = step.subworkflow.id

for conn in step.input_connections:
step_id = step.id if legacy else step.order_index
Expand Down
38 changes: 10 additions & 28 deletions lib/galaxy/schema/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -2099,7 +2099,7 @@ class JobFullDetails(JobDetails):


class StoredWorkflowSummary(Model, WithModelClass):
id: DecodedDatabaseIdField
id: EncodedDatabaseIdField
model_class: STORED_WORKFLOW_MODEL_CLASS = ModelClassField(STORED_WORKFLOW_MODEL_CLASS)
create_time: datetime = CreateTimeField
update_time: datetime = UpdateTimeField
Expand Down Expand Up @@ -2203,33 +2203,23 @@ class InputStep(Model):
)


class WorkflowModuleType(str, Enum):
"""Available types of modules that represent a step in a Workflow."""

data_input = "data_input"
data_collection_input = "data_collection_input"
parameter_input = "parameter_input"
subworkflow = "subworkflow"
tool = "tool"
pause = "pause" # Experimental


class WorkflowStepBase(Model):
id: int = Field(
...,
title="ID",
description="The identifier of the step. It matches the index order of the step inside the workflow.",
)
type: WorkflowModuleType = Field(..., title="Type", description="The type of workflow module.")
annotation: Optional[str] = AnnotationField
input_steps: Dict[str, InputStep] = Field(
...,
title="Input Steps",
description="A dictionary containing information about the inputs connected to this workflow step.",
)
when: Optional[str]


class ToolBasedWorkflowStep(WorkflowStepBase):
type: Literal["tool"]
tool_id: Optional[str] = Field(
None, title="Tool ID", description="The unique name of the tool associated with this step."
)
Expand All @@ -2240,36 +2230,28 @@ class ToolBasedWorkflowStep(WorkflowStepBase):


class InputDataStep(ToolBasedWorkflowStep):
type: WorkflowModuleType = Field(
WorkflowModuleType.data_input, title="Type", description="The type of workflow module."
)
type: Literal["data_input"]


class InputDataCollectionStep(ToolBasedWorkflowStep):
type: WorkflowModuleType = Field(
WorkflowModuleType.data_collection_input, title="Type", description="The type of workflow module."
)
type: Literal["data_collection_input"]


class InputParameterStep(ToolBasedWorkflowStep):
type: WorkflowModuleType = Field(
WorkflowModuleType.parameter_input, title="Type", description="The type of workflow module."
)
type: Literal["parameter"]


class PauseStep(WorkflowStepBase):
type: WorkflowModuleType = Field(WorkflowModuleType.pause, title="Type", description="The type of workflow module.")
type: Literal["pause"]


class ToolStep(ToolBasedWorkflowStep):
type: WorkflowModuleType = Field(WorkflowModuleType.tool, title="Type", description="The type of workflow module.")
type: Literal["tool"]


class SubworkflowStep(WorkflowStepBase):
type: WorkflowModuleType = Field(
WorkflowModuleType.subworkflow, title="Type", description="The type of workflow module."
)
workflow_id: DecodedDatabaseIdField = Field(
type: Literal["subworkflow"]
workflow_id: EncodedDatabaseIdField = Field(
..., title="Workflow ID", description="The encoded ID of the workflow that will be run on this step."
)

Expand Down
7 changes: 6 additions & 1 deletion lib/galaxy/schema/workflows.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,12 @@ class StoredWorkflowDetailed(StoredWorkflowSummary):
ToolStep,
SubworkflowStep,
],
] = Field({}, title="Steps", description="A dictionary with information about all the steps of the workflow.")
] = Field(
{},
title="Steps",
description="A dictionary with information about all the steps of the workflow.",
discriminator="type",
)
importable: Optional[bool] = Field(
...,
title="Importable",
Expand Down

0 comments on commit 0fafdfa

Please sign in to comment.