Run the Flow through the SDK's normal grant and export lifecycle.
()
| 228 | |
| 229 | |
| 230 | def main() -> int: |
| 231 | """Run the Flow through the SDK's normal grant and export lifecycle.""" |
| 232 | parser = argparse.ArgumentParser( |
| 233 | description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter |
| 234 | ) |
| 235 | parser.add_argument( |
| 236 | "--runs", |
| 237 | type=int, |
| 238 | default=1, |
| 239 | help="Number of independent runs to start concurrently (default: 1)", |
| 240 | ) |
| 241 | parser.add_argument( |
| 242 | "--topic", |
| 243 | default=WharfDemoState().topic, |
| 244 | help="Research topic for the three-agent Flow", |
| 245 | ) |
| 246 | parser.add_argument( |
| 247 | "--amp-url", |
| 248 | help="AMP base URL; defaults to CREWAI_PLUS_URL or your CLI settings", |
| 249 | ) |
| 250 | args = parser.parse_args() |
| 251 | if args.runs < 1: |
| 252 | parser.error("--runs must be at least 1") |
| 253 | try: |
| 254 | firecrawl_mcp() |
| 255 | except ValueError as error: |
| 256 | parser.error(str(error)) |
| 257 | if args.amp_url: |
| 258 | os.environ["CREWAI_PLUS_URL"] = args.amp_url |
| 259 | logging.basicConfig(level=logging.INFO) |
| 260 | |
| 261 | print(f"Source checkout: {ROOT}") |
| 262 | try: |
| 263 | results = asyncio.run(run_concurrent(args.topic, args.runs)) |
| 264 | except KeyboardInterrupt: |
| 265 | print("Flow interrupted.", file=sys.stderr) |
| 266 | return 130 |
| 267 | |
| 268 | for result in results: |
| 269 | print( |
| 270 | f"\n[Run {result.run_number}] " |
| 271 | f"{'FAILED' if result.error else 'COMPLETED'}\n" |
| 272 | f" crewai.execution_uuid: {result.execution_uuid or 'not started'}\n" |
| 273 | f" trace_id: {result.trace_id or 'not recording'}\n" |
| 274 | f"{result.error or result.output}" |
| 275 | ) |
| 276 | print( |
| 277 | "The SDK handled trace export. Flow completion does not confirm collector acceptance." |
| 278 | ) |
| 279 | print( |
| 280 | "Check SDK export errors and search for crewai.execution_uuid in your trace viewer." |
| 281 | ) |
| 282 | return int(any(result.error for result in results)) |
| 283 | |
| 284 | |
| 285 | if __name__ == "__main__": |
no test coverage detected