Skip to content

Commit

Permalink
feat(arguments): add WorkflowArguments object
Browse files Browse the repository at this point in the history
Added a new class for WorkflowArguments. This is a special type of arguments for workflows which has
an additional field for user_data. This design will provide the option to assign user_data to a
workflow by loading them from an input file which updates the user_data information.
  • Loading branch information
mostaphaRoudsari committed Feb 23, 2020
1 parent ccf4fe9 commit d72b3a4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
22 changes: 13 additions & 9 deletions queenbee/schema/arguments.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,6 @@ class Arguments(BaseModel):
Queenbee accepts two types of arguments: parameters and artifacts. A ``parameter``
is a variable that can be passed to a task or a workflow. An ``artifact`` is a file
or folder that can be identified by a url or a path.
There is a third field for ``user_data`` which can be used to assign arbitrary values
to a workflow.
"""

parameters: List[Parameter] = Field(
Expand All @@ -209,12 +206,6 @@ class Arguments(BaseModel):
'task or workflow.'
)

user_data: Dict = Field(
None,
description='Optional user data as a dictionary. User data is for user reference'
' only and will not be used in the execution of the workflow.'
)

@root_validator
def unique_names(cls, values):
params = values.get('parameters')
Expand Down Expand Up @@ -293,3 +284,16 @@ def referenced_values(self):
]

return ref_values


class WorkflowArguments(Arguments):
"""A workflow arguments object.
The difference between the workflow argument and a standard argument is the extra
field for user_data.
"""
user_data: Dict = Field(
None,
description='Optional user data as a dictionary. User data is for user reference'
' only and will not be used in the execution of the workflow.'
)
4 changes: 2 additions & 2 deletions queenbee/schema/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from typing import List, Union
from queenbee.schema.qutil import BaseModel
from queenbee.schema.dag import DAG
from queenbee.schema.arguments import Arguments
from queenbee.schema.arguments import Arguments, WorkflowArguments
from queenbee.schema.operator import Operator
from queenbee.schema.function import Function
from queenbee.schema.artifact_location import RunFolderLocation, InputFolderLocation, \
Expand All @@ -36,7 +36,7 @@ class Workflow(BaseModel):
description='Workflow metadata information.'
)

inputs: Arguments = Field(
inputs: WorkflowArguments = Field(
None,
description='Workflow input arguments.'
)
Expand Down

0 comments on commit d72b3a4

Please sign in to comment.