App framework utilities¶
Settings¶
DataRobotAppFrameworkBaseSettings¶
Base settings class that reads each setting from the first source that defines it:
- Environment variables, including runtime parameters
- The
.envfile - File secrets
pulumi_config.json(fallback)
However a variable is set, it is picked up, so the same settings class works both locally and once deployed in DataRobot. This covers credentials and plain variables for runtime parameters in both custom applications and custom models.
Examples
class Config(DataRobotAppFrameworkBaseSettings):
my_variable: str = "default_value"
another_variable: Optional[int]
config = Config()
assert config.my_variable == "value_from_env_or_pulumi_or_default"
settings_customise_sources()¶
Define the sources and their order for loading the settings values.
Parameters
| Parameter | Type | Description |
|---|---|---|
settings_cls |
Type[BaseSettings] |
The Settings class. |
init_settings |
PydanticBaseSettingsSource |
The InitSettingsSource instance. |
env_settings |
PydanticBaseSettingsSource |
The EnvSettingsSource instance. |
dotenv_settings |
PydanticBaseSettingsSource |
The DotEnvSettingsSource instance. |
file_secret_settings |
PydanticBaseSettingsSource |
The SecretsSettingsSource instance. |
Return type: Tuple[PydanticBaseSettingsSource, ...]
Returns
| Returns | Description |
|---|---|
| A tuple containing the sources and their order for loading the settings values. |
resolve_datarobot_endpoint()¶
Resolve the DataRobot endpoint from this config, or fall back to the public default.
Return type: str
resolve_datarobot_api_token()¶
Resolve the DataRobot API token from this config, treating an empty value as unset.
Return type: Optional[str]
resolve_llm_config()¶
Build the config for one named LLM instance from this settings object.
Call this once per configured LLM to support more than one LLM in a single app.
Parameters
| Parameter | Type | Description |
|---|---|---|
name |
str |
Name of the LLM component instance, used as the prefix of its {name}_* fields. Defaults to "llm". |
Returns
| Returns | Description |
|---|---|
| That instance’s routing fields, combined with the endpoint and API token | |
| resolved from this config. |
Return type: LLMConfig
OpenTelemetry¶
datarobot.core.create_dr_resource(entity_type, entity_id, , service_priority='p1', extra_attrs=None)¶
Build an OpenTelemetry Resource with DataRobot-standard attributes.
Parameters
| Parameter | Type | Description |
|---|---|---|
entity_type |
str |
DataRobot entity type (e.g. "experiment_container"). |
entity_id |
str |
DataRobot entity ID. |
service_priority |
str |
Value for datarobot.service.priority. Defaults to "p1". |
extra_attrs |
Optional[Dict[str, str]] |
Additional or override attributes merged last, taking precedence over all computed values. |
Return type: Resource
Returns
| Returns | Description |
|---|---|
An opentelemetry.sdk.resources.Resource ready to pass to a |
|
TracerProvider / MeterProvider / LoggerProvider. |
Raises
| Exception | Description |
|---|---|
| ImportError | If opentelemetry-sdk is not installed. Install the datarobot[otel] extra to add it. |
NOTE¶
service.name is only set when OTEL_SERVICE_NAME is absent from the
environment — Resource.create() merges env vars at lower precedence than
explicit attrs, so setting it here would shadow any platform-provided value.
LLM configuration¶
LLMConfig¶
Resolved connection parameters for a single LLM instance.
An app can hold one of these per configured LLM. Each carries the routing fields for its own LLM plus a copy of the DataRobot endpoint and API token, so building a client from it never requires reading a global config.
Variables
| Attribute | Type | Description |
|---|---|---|
datarobot_endpoint |
str or None |
DataRobot API endpoint. Defaults to DEFAULT_DATAROBOT_ENDPOINT when unset. |
datarobot_api_token |
str or None |
DataRobot API token used to authenticate LLM requests. |
llm_deployment_id |
str or None |
ID of the deployment serving the LLM, when routing to a deployment. |
llm_nim_deployment_id |
str or None |
ID of the deployment serving a NIM model, when routing to a NIM. |
llm_use_datarobot_llm_gateway |
bool |
Whether to route through the DataRobot LLM gateway. Takes precedence over both deployment IDs. Defaults to True. |
llm_default_model |
str or None |
Model name to request. Defaults to DEFAULT_MODEL_NAME_FOR_DEPLOYED_LLM. |
Notes
This is intentionally a plain model rather than a
DataRobotAppFrameworkBaseSettings subclass. The settings class is the
single app-wide source of configuration, so keeping LLMConfig separate is what
lets one app configure several LLMs, including fallbacks.
get_llm_type()¶
Report which route this config uses, checking the routing fields in precedence order.
Return type: LLMType
to_litellm_params()¶
Render this config as a litellm_params entry for a litellm.Router model list.
Returns
| Returns | Description |
|---|---|
The litellm connection parameters: model, api_key, and, for every |
|
route other than an external provider, api_base. |
Return type: dict
LLMType¶
How an LLMConfig routes its requests.