-
Notifications
You must be signed in to change notification settings - Fork 617
Add dotenv environment variable defaults #2422
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
8W9aG
commented
Jun 20, 2025
- Allow a .env file to specify the default environment variables to be passed to predict
* Allow a .env file to specify the default environment variables to be passed to predict
What's the use case for this in predict only? Tbh I'd like better support for .env files across the entire cli, but we need to think about the various ways we use env vars, like adding variables (and secrets) to models at build time, or build args, during predict, etc. We just need predictable behavior, specifically, vars are eagerly loaded from a predictable place but explicitly requested before being used. Just thinking this through, but maybe something like this... first, we add an env-file flag to the root command that defaults to .env. if there's a file present at that path we automatically load it into the env for the command Later on when passing variables to something, we follow conventions for the
I think this behavior would be consistent across all the use cases we have (or will be adding) across the CLI without surprises. If this lands in an Thoughts? |
Use case is supplying a replicate api token which is a runtime problem rather than a build problem, see DP-280 for details. This would be different to how |
Ah I understand, that makes sense! So yeah, standardizing cog env var loading is out of scope, and I'd prefer we do that properly in isolation. Would this work for now: automatically read the .env file, but instead of loading it into the process env, load it as a map and automatically pluck out just the values you need. If Also, this is like the 3rd time this week where I've found a good reason for cog to maintain a state file for config. Only using the docker auth for registry token is making things needlessly difficult. |
As a user I think this would be unexpected. I'd expect the The primary goal here is to allow a user to run |
I agree I'm not sure it makes sense to scope the |
Sorry I missed your reply @aron! You're both right, env variables are the right thing to use. I'm only (gently) pushing back on scope and timing. Supporting .env files, and host-to-container env in general, comes with ux footguns we need to think through. I haven't thought through it more than the discussion above, so I'll think it through in words here and we can figure it out together 🙃 The main question is if The default/expected behavior of an What we don't want is to load There's also a number of collisions I'd expect between cog and the container, like We can go into more detail with all that, but that's the gist. So what options do we have for a path forward? The quickest is to not address this yet and use Dunno... just wanted to dump some thoughts for discussion. What do y'all think? |