Skip to content

Commit d378e06

Browse files
cosmicBboykumare3
andauthored
Rename app inputs to parameters (#627)
* app doc updates Signed-off-by: Niels Bantilan <[email protected]> * update app input -> parameter Signed-off-by: Niels Bantilan <[email protected]> * rename files Signed-off-by: Niels Bantilan <[email protected]> * updates Signed-off-by: Niels Bantilan <[email protected]> * fixed Signed-off-by: Ketan Umare <[email protected]> * Updated unionai-examples commit Signed-off-by: Ketan Umare <[email protected]> --------- Signed-off-by: Niels Bantilan <[email protected]> Signed-off-by: Ketan Umare <[email protected]> Co-authored-by: Ketan Umare <[email protected]> Co-authored-by: Ketan Umare <[email protected]>
1 parent 9dfaa99 commit d378e06

File tree

12 files changed

+159
-157
lines changed

12 files changed

+159
-157
lines changed

content/user-guide/build-apps/app-usage-patterns.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -276,16 +276,16 @@ Key points:
276276
- Access the app endpoint via `env1.endpoint`
277277
- Use HTTP clients (like `httpx`) to make requests between apps
278278

279-
### Using AppEndpoint input
279+
### Using AppEndpoint parameter
280280

281-
You can pass app endpoints as inputs for more flexibility:
281+
You can pass app endpoints as parameters for more flexibility:
282282

283283
```python
284284
env2 = FastAPIAppEnvironment(
285285
name="frontend-api",
286286
app=app2,
287-
inputs=[
288-
flyte.app.Input(
287+
parameters=[
288+
flyte.app.Parameter(
289289
name="backend_url",
290290
value=flyte.app.AppEndpoint(app_name="backend-api"),
291291
env_var="BACKEND_URL",
@@ -477,7 +477,7 @@ To access a browser-based app:
477477
2. **Handle errors**: Implement proper error handling for HTTP requests.
478478
3. **Use async clients**: Use async HTTP clients (`httpx.AsyncClient`) in async contexts.
479479
4. **Initialize Flyte**: For apps calling tasks, initialize Flyte in the app's startup.
480-
5. **Endpoint access**: Use `app_env.endpoint` or `AppEndpoint` input for accessing app URLs.
480+
5. **Endpoint access**: Use `app_env.endpoint` or `AppEndpoint` parameter for accessing app URLs.
481481
6. **Authentication**: Consider authentication when apps call each other (set `requires_auth=True` if needed).
482482
7. **Webhook security**: Secure webhooks with auth, validation, and HTTPS.
483483
8. **WebSocket robustness**: Implement connection management, heartbeats, and rate limiting.

content/user-guide/build-apps/fastapi-app.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@ env = FastAPIAppEnvironment(
8282
"pydantic",
8383
"joblib",
8484
),
85-
inputs=[
86-
flyte.app.Input(
85+
parameters=[
86+
flyte.app.Parameter(
8787
name="model_file",
8888
value=flyte.io.File("s3://bucket/models/model.joblib"),
8989
mount="/app/models",

content/user-guide/configure-apps/_index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ While `AppEnvironment` inherits from `Environment` (the same base class as `Task
5050
| `domain` ||| Custom domain/subdomain |
5151
| `links` ||| Links to include in the App UI page |
5252
| `include` ||| Files to include in app |
53-
| `inputs` ||| Inputs to pass to app |
53+
| `parameters` ||| Parameters to pass to app |
5454
| `cluster_pool` ||| Cluster pool for deployment |
5555

5656
Parameters like `image`, `resources`, `secrets`, `env_vars`, and `depends_on` are shared between both environment types. See the [task configuration](../task-configuration/) docs for details on these shared parameters.
@@ -63,6 +63,6 @@ Learn more about configuring apps:
6363
- [**Environment settings**](./app-environment-settings): Images, resources, secrets, and app-specific settings like `type`, `port`, `args`, `requires_auth`
6464
- [**App startup**](./app-environment-settings#app-startup): Understanding the difference between `args` and `command`
6565
- [**Including additional files**](./including-additional-files): How to include additional files needed by your app
66-
- [**App inputs**](./passing-inputs): Pass inputs to your app at deployment time
66+
- [**App parameters**](./passing-parameters): Pass parameters to your app at deployment time
6767
- [**Autoscaling apps**](./app-environment-settings#autoscaling-apps): Configure scaling up and down based on traffic with idle TTL
6868
- [**App depending on other environments**](./apps-depending-on-environments): Use `depends_on` to deploy dependent apps together

content/user-guide/configure-apps/app-environment-settings.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ This is particularly useful for passing API keys or other sensitive values to co
110110
> [!TIP]
111111
> For most `AppEnvironment`s, use `args` instead of `command` to specify the app startup command
112112
> in the container. This is because `args` will use the `fserve` command to run the app, which
113-
> unlocks features like local code bundling and file/directory mounting via input injection.
113+
> unlocks features like local code bundling and file/directory mounting via parameter injection.
114114
115115
### `command`
116116

@@ -201,24 +201,24 @@ app_env = flyte.app.AppEnvironment(
201201
> [!NOTE]
202202
> Learn more about including additional files in your app deployment [here](./including-additional-files).
203203
204-
### `inputs`
204+
### `parameters`
205205

206-
The `inputs` parameter passes inputs to your app at deployment time. Inputs can be primitive values, files, directories, or delayed values like `RunOutput` or `AppEndpoint`.
206+
The `parameters` parameter passes parameters to your app at deployment time. Parameters can be primitive values, files, directories, or delayed values like `RunOutput` or `AppEndpoint`.
207207

208208
```python
209209
app_env = flyte.app.AppEnvironment(
210210
name="my-app",
211-
inputs=[
212-
flyte.app.Input(name="config", value="foo", env_var="BAR"),
213-
flyte.app.Input(name="model", value=flyte.io.File(path="s3://bucket/model.pkl"), mount="/mnt/model"),
214-
flyte.app.Input(name="data", value=flyte.io.File(path="s3://bucket/data.pkl"), mount="/mnt/data"),
211+
parameters=[
212+
flyte.app.Parameter(name="config", value="foo", env_var="BAR"),
213+
flyte.app.Parameter(name="model", value=flyte.io.File(path="s3://bucket/model.pkl"), mount="/mnt/model"),
214+
flyte.app.Parameter(name="data", value=flyte.io.File(path="s3://bucket/data.pkl"), mount="/mnt/data"),
215215
],
216216
# ...
217217
)
218218
```
219219

220220
> [!NOTE]
221-
> Learn more about passing inputs to your app at deployment time [here](./passing-inputs).
221+
> Learn more about passing parameters to your app at deployment time [here](./passing-parameters).
222222
223223
### `scaling`
224224

@@ -278,7 +278,7 @@ When you don't specify a `command`, Flyte generates a default command that uses
278278
- Setting up the code bundle
279279
- Configuring the version
280280
- Setting up project/domain context
281-
- Injecting inputs if provided
281+
- Injecting parameters if provided
282282

283283
The default command looks like:
284284

@@ -335,7 +335,7 @@ The `FastAPIAppEnvironment` automatically:
335335
### Startup best practices
336336

337337
1. **Use specialized app environments** when available (for example, `FastAPIAppEnvironment`) – they handle command setup automatically.
338-
2. **Use `args`** when you need code bundling and input injection.
338+
2. **Use `args`** when you need code bundling and parameter injection.
339339
3. **Use `command`** for simple, standalone apps that don't need code bundling.
340340
4. **Always set `port`** to match what your app actually listens on.
341341
5. **Use `include`** with `args` to bundle your app code files.

content/user-guide/configure-apps/apps-depending-on-environments.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ backend_env = flyte.app.AppEnvironment(name="backend-api", ...)
7878
frontend_env = flyte.app.AppEnvironment(
7979
name="frontend-app",
8080
depends_on=[backend_env],
81-
inputs=[
82-
flyte.app.Input(
81+
parameters=[
82+
flyte.app.Parameter(
8383
name="backend_url",
8484
value=flyte.app.AppEndpoint(app_name="backend-api"),
8585
),
@@ -88,7 +88,7 @@ frontend_env = flyte.app.AppEnvironment(
8888
)
8989
```
9090

91-
The `backend_url` input will be automatically set to the backend app's endpoint URL.
91+
The `backend_url` parameter will be automatically set to the backend app's endpoint URL.
9292
You can get this value in your app code using `flyte.app.get_input("backend_url")`.
9393

9494
## Deployment behavior

content/user-guide/configure-apps/passing-inputs.md

Lines changed: 0 additions & 123 deletions
This file was deleted.
Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
---
2+
title: Passing parameters into app environments
3+
weight: 4
4+
variants: +flyte +serverless +byoc +selfmanaged
5+
---
6+
7+
# Passing parameters into app environments
8+
9+
`[[AppEnvironment]]`s support various parameter types that can be passed at deployment time. This includes primitive values, files, directories, and delayed values like `RunOutput` and `AppEndpoint`.
10+
11+
## Parameter types overview
12+
13+
There are several parameter types:
14+
15+
- **Primitive values**: Strings, numbers, booleans
16+
- **Files**: `flyte.io.File` objects
17+
- **Directories**: `flyte.io.Dir` objects
18+
- **Delayed values**: `RunOutput` (from task runs) or `AppEndpoint` (inject endpoint urls of other apps)
19+
20+
## Basic parameter types
21+
22+
{{< code file="/external/unionai-examples/v2/user-guide/build-apps/passing-parameters-examples.py" fragment=basic-parameter-types lang=python >}}
23+
24+
## Delayed values
25+
26+
Delayed values are parameters whose actual values are materialized at deployment time.
27+
28+
### RunOutput
29+
30+
Use `RunOutput` to pass outputs from task runs as app parameters:
31+
32+
{{< code file="/external/unionai-examples/v2/user-guide/build-apps/passing-parameters-examples.py" fragment=runoutput-example lang=python >}}
33+
34+
The `type` argument is required and must be one of `string`, `file`, or `directory`.
35+
When the app is deployed, it will make the remote calls needed to figure out the
36+
actual value of the parameter.
37+
38+
### AppEndpoint
39+
40+
Use `AppEndpoint` to pass endpoints from other apps:
41+
42+
{{< code file="/external/unionai-examples/v2/user-guide/build-apps/passing-parameters-examples.py" fragment=appendpoint-example lang=python >}}
43+
44+
The endpoint URL will be injected as the parameter value when the app starts.
45+
46+
This is particularly useful when you want to chain apps together (for example, a frontend app calling a backend app), without hardcoding URLs.
47+
48+
## Overriding parameters at serve time
49+
50+
You can override parameter values when serving apps (this is not supported for deployment):
51+
52+
```python
53+
# Override parameters when serving
54+
app = flyte.with_servecontext(
55+
input_values={"my-app": {"model_path": "s3://bucket/new-model.pkl"}}
56+
).serve(app_env)
57+
```
58+
59+
> [!NOTE]
60+
> Parameter overrides are only available when using `flyte.serve()` or `flyte.with_servecontext().serve()`.
61+
> The `flyte.deploy()` function does not support parameter overrides - parameters must be specified in the `AppEnvironment` definition.
62+
63+
This is useful for:
64+
- Testing different configurations during development
65+
- Using different models or data sources for testing
66+
- A/B testing different app configurations
67+
68+
## Example: FastAPI app with configurable model
69+
70+
Here's a complete example showing how to use parameters in a FastAPI app:
71+
72+
{{< code file="/external/unionai-examples/v2/user-guide/configure-apps/app-inputs-fastapi-example.py" lang=python >}}
73+
74+
## Example: Using RunOutput for model serving
75+
76+
{{< code file="/external/unionai-examples/v2/user-guide/build-apps/passing-parameters-examples.py" fragment=runoutput-serving-example lang=python >}}
77+
78+
## Accessing parameters in your app
79+
80+
How you access parameters depends on how they're configured:
81+
82+
1. **Environment variables**: If `env_var` is specified, the parameter is available as an environment variable
83+
2. **Mounted paths**: File and directory parameters are mounted at the specified path
84+
3. **Flyte SDK**: Use the Flyte SDK to access parameter values programmatically
85+
86+
```python
87+
import os
88+
89+
# Parameter with env_var specified
90+
env = flyte.app.AppEnvironment(
91+
name="my-app",
92+
parameters=[
93+
flyte.app.Parameter(
94+
name="model_file",
95+
value=flyte.io.File("s3://bucket/model.pkl"),
96+
mount="/app/models/model.pkl",
97+
env_var="MODEL_PATH",
98+
),
99+
],
100+
# ...
101+
)
102+
103+
# Access in the app via the environment variable
104+
API_KEY = os.getenv("API_KEY")
105+
106+
# Access in the app via the mounted path
107+
with open("/app/models/model.pkl", "rb") as f:
108+
model = pickle.load(f)
109+
110+
# Access in the app via the Flyte SDK (for string parameters)
111+
parameter_value = flyte.app.get_parameter("model_file") # Returns string value
112+
```
113+
114+
## Best practices
115+
116+
1. **Use delayed parameters**: Leverage `RunOutput` and `AppEndpoint` to create app dependencies between tasks and apps, or app-to-app chains.
117+
2. **Override for testing**: Use the `input_values` parameter when serving to test different configurations without changing code.
118+
3. **Mount paths clearly**: Use descriptive mount paths for file/directory parameters so your app code is easy to understand.
119+
4. **Use environment variables**: For simple constants that you can hard-code, use `env_var` to inject values as environment variables.
120+
5. **Production deployments**: For production, define parameters in the `AppEnvironment` rather than overriding them at deploy time.
121+
122+
## Limitations
123+
124+
- Large files/directories can slow down app startup.
125+
- Parameter overrides are only available when using `flyte.with_servecontext(...).serve(...)`.

content/user-guide/serve-and-deploy-apps/_index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Flyte provides two main ways to deploy apps: **serve** (for development) and **d
1515

1616
Serving is designed for development and iteration:
1717

18-
- **Dynamic input modification**: You can override app inputs when serving
18+
- **Dynamic parameter modification**: You can override app parameters when serving
1919
- **Quick iteration**: Faster feedback loop for development
2020
- **Interactive**: Better suited for testing and experimentation
2121

0 commit comments

Comments
 (0)