You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/setup/populating_secrets.md
+47-4Lines changed: 47 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -21,11 +21,33 @@ With this setup, you can run most PyRIT notebooks and examples!
21
21
22
22
## Setting Up Environment Variables
23
23
24
-
PyRIT loads secrets and endpoints from environment variables or a `.env` file in your repo root. The `.env_example` file shows the format and available options.
24
+
PyRIT loads secrets and endpoints from environment variables or `.env` files. The `.env_example` file shows the format and available options.
25
+
26
+
### Environment Variable Precedence
27
+
28
+
When `initialize_pyrit_async` runs, environment variables are loaded in a specific order. **Later sources override earlier ones:**
29
+
30
+
```{mermaid}
31
+
flowchart LR
32
+
A["1. System Environment"] --> B{"env_files provided?"}
33
+
B -->|No| C["2. ~/.pyrit/.env"]
34
+
C --> D["3. ~/.pyrit/.env.local"]
35
+
B -->|Yes| E["2. Your specified files (in order)"]
36
+
```
37
+
38
+
**Default behavior** (no `env_files` argument):
39
+
40
+
| Priority | Source | Description |
41
+
|----------|--------|-------------|
42
+
| Lowest | System environment variables | Always loaded as the baseline |
43
+
| Medium |`~/.pyrit/.env`| Default config file (loaded if it exists) |
44
+
| Highest |`~/.pyrit/.env.local`| Local overrides (loaded if it exists) |
45
+
46
+
**Custom behavior** (with `env_files` argument): Only your specified files are loaded, in order. Default paths are completely ignored.
25
47
26
48
### Creating Your .env File
27
49
28
-
1. Copy `.env_example` to `.env` in your repository root
50
+
1. Copy `.env_example` to `.env` in your home directory in ~/.pyrit/.env
29
51
2. Add your API credentials. For example, for Azure OpenAI:
30
52
31
53
```bash
@@ -37,12 +59,33 @@ To find these values in Azure Portal: `Azure Portal > Azure AI Services > Azure
37
59
38
60
### Using .env.local for Overrides
39
61
40
-
You can use `.env.local` to override values in `.env` without modifying the base file. This is useful for:
62
+
You can use `~/.pyrit/.env.local` to override values in `~/.pyrit/.env` without modifying the base file. This is useful for:
41
63
- Testing different targets
42
64
- Using personal credentials instead of shared ones
43
65
- Switching between configurations quickly
44
66
45
-
Simply create `.env.local` and add any variables you want to override. PyRIT will prioritize `.env.local` over `.env`.
67
+
Simply create `.env.local` in your `~/.pyrit/` directory and add any variables you want to override.
68
+
69
+
### Custom Environment Files
70
+
71
+
You can also specify exactly which `.env` files to load using the `env_files` parameter:
0 commit comments