Skip to content

Commit 2170858

Browse files
authored
docs: clarify .env scope for env separation (#39)
* docs: clarify .env is for CLI only, not deployed endpoint env Update all documentation to reflect env separation: - .env populates os.environ for CLI and local dev - Resource env={} is the explicit way to set endpoint env vars - flash login is the primary auth method - Deploy-time preview shows what goes to each endpoint * docs: address PR review feedback on env var examples - Use os.getenv() instead of os.environ[] in doc examples - Show both uv run and bare flash login invocations - Split dense paragraph into scannable bullets in CONTRIBUTING.md * docs: standardize os.environ for deploy-time env examples - Use os.environ["KEY"] consistently across all files (loud KeyError on missing vars is better UX than silently passing None via getenv) - Convert CONTRIBUTING.md bullets to blockquote callout - Fix duplicate step numbering in troubleshooting.md
1 parent bd005b8 commit 2170858

6 files changed

Lines changed: 48 additions & 25 deletions

File tree

CLI-REFERENCE.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -839,12 +839,14 @@ export FLASH_PORT=9000
839839

840840
**.env file:**
841841
```bash
842-
# .env (loaded automatically by Flash)
842+
# .env (loaded into os.environ for CLI and local development)
843843
RUNPOD_API_KEY=your-key-here
844844
FLASH_HOST=0.0.0.0
845845
FLASH_PORT=8888
846846
```
847847

848+
> **Note:** `.env` values populate `os.environ` locally. They are **not** carried to deployed endpoints. To pass env vars at deploy time, declare them on the resource: `env={"KEY": os.environ["KEY"]}`.
849+
848850
## Configuration Files
849851

850852
Flash uses these configuration files:

CONTRIBUTING.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,11 @@ To debug a worker:
332332
4. Choose the appropriate debug configuration
333333
5. The debugger will execute the `if __name__ == "__main__"` test block
334334

335-
The `.env` file is automatically loaded, so your `RUNPOD_API_KEY` is available during debugging.
335+
The `.env` file is loaded into `os.environ` for local CLI use and debugging.
336+
337+
> To pass environment variables to deployed endpoints, declare them explicitly on the resource config, for example: `env={"KEY": os.environ["KEY"]}`.
338+
>
339+
> For authentication, prefer using `flash login`.
336340
337341
### Unit Tests (Recommended)
338342

docs/cli/commands.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -329,15 +329,17 @@ This hybrid approach enables rapid development: iterate on your orchestration lo
329329

330330
### Environment Variables
331331

332-
Variables can be set in `.env` file or exported in shell:
332+
Variables can be set in `.env` file or exported in shell. The `.env` file populates `os.environ` for local CLI use and development -- it is not carried to deployed endpoints.
333333

334334
```bash
335-
# .env file
335+
# .env file (local CLI and development only)
336336
FLASH_HOST=0.0.0.0
337337
FLASH_PORT=9000
338338
RUNPOD_API_KEY=your-key-here
339339
```
340340

341+
> To pass env vars to deployed endpoints, declare them on the resource config: `env={"HF_TOKEN": os.environ["HF_TOKEN"]}`.
342+
341343
**Precedence (highest to lowest):**
342344
1. Command-line options (`--host`, `--port`)
343345
2. Environment variables (`FLASH_HOST`, `FLASH_PORT`)

docs/cli/getting-started.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ uv run flash login
2727

2828
This opens a browser for authentication and saves your credentials.
2929

30-
**Alternative:** Set your Runpod API key manually:
30+
**Alternative:** Set your Runpod API key in the environment for local CLI use:
3131
```bash
3232
export RUNPOD_API_KEY=your-key-here
33-
# Or add to .env file:
33+
# Or add to .env file (populates os.environ locally, not carried to deployed endpoints):
3434
echo "RUNPOD_API_KEY=your-key-here" > .env
3535
```
3636

docs/cli/troubleshooting.md

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -659,28 +659,37 @@ Error: RUNPOD_API_KEY environment variable not set
659659
660660
**Solutions:**
661661
662-
**1. Set environment variable:**
662+
**1. Use `flash login` (recommended):**
663+
```bash
664+
# If you installed Flash via uv (recommended)
665+
uv run flash login
666+
667+
# Or, if flash is installed globally
668+
flash login
669+
```
670+
671+
**2. Set environment variable:**
663672
```bash
664673
export RUNPOD_API_KEY=your-key-here
665674
666675
# Verify
667676
echo $RUNPOD_API_KEY
668677
```
669678
670-
**2. Add to .env file:**
679+
**3. Add to .env file (for local CLI use):**
671680
```bash
672681
echo "RUNPOD_API_KEY=your-key-here" >> .env
673682
674-
# Flash automatically loads .env
683+
# Loaded into os.environ for CLI commands
675684
```
676685
677-
**3. Get API key:**
686+
**4. Get API key:**
678687
1. Visit https://runpod.io/console/user/settings
679688
2. Click "API Keys"
680689
3. Create new key or copy existing
681690
4. Set environment variable
682691
683-
**4. Make persistent (bash/zsh):**
692+
**5. Make persistent (bash/zsh):**
684693
```bash
685694
echo 'export RUNPOD_API_KEY=your-key-here' >> ~/.bashrc
686695
source ~/.bashrc
@@ -1046,12 +1055,12 @@ export RUNPOD_API_KEY=your-key
10461055
flash deploy
10471056
```
10481057
1049-
**3. Use .env file:**
1058+
**3. Use .env file (for local CLI use):**
10501059
```bash
10511060
# Create .env in project root
10521061
echo "RUNPOD_API_KEY=your-key" > .env
10531062
1054-
# Flash automatically loads .env
1063+
# Loaded into os.environ for CLI commands
10551064
flash deploy
10561065
```
10571066
@@ -1078,18 +1087,23 @@ ERROR: Authentication failed: API key expired
10781087
10791088
**Solutions:**
10801089
1081-
**1. Generate new key:**
1090+
**1. Re-authenticate with `flash login` (recommended):**
1091+
```bash
1092+
flash login
1093+
```
1094+
1095+
**2. Or generate a new key manually:**
10821096
1. Visit https://runpod.io/console/user/settings
10831097
2. Revoke expired key
10841098
3. Create new key
1085-
4. Update environment variable
1099+
4. Update environment variable or `.env` file
10861100
1087-
**2. Update in all locations:**
1101+
**3. Update in all locations:**
10881102
```bash
10891103
# Update environment variable
10901104
export RUNPOD_API_KEY=new-key
10911105
1092-
# Update .env file
1106+
# Or update .env file (for local CLI use)
10931107
echo "RUNPOD_API_KEY=new-key" > .env
10941108
10951109
# Update CI/CD secrets

docs/cli/workflows.md

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -63,24 +63,25 @@ python --version # Should show 3.10+
6363
uv run flash --version # Should show flash version
6464
```
6565

66-
#### 3. Configure Environment Variables
66+
#### 3. Authenticate
6767

68-
```bash
69-
# Copy example environment file
70-
cp .env.example .env
68+
The recommended way to authenticate is `flash login`:
7169

72-
# Edit .env file
73-
# Required: RUNPOD_API_KEY (for deployment)
74-
# Optional: FLASH_HOST, FLASH_PORT (for development)
70+
```bash
71+
uv run flash login
7572
```
7673

77-
Example `.env`:
74+
Alternatively, set `RUNPOD_API_KEY` in your environment or a `.env` file for local CLI use:
75+
7876
```bash
77+
# .env file (populates os.environ for CLI and local development)
7978
RUNPOD_API_KEY=your-key-here
8079
FLASH_HOST=localhost
8180
FLASH_PORT=8888
8281
```
8382

83+
> **Note:** `.env` values are **not** carried to deployed endpoints. To pass env vars at deploy time, declare them on the resource: `env={"KEY": os.environ["KEY"]}`.
84+
8485
#### 4. Start Development Server
8586

8687
```bash

0 commit comments

Comments
 (0)