stanfordnlp / dspy

DSPy: The framework for programming—not prompting—foundation models
https://dspy-docs.vercel.app/
MIT License
18.07k stars 1.38k forks source link

Change local file logging handler? #480

Open smcdowellfactor opened 7 months ago

smcdowellfactor commented 7 months ago

I would like to set up some modules using DSPy as Azure Function App functions. Hit a roadblock: I get an error when DSPy attempts to create/write to "openai_usage.log": "Result: Failure Exception: OSError: [Errno 30] Read-only file system: '/home/site/wwwroot/openai_usage.log'"

Is there a built-in way I can turn off the logging to "openai_usage.log"? Or change the logging handler/location to a non-local destination?

arnavsinghvi11 commented 7 months ago

Hi @smcdowellfactor , could you try setting dspy.settings(log_openai_usage=False manually and testing if this resolves it?

You can also comment you the logging configuration in gpt3.py for your use case.

eulervoid commented 6 months ago

I tried this, when trying to run dspy in a Docker container, but it does not seem to work. The cache is a similar issue, it is created in the home directory by default, which can cause issues when trying to deploy an app in a serverless environment or in a Docker container. For the cache there are two environment variables: DSP_CACHEDIR and DSP_NOTEBOOK_CACHEDIR, a similar thing would be desirable for the usage logs. As a workaround in Docker you can create a volume for each of the files, but it would be much nicer to be able to configure where the files go in the framework somewhere.