App framework utilities
Settings
- class datarobot.core.DataRobotAppFrameworkBaseSettings
Base settings class that reads each setting from the first source that defines it:
Environment variables, including runtime parameters
The
.envfileFile 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"
- classmethod settings_customise_sources(settings_cls, init_settings, env_settings, dotenv_settings, file_secret_settings)
Define the sources and their order for loading the settings values.
- Parameters:
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:
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(name='llm')
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:
name (
str) – Name of the LLM component instance, used as the prefix of its{name}_*fields. Defaults to"llm".- Returns:
That instance’s routing fields, combined with the endpoint and API token resolved from this config.
- Return type:
Notes
Two routing fields fall back to their pre-rename bare parameter names,
NIM_DEPLOYMENT_IDandUSE_DATAROBOT_LLM_GATEWAY, when the namespaced{name}_*field was not set explicitly. That keeps deployments created before the rename working, warns when it happens, and is meant to be removed later.
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:
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:
An
opentelemetry.sdk.resources.Resourceready to pass to aTracerProvider/MeterProvider/LoggerProvider.- Raises:
ImportError – If
opentelemetry-sdkis not installed. Install thedatarobot[otel]extra to add it.
Note
service.nameis only set whenOTEL_SERVICE_NAMEis 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
- class datarobot.core.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:
datarobot_endpoint (
strorNone) – DataRobot API endpoint. Defaults toDEFAULT_DATAROBOT_ENDPOINTwhen unset.datarobot_api_token (
strorNone) – DataRobot API token used to authenticate LLM requests.llm_deployment_id (
strorNone) – ID of the deployment serving the LLM, when routing to a deployment.llm_nim_deployment_id (
strorNone) – 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 toTrue.llm_default_model (
strorNone) – Model name to request. Defaults toDEFAULT_MODEL_NAME_FOR_DEPLOYED_LLM.
Notes
This is intentionally a plain model rather than a
DataRobotAppFrameworkBaseSettingssubclass. The settings class is the single app-wide source of configuration, so keepingLLMConfigseparate 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:
- to_litellm_params()
Render this config as a
litellm_paramsentry for alitellm.Routermodel list.- Returns:
The
litellmconnection parameters:model,api_key, and, for every route other than an external provider,api_base.- Return type:
dict