Skip to content

Commit a3f5072

Browse files
authored
chore!: remove --env from llama stack run (#3711)
# What does this PR do? user can simply set env vars in the beginning of the command.`FOO=BAR llama stack run ...` ## Test Plan Run TELEMETRY_SINKS=coneol uv run --with llama-stack llama stack build --distro=starter --image-type=venv --run --- [//]: # (BEGIN SAPLING FOOTER) Stack created with [Sapling](https://sapling-scm.com). Best reviewed with [ReviewStack](https://reviewstack.dev/llamastack/llama-stack/pull/3711). * #3714 * __->__ #3711
1 parent 1ac320b commit a3f5072

File tree

27 files changed

+151
-217
lines changed

27 files changed

+151
-217
lines changed

.github/workflows/integration-auth-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ jobs:
8686
8787
# avoid line breaks in the server log, especially because we grep it below.
8888
export COLUMNS=1984
89-
nohup uv run llama stack run $run_dir/run.yaml --image-type venv > server.log 2>&1 &
89+
nohup uv run llama stack run $run_dir/run.yaml > server.log 2>&1 &
9090
9191
- name: Wait for Llama Stack server to be ready
9292
run: |

.github/workflows/test-external-provider-module.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ jobs:
5959
# Use the virtual environment created by the build step (name comes from build config)
6060
source ramalama-stack-test/bin/activate
6161
uv pip list
62-
nohup llama stack run tests/external/ramalama-stack/run.yaml --image-type ${{ matrix.image-type }} > server.log 2>&1 &
62+
nohup llama stack run tests/external/ramalama-stack/run.yaml > server.log 2>&1 &
6363
6464
- name: Wait for Llama Stack server to be ready
6565
run: |

.github/workflows/test-external.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ jobs:
5959
# Use the virtual environment created by the build step (name comes from build config)
6060
source ci-test/bin/activate
6161
uv pip list
62-
nohup llama stack run tests/external/run-byoa.yaml --image-type ${{ matrix.image-type }} > server.log 2>&1 &
62+
nohup llama stack run tests/external/run-byoa.yaml > server.log 2>&1 &
6363
6464
- name: Wait for Llama Stack server to be ready
6565
run: |

docs/docs/advanced_apis/post_training.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ You can access the HuggingFace trainer via the `starter` distribution:
5252

5353
```bash
5454
llama stack build --distro starter --image-type venv
55-
llama stack run --image-type venv ~/.llama/distributions/starter/starter-run.yaml
55+
llama stack run ~/.llama/distributions/starter/starter-run.yaml
5656
```
5757

5858
### Usage Example

docs/docs/building_applications/tools.mdx

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -219,13 +219,10 @@ group_tools = client.tools.list_tools(toolgroup_id="search_tools")
219219
<TabItem value="setup" label="Setup & Configuration">
220220

221221
1. Start by registering a Tavily API key at [Tavily](https://tavily.com/).
222-
2. [Optional] Provide the API key directly to the Llama Stack server
222+
2. [Optional] Set the API key in your environment before starting the Llama Stack server
223223
```bash
224224
export TAVILY_SEARCH_API_KEY="your key"
225225
```
226-
```bash
227-
--env TAVILY_SEARCH_API_KEY=${TAVILY_SEARCH_API_KEY}
228-
```
229226

230227
</TabItem>
231228
<TabItem value="implementation" label="Implementation">
@@ -273,9 +270,9 @@ for log in EventLogger().log(response):
273270
<TabItem value="setup" label="Setup & Configuration">
274271

275272
1. Start by registering for a WolframAlpha API key at [WolframAlpha Developer Portal](https://developer.wolframalpha.com/access).
276-
2. Provide the API key either when starting the Llama Stack server:
273+
2. Provide the API key either by setting it in your environment before starting the Llama Stack server:
277274
```bash
278-
--env WOLFRAM_ALPHA_API_KEY=${WOLFRAM_ALPHA_API_KEY}
275+
export WOLFRAM_ALPHA_API_KEY="your key"
279276
```
280277
or from the client side:
281278
```python

docs/docs/contributing/new_api_provider.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ Integration tests are located in [tests/integration](https://github.com/meta-lla
7676
Consult [tests/integration/README.md](https://github.com/meta-llama/llama-stack/blob/main/tests/integration/README.md) for more details on how to run the tests.
7777

7878
Note that each provider's `sample_run_config()` method (in the configuration class for that provider)
79-
typically references some environment variables for specifying API keys and the like. You can set these in the environment or pass these via the `--env` flag to the test command.
79+
typically references some environment variables for specifying API keys and the like. You can set these in the environment before running the test command.
8080

8181

8282
### 2. Unit Testing

docs/docs/distributions/building_distro.mdx

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -289,10 +289,10 @@ After this step is successful, you should be able to find the built container im
289289
docker run -d \
290290
-p $LLAMA_STACK_PORT:$LLAMA_STACK_PORT \
291291
-v ~/.llama:/root/.llama \
292+
-e INFERENCE_MODEL=$INFERENCE_MODEL \
293+
-e OLLAMA_URL=http://host.docker.internal:11434 \
292294
localhost/distribution-ollama:dev \
293-
--port $LLAMA_STACK_PORT \
294-
--env INFERENCE_MODEL=$INFERENCE_MODEL \
295-
--env OLLAMA_URL=http://host.docker.internal:11434
295+
--port $LLAMA_STACK_PORT
296296
```
297297

298298
Here are the docker flags and their uses:
@@ -305,11 +305,11 @@ Here are the docker flags and their uses:
305305

306306
* `localhost/distribution-ollama:dev`: The name and tag of the container image to run
307307

308-
* `--port $LLAMA_STACK_PORT`: Port number for the server to listen on
308+
* `-e INFERENCE_MODEL=$INFERENCE_MODEL`: Sets the INFERENCE_MODEL environment variable in the container
309309

310-
* `--env INFERENCE_MODEL=$INFERENCE_MODEL`: Sets the model to use for inference
310+
* `-e OLLAMA_URL=http://host.docker.internal:11434`: Sets the OLLAMA_URL environment variable in the container
311311

312-
* `--env OLLAMA_URL=http://host.docker.internal:11434`: Configures the URL for the Ollama service
312+
* `--port $LLAMA_STACK_PORT`: Port number for the server to listen on
313313

314314
</TabItem>
315315
</Tabs>
@@ -320,23 +320,22 @@ Now, let's start the Llama Stack Distribution Server. You will need the YAML con
320320

321321
```
322322
llama stack run -h
323-
usage: llama stack run [-h] [--port PORT] [--image-name IMAGE_NAME] [--env KEY=VALUE]
323+
usage: llama stack run [-h] [--port PORT] [--image-name IMAGE_NAME]
324324
[--image-type {venv}] [--enable-ui]
325-
[config | template]
325+
[config | distro]
326326
327327
Start the server for a Llama Stack Distribution. You should have already built (or downloaded) and configured the distribution.
328328
329329
positional arguments:
330-
config | template Path to config file to use for the run or name of known template (`llama stack list` for a list). (default: None)
330+
config | distro Path to config file to use for the run or name of known distro (`llama stack list` for a list). (default: None)
331331
332332
options:
333333
-h, --help show this help message and exit
334334
--port PORT Port to run the server on. It can also be passed via the env var LLAMA_STACK_PORT. (default: 8321)
335335
--image-name IMAGE_NAME
336-
Name of the image to run. Defaults to the current environment (default: None)
337-
--env KEY=VALUE Environment variables to pass to the server in KEY=VALUE format. Can be specified multiple times. (default: None)
336+
[DEPRECATED] This flag is no longer supported. Please activate your virtual environment before running. (default: None)
338337
--image-type {venv}
339-
Image Type used during the build. This should be venv. (default: None)
338+
[DEPRECATED] This flag is no longer supported. Please activate your virtual environment before running. (default: None)
340339
--enable-ui Start the UI server (default: False)
341340
```
342341

@@ -348,9 +347,6 @@ llama stack run tgi
348347
349348
# Start using config file
350349
llama stack run ~/.llama/distributions/llamastack-my-local-stack/my-local-stack-run.yaml
351-
352-
# Start using a venv
353-
llama stack run --image-type venv ~/.llama/distributions/llamastack-my-local-stack/my-local-stack-run.yaml
354350
```
355351

356352
```

docs/docs/distributions/configuration.mdx

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ A few things to note:
101101
- The id is a string you can choose freely.
102102
- You can instantiate any number of provider instances of the same type.
103103
- The configuration dictionary is provider-specific.
104-
- Notice that configuration can reference environment variables (with default values), which are expanded at runtime. When you run a stack server (via docker or via `llama stack run`), you can specify `--env OLLAMA_URL=http://my-server:11434` to override the default value.
104+
- Notice that configuration can reference environment variables (with default values), which are expanded at runtime. When you run a stack server, you can set environment variables in your shell before running `llama stack run` to override the default values.
105105

106106
### Environment Variable Substitution
107107

@@ -173,13 +173,10 @@ optional_token: ${env.OPTIONAL_TOKEN:+}
173173

174174
#### Runtime Override
175175

176-
You can override environment variables at runtime when starting the server:
176+
You can override environment variables at runtime by setting them in your shell before starting the server:
177177

178178
```bash
179-
# Override specific environment variables
180-
llama stack run --config run.yaml --env API_KEY=sk-123 --env BASE_URL=https://custom-api.com
181-
182-
# Or set them in your shell
179+
# Set environment variables in your shell
183180
export API_KEY=sk-123
184181
export BASE_URL=https://custom-api.com
185182
llama stack run --config run.yaml

docs/docs/distributions/remote_hosted_distro/watsonx.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,10 @@ docker run \
6969
-it \
7070
-p $LLAMA_STACK_PORT:$LLAMA_STACK_PORT \
7171
-v ./run.yaml:/root/my-run.yaml \
72+
-e WATSONX_API_KEY=$WATSONX_API_KEY \
73+
-e WATSONX_PROJECT_ID=$WATSONX_PROJECT_ID \
74+
-e WATSONX_BASE_URL=$WATSONX_BASE_URL \
7275
llamastack/distribution-watsonx \
7376
--config /root/my-run.yaml \
74-
--port $LLAMA_STACK_PORT \
75-
--env WATSONX_API_KEY=$WATSONX_API_KEY \
76-
--env WATSONX_PROJECT_ID=$WATSONX_PROJECT_ID \
77-
--env WATSONX_BASE_URL=$WATSONX_BASE_URL
77+
--port $LLAMA_STACK_PORT
7878
```

docs/docs/distributions/self_hosted_distro/dell.md

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -129,11 +129,11 @@ docker run -it \
129129
# NOTE: mount the llama-stack / llama-model directories if testing local changes else not needed
130130
-v $HOME/git/llama-stack:/app/llama-stack-source -v $HOME/git/llama-models:/app/llama-models-source \
131131
# localhost/distribution-dell:dev if building / testing locally
132-
llamastack/distribution-dell\
133-
--port $LLAMA_STACK_PORT \
134-
--env INFERENCE_MODEL=$INFERENCE_MODEL \
135-
--env DEH_URL=$DEH_URL \
136-
--env CHROMA_URL=$CHROMA_URL
132+
-e INFERENCE_MODEL=$INFERENCE_MODEL \
133+
-e DEH_URL=$DEH_URL \
134+
-e CHROMA_URL=$CHROMA_URL \
135+
llamastack/distribution-dell \
136+
--port $LLAMA_STACK_PORT
137137

138138
```
139139

@@ -154,14 +154,14 @@ docker run \
154154
-p $LLAMA_STACK_PORT:$LLAMA_STACK_PORT \
155155
-v $HOME/.llama:/root/.llama \
156156
-v ./llama_stack/distributions/tgi/run-with-safety.yaml:/root/my-run.yaml \
157+
-e INFERENCE_MODEL=$INFERENCE_MODEL \
158+
-e DEH_URL=$DEH_URL \
159+
-e SAFETY_MODEL=$SAFETY_MODEL \
160+
-e DEH_SAFETY_URL=$DEH_SAFETY_URL \
161+
-e CHROMA_URL=$CHROMA_URL \
157162
llamastack/distribution-dell \
158163
--config /root/my-run.yaml \
159-
--port $LLAMA_STACK_PORT \
160-
--env INFERENCE_MODEL=$INFERENCE_MODEL \
161-
--env DEH_URL=$DEH_URL \
162-
--env SAFETY_MODEL=$SAFETY_MODEL \
163-
--env DEH_SAFETY_URL=$DEH_SAFETY_URL \
164-
--env CHROMA_URL=$CHROMA_URL
164+
--port $LLAMA_STACK_PORT
165165
```
166166

167167
### Via venv
@@ -170,21 +170,21 @@ Make sure you have done `pip install llama-stack` and have the Llama Stack CLI a
170170

171171
```bash
172172
llama stack build --distro dell --image-type venv
173-
llama stack run dell
174-
--port $LLAMA_STACK_PORT \
175-
--env INFERENCE_MODEL=$INFERENCE_MODEL \
176-
--env DEH_URL=$DEH_URL \
177-
--env CHROMA_URL=$CHROMA_URL
173+
INFERENCE_MODEL=$INFERENCE_MODEL \
174+
DEH_URL=$DEH_URL \
175+
CHROMA_URL=$CHROMA_URL \
176+
llama stack run dell \
177+
--port $LLAMA_STACK_PORT
178178
```
179179

180180
If you are using Llama Stack Safety / Shield APIs, use:
181181

182182
```bash
183+
INFERENCE_MODEL=$INFERENCE_MODEL \
184+
DEH_URL=$DEH_URL \
185+
SAFETY_MODEL=$SAFETY_MODEL \
186+
DEH_SAFETY_URL=$DEH_SAFETY_URL \
187+
CHROMA_URL=$CHROMA_URL \
183188
llama stack run ./run-with-safety.yaml \
184-
--port $LLAMA_STACK_PORT \
185-
--env INFERENCE_MODEL=$INFERENCE_MODEL \
186-
--env DEH_URL=$DEH_URL \
187-
--env SAFETY_MODEL=$SAFETY_MODEL \
188-
--env DEH_SAFETY_URL=$DEH_SAFETY_URL \
189-
--env CHROMA_URL=$CHROMA_URL
189+
--port $LLAMA_STACK_PORT
190190
```

0 commit comments

Comments
 (0)