MCPcopy Create free account
hub / github.com/PolymathicAI/AstroCLIP / default_dotenv_values

Function default_dotenv_values

astroclip/env.py:17–44  ·  view source on GitHub ↗

Use a default .env but tell the user how to create their own.

()

Source from the content-addressed store, hash-verified

15
16
17def default_dotenv_values():
18 """Use a default .env but tell the user how to create their own."""
19
20 env_dir = Path(__file__).parent
21 env_path = env_dir / ".env"
22
23 if env_path.exists():
24 return dotenv_values(env_path)
25
26 with NamedTemporaryFile(mode="w+") as f:
27 global WARN_ONCE
28
29 # TODO: these should be replaced with a folder in the project's root
30 f.write("ASTROCLIP_ROOT={ASTROCLIP_ROOT}\n")
31 f.write('WANDB_ENTITY_NAME="{WANDB_ENTITY_NAME}"\n')
32 f.flush()
33
34 if WARN_ONCE:
35 f.seek(0)
36 warn(
37 f"No .env file found in {env_dir}. "
38 "Using default environment variables for rusty. "
39 f"To suppress this warning, create {env_dir}/.env with, e.g., the following content:\n"
40 f"{f.read()}"
41 )
42 WARN_ONCE = False
43
44 return dotenv_values(f.name)
45
46
47T = TypeVar("T")

Callers 1

format_with_envFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected