Files
crewAI/examples/custom_flow_script.py
2025-04-05 22:38:38 +00:00

31 lines
715 B
Python

"""
Example script showing how to run a CrewAI flow from a custom script.
This example demonstrates how to avoid the ModuleNotFoundError when
starting flows from custom scripts outside of the CLI command context.
"""
import logging
import os
from crewai.utilities.path_utils import add_project_to_path
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
logger.info("Adding project directory to Python path")
add_project_to_path()
from my_flow.main import MyFlow # noqa: E402
def main():
"""Run the flow from a custom script."""
flow = MyFlow()
result = flow.kickoff()
print(f"Flow completed with result: {result}")
if __name__ == "__main__":
main()