MCPcopy Create free account
hub / github.com/modelscope/ms-agent / get_project_workflow

Function get_project_workflow

webui/backend/api.py:157–196  ·  view source on GitHub ↗

Get the workflow configuration for a project If session_id is provided, returns the workflow based on the session's workflow_type. For code_genesis project, 'simple' workflow_type will return simple_workflow.yaml.

(project_id: str,
                               session_id: Optional[str] = None)

Source from the content-addressed store, hash-verified

155
156@router.get('/projects/{project_id}/workflow')
157async def get_project_workflow(project_id: str,
158 session_id: Optional[str] = None):
159 """Get the workflow configuration for a project
160
161 If session_id is provided, returns the workflow based on the session's workflow_type.
162 For code_genesis project, 'simple' workflow_type will return simple_workflow.yaml.
163 """
164 project = project_discovery.get_project(project_id)
165 if not project:
166 raise HTTPException(status_code=404, detail='Project not found')
167
168 # Determine workflow_type from session if session_id is provided
169 workflow_type = 'standard' # default
170 if session_id:
171 session = session_manager.get_session(session_id)
172 if session and session.get('workflow_type'):
173 workflow_type = session['workflow_type']
174
175 # Determine which workflow file to use
176 if workflow_type == 'simple' and project.get('supports_workflow_switch'):
177 # For simple workflow, try simple_workflow.yaml first
178 workflow_file = os.path.join(project['path'], 'simple_workflow.yaml')
179 if not os.path.exists(workflow_file):
180 # Fallback to standard workflow.yaml if simple_workflow.yaml doesn't exist
181 workflow_file = os.path.join(project['path'], 'workflow.yaml')
182 else:
183 # Standard workflow
184 workflow_file = os.path.join(project['path'], 'workflow.yaml')
185
186 if not os.path.exists(workflow_file):
187 raise HTTPException(status_code=404, detail='Workflow file not found')
188
189 try:
190 import yaml
191 with open(workflow_file, 'r', encoding='utf-8') as f:
192 workflow_data = yaml.safe_load(f)
193 return {'workflow': workflow_data, 'workflow_type': workflow_type}
194 except Exception as e:
195 raise HTTPException(
196 status_code=500, detail=f'Error reading workflow file: {str(e)}')
197
198
199# Session Endpoints

Callers

nothing calls this directly

Calls 3

get_projectMethod · 0.80
get_sessionMethod · 0.80
getMethod · 0.80

Tested by

no test coverage detected