11from __future__ import annotations
22
3- import json
43from datetime import datetime
54from enum import Enum
65from typing import Any
76
87import typer
98from typing_extensions import Annotated
109
10+ from simpleflow import Workflow , format
1111from simpleflow .command import get_progression_callback , get_workflow_type , with_format
1212from simpleflow .swf import helpers
1313from simpleflow .swf .mapper .models import WorkflowExecution
@@ -46,7 +46,6 @@ def filter(
4646 status : Annotated [Status , typer .Option ("--status" , "-s" )] = Status .open ,
4747 tag : str | None = None ,
4848 workflow_id : str | None = None ,
49- run_id : str | None = None ,
5049 workflow_type : str | None = None ,
5150 workflow_type_version : str | None = None ,
5251 close_status : CloseStatus | None = None ,
@@ -80,7 +79,7 @@ def filter(
8079 print (
8180 with_format (ctx .parent )(helpers .filter_workflow_executions )(
8281 domain ,
83- status = status . upper () ,
82+ status = status ,
8483 tag = tag ,
8584 workflow_id = workflow_id ,
8685 workflow_type_name = workflow_type ,
@@ -95,16 +94,16 @@ def filter(
9594def start (
9695 ctx : typer .Context ,
9796 workflow : str ,
98- domain : Annotated [str , typer .Argument (envvar = "SWF_DOMAIN" )],
97+ domain : Annotated [str , typer .Option (envvar = "SWF_DOMAIN" )],
9998 input : Annotated [str , typer .Option ("--input" , "-i" , help = "input JSON" )] | None = None ,
10099):
101100 """
102101 Start a workflow.
103102 """
104- workflow_class = import_from_module (workflow )
103+ workflow_class : type [ Workflow ] = import_from_module (workflow )
105104 wf_input : dict [str , Any ] = {}
106105 if input is not None :
107- json_input = json . loads (input )
106+ json_input = format . decode (input )
108107 if isinstance (json_input , list ):
109108 wf_input = {"args" : json_input , "kwargs" : {}}
110109 elif isinstance (json_input , dict ) and ("args" not in json_input or "kwargs" not in json_input ):
@@ -113,9 +112,22 @@ def start(
113112 wf_input = json_input
114113 workflow_type = get_workflow_type (domain , workflow_class )
115114 set_workflow_class_name (wf_input , workflow_class )
115+ get_task_list = getattr (workflow_class , "get_task_list" , None )
116+ if get_task_list :
117+ if not callable (get_task_list ):
118+ raise Exception ("get_task_list must be a callable" )
119+ if isinstance (wf_input , dict ):
120+ args = wf_input .get ("args" , [])
121+ kwargs = wf_input .get ("kwargs" , {})
122+ else :
123+ args = []
124+ kwargs = wf_input
125+ task_list = get_task_list (workflow_class , * args , ** kwargs )
126+ else :
127+ task_list = workflow_class .task_list
116128 execution = workflow_type .start_execution (
117129 # workflow_id=workflow_id,
118- # task_list=task_list or workflow_class. task_list,
130+ task_list = task_list ,
119131 # execution_timeout=execution_timeout,
120132 input = wf_input ,
121133 # tag_list=tags,
0 commit comments