Example 2: Workflow execution with input data
()
| 30 | |
| 31 | |
| 32 | def with_input_example(): |
| 33 | """Example 2: Workflow execution with input data""" |
| 34 | client = SimStudioClient(api_key=os.getenv("SIM_API_KEY")) |
| 35 | |
| 36 | try: |
| 37 | result = client.execute_workflow( |
| 38 | "your-workflow-id", |
| 39 | input_data={ |
| 40 | "message": "Hello from Python SDK!", |
| 41 | "user_id": "12345", |
| 42 | "data": { |
| 43 | "type": "analysis", |
| 44 | "parameters": { |
| 45 | "include_metadata": True, |
| 46 | "format": "json" |
| 47 | } |
| 48 | } |
| 49 | }, |
| 50 | timeout=60.0 # 60 seconds |
| 51 | ) |
| 52 | |
| 53 | if result.success: |
| 54 | print("✅ Workflow executed successfully!") |
| 55 | print(f"Output: {result.output}") |
| 56 | if result.metadata: |
| 57 | print(f"Duration: {result.metadata.get('duration')} ms") |
| 58 | else: |
| 59 | print(f"❌ Workflow failed: {result.error}") |
| 60 | |
| 61 | except SimStudioError as error: |
| 62 | print(f"SDK Error: {error} (Code: {error.code})") |
| 63 | except Exception as error: |
| 64 | print(f"Unexpected error: {error}") |
| 65 | |
| 66 | |
| 67 | def status_example(): |
no test coverage detected