Open lugfug opened 2 months ago
FYI, I created a workaround, code below.
@joaomdmoura maybe you can implement an official method of declaring an environment variable for where the trained_agents_data.pkl
may be saved...
Here is my workaround for the error mentioned above.
# Monkey patch the PickleHandler class to use /tmp for the file path
# Import the PickleHandler class from the crewai.utilities.file_handler module
from crewai.utilities.file_handler import PickleHandler
# Store the original __init__ method of the PickleHandler class
# This allows us to call the original method after modifying the file_path
original_init = PickleHandler.__init__
# Define a new __init__ method to replace the original one
def patched_init(self, file_path):
# Override the file path to use the /tmp directory, which is writable in AWS Lambda
file_path = "/tmp/trained_agents_data.pkl"
# Call the original __init__ method with the modified file_path
original_init(self, file_path)
# Apply the patch by replacing the original __init__ method with the patched version
PickleHandler.__init__ = patched_init
# Import specific classes after environment setup to avoid premature errors.
from crewai import Agent, Task, Crew, Process
from crewai_tools import tool
from crewai_tools import BaseTool
Summary:
Ability to select where the pkl file gets saved when training a crew
@lugfug Feel free to raise a PR with your monkey patch so the Devs can see it
@pythonbyte might have context to help on this
This issue is stale because it has been open for 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.
I'm running crewAI in a Docker container on an AWS Lambda Function, where the only writable directory path is
/tmp
.Since the update of crewAI, I'm now getting the following error.
OSError: [Errno 30] Read-only file system: '/function/trained_agents_data.pkl'
Is there an official method to set an environment variable for crewAI to define where it should save the
trained_agents_data.pkl
file?Thank you for a great product, crewAI is awesome!