datarobot-pulumi-utils 0.0.2.dev10__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- datarobot_pulumi_utils/__init__.py +13 -0
- datarobot_pulumi_utils/_version.py +1 -0
- datarobot_pulumi_utils/common/__init__.py +16 -0
- datarobot_pulumi_utils/common/feature_flags.py +95 -0
- datarobot_pulumi_utils/common/urls.py +32 -0
- datarobot_pulumi_utils/pulumi/__init__.py +14 -0
- datarobot_pulumi_utils/pulumi/custom_model_deployment.py +111 -0
- datarobot_pulumi_utils/pulumi/playground_custom_model.py +73 -0
- datarobot_pulumi_utils/pulumi/proxy_llm_blueprint.py +83 -0
- datarobot_pulumi_utils/pulumi/rag_custom_model.py +93 -0
- datarobot_pulumi_utils/pulumi/stack.py +56 -0
- datarobot_pulumi_utils/py.typed +0 -0
- datarobot_pulumi_utils/schema/__init__.py +13 -0
- datarobot_pulumi_utils/schema/apps.py +77 -0
- datarobot_pulumi_utils/schema/base.py +31 -0
- datarobot_pulumi_utils/schema/common.py +53 -0
- datarobot_pulumi_utils/schema/custom_models.py +139 -0
- datarobot_pulumi_utils/schema/datasets.py +22 -0
- datarobot_pulumi_utils/schema/exec_envs.py +61 -0
- datarobot_pulumi_utils/schema/guardrails.py +91 -0
- datarobot_pulumi_utils/schema/llms.py +78 -0
- datarobot_pulumi_utils/schema/predictions.py +264 -0
- datarobot_pulumi_utils/schema/training.py +285 -0
- datarobot_pulumi_utils/schema/vectordb.py +37 -0
- datarobot_pulumi_utils-0.0.2.dev10.dist-info/METADATA +45 -0
- datarobot_pulumi_utils-0.0.2.dev10.dist-info/RECORD +29 -0
- datarobot_pulumi_utils-0.0.2.dev10.dist-info/WHEEL +4 -0
- datarobot_pulumi_utils-0.0.2.dev10.dist-info/licenses/AUTHORS +1 -0
- datarobot_pulumi_utils-0.0.2.dev10.dist-info/licenses/LICENSE +201 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Copyright 2025 DataRobot, Inc.
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
version = "0.0.2.dev10"
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# Copyright 2025 DataRobot, Inc.
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
from .feature_flags import check_feature_flags
|
|
15
|
+
|
|
16
|
+
__all__ = ("check_feature_flags",)
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
# Copyright 2025 DataRobot, Inc.
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
import pathlib
|
|
15
|
+
from typing import Iterable, NamedTuple
|
|
16
|
+
|
|
17
|
+
import datarobot as dr
|
|
18
|
+
import pulumi
|
|
19
|
+
import yaml
|
|
20
|
+
|
|
21
|
+
FeatureFlagSet = dict[str, bool]
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
class FeatureFlagCorrection(NamedTuple):
|
|
25
|
+
flag: str
|
|
26
|
+
correct_value: bool
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def fetch_flag_statuses(flags: Iterable[str]) -> FeatureFlagSet:
|
|
30
|
+
client = dr.client.get_client()
|
|
31
|
+
flags_json = {"entitlements": [{"name": flag} for flag in flags]}
|
|
32
|
+
# TODO: we need to use Python SDK here (this method may be missing as of now)
|
|
33
|
+
response = client.post("entitlements/evaluate/", json=flags_json)
|
|
34
|
+
|
|
35
|
+
return {flag_status["name"]: flag_status["value"] for flag_status in response.json()["entitlements"]}
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def get_corrections(desired: dict[str, bool], status: dict[str, bool]) -> list[FeatureFlagCorrection]:
|
|
39
|
+
return [FeatureFlagCorrection(flag, desired[flag]) for flag in status.keys() if desired[flag] != status[flag]]
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def eval_feature_flag_statuses(desired_flags: FeatureFlagSet) -> tuple[list[FeatureFlagCorrection], list[str]]:
|
|
43
|
+
invalid_flags: list[str] = []
|
|
44
|
+
|
|
45
|
+
try:
|
|
46
|
+
status = fetch_flag_statuses(desired_flags.keys())
|
|
47
|
+
|
|
48
|
+
return get_corrections(desired_flags, status), invalid_flags
|
|
49
|
+
except dr.errors.ClientError as e:
|
|
50
|
+
if e.status_code != 422:
|
|
51
|
+
raise e
|
|
52
|
+
|
|
53
|
+
# try to separate invalid feature flags from still valid desired flags
|
|
54
|
+
|
|
55
|
+
for _, value in e.json["errors"].items():
|
|
56
|
+
invalid_flags.append(value)
|
|
57
|
+
|
|
58
|
+
valid_desired_flags = {k: v for k, v in desired_flags.items() if k not in invalid_flags}
|
|
59
|
+
valid_desired_flag_states = fetch_flag_statuses(valid_desired_flags.keys())
|
|
60
|
+
|
|
61
|
+
return get_corrections(valid_desired_flags, valid_desired_flag_states), invalid_flags
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
def check_feature_flags(yaml_path: pathlib.Path, raise_corrections: bool = True) -> None:
|
|
65
|
+
"""
|
|
66
|
+
Find incorrect and invalid feature flags
|
|
67
|
+
|
|
68
|
+
Returns
|
|
69
|
+
-------
|
|
70
|
+
A list of feature flag corrections the user needs to make and
|
|
71
|
+
a list of invalid feature flags.
|
|
72
|
+
"""
|
|
73
|
+
with open(yaml_path) as f:
|
|
74
|
+
desired_flags = yaml.safe_load(f)
|
|
75
|
+
|
|
76
|
+
desired_flags = {k: bool(v) for k, v in desired_flags.items()}
|
|
77
|
+
|
|
78
|
+
corrections, invalid_flags = eval_feature_flag_statuses(desired_flags)
|
|
79
|
+
|
|
80
|
+
for flag in invalid_flags:
|
|
81
|
+
correct_value = desired_flags[flag]
|
|
82
|
+
|
|
83
|
+
pulumi.warn(
|
|
84
|
+
f"Feature flag '{flag}' is required to be {correct_value} but is no longer a valid DataRobot feature flag."
|
|
85
|
+
)
|
|
86
|
+
|
|
87
|
+
for flag, correct_value in corrections:
|
|
88
|
+
pulumi.error(
|
|
89
|
+
f"This app template requires that feature flag '{flag}' is set "
|
|
90
|
+
f"to {correct_value}. Contact your DataRobot representative for "
|
|
91
|
+
"assistance."
|
|
92
|
+
)
|
|
93
|
+
|
|
94
|
+
if corrections and raise_corrections:
|
|
95
|
+
raise pulumi.RunError("Please correct feature flag settings and run again.")
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# Copyright 2025 DataRobot, Inc.
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
import os
|
|
15
|
+
from urllib.parse import urlsplit
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def get_deployment_url(deployment_id: str) -> str:
|
|
19
|
+
"""Translate deployment ID to GUI URL.
|
|
20
|
+
|
|
21
|
+
TODO(CFX-1849): Replace it with a call to Python SDK
|
|
22
|
+
|
|
23
|
+
Parameters
|
|
24
|
+
----------
|
|
25
|
+
deployment_id : str
|
|
26
|
+
DataRobot deployment id.
|
|
27
|
+
endpoint: str
|
|
28
|
+
DataRobot public API endpoint e.g. envir
|
|
29
|
+
"""
|
|
30
|
+
parsed_dr_url = urlsplit(os.environ["DATAROBOT_ENDPOINT"])
|
|
31
|
+
|
|
32
|
+
return f"{parsed_dr_url.scheme}://{parsed_dr_url.netloc}/console-nextgen/deployments/{deployment_id}/"
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# Copyright 2025 DataRobot, Inc.
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
# Copyright 2025 DataRobot, Inc.
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
from __future__ import annotations
|
|
15
|
+
|
|
16
|
+
from typing import Sequence
|
|
17
|
+
|
|
18
|
+
import pulumi
|
|
19
|
+
import pulumi_datarobot as drp
|
|
20
|
+
|
|
21
|
+
from datarobot_pulumi_utils.schema.custom_models import (
|
|
22
|
+
CustomModelArgs,
|
|
23
|
+
DeploymentArgs,
|
|
24
|
+
RegisteredModelArgs,
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
class CustomModelDeployment(pulumi.ComponentResource):
|
|
29
|
+
def __init__(
|
|
30
|
+
self,
|
|
31
|
+
resource_name: str,
|
|
32
|
+
registered_model_args: RegisteredModelArgs,
|
|
33
|
+
prediction_environment: drp.PredictionEnvironment,
|
|
34
|
+
deployment_args: DeploymentArgs,
|
|
35
|
+
use_case_ids: Sequence[pulumi.Output[str]] | str | None = None,
|
|
36
|
+
custom_model_version_id: pulumi.Input[str] | None = None,
|
|
37
|
+
custom_model_args: CustomModelArgs | None = None,
|
|
38
|
+
opts: pulumi.ResourceOptions | None = None,
|
|
39
|
+
):
|
|
40
|
+
"""
|
|
41
|
+
Deploy a custom model in DataRobot.
|
|
42
|
+
|
|
43
|
+
This class performs the following steps:
|
|
44
|
+
1. Registers the custom model.
|
|
45
|
+
2. Deploys the registered model to the specified prediction environment.
|
|
46
|
+
|
|
47
|
+
Parameters:
|
|
48
|
+
-----------
|
|
49
|
+
name : str
|
|
50
|
+
The name of this Pulumi resource.
|
|
51
|
+
custom_model : datarobot.CustomModel
|
|
52
|
+
The custom model to be deployed.
|
|
53
|
+
prediction_environment : datarobot.PredictionEnvironment
|
|
54
|
+
The DataRobot PredictionEnvironment object where the model will be deployed.
|
|
55
|
+
registered_model_args : RegisteredModelArgs
|
|
56
|
+
Arguments for registering the model.
|
|
57
|
+
deployment_args : DeploymentArgs
|
|
58
|
+
Arguments for creating the Deployment.
|
|
59
|
+
opts : Optional[pulumi.ResourceOptions]
|
|
60
|
+
Optional Pulumi resource options.
|
|
61
|
+
"""
|
|
62
|
+
super().__init__("custom:datarobot:CustomModelDeployment", resource_name, None, opts)
|
|
63
|
+
if (custom_model_version_id and custom_model_args) or (not custom_model_version_id and not custom_model_args):
|
|
64
|
+
raise ValueError("Exactly one of custom_model_version_id and custom_model_args must be specified")
|
|
65
|
+
|
|
66
|
+
if custom_model_args:
|
|
67
|
+
custom_model_version_id = drp.CustomModel(
|
|
68
|
+
**custom_model_args.model_dump(exclude_none=True),
|
|
69
|
+
opts=pulumi.ResourceOptions(parent=self),
|
|
70
|
+
use_case_ids=use_case_ids,
|
|
71
|
+
).version_id
|
|
72
|
+
|
|
73
|
+
self.registered_model = drp.RegisteredModel(
|
|
74
|
+
custom_model_version_id=custom_model_version_id,
|
|
75
|
+
**registered_model_args.model_dump(mode="json"),
|
|
76
|
+
opts=pulumi.ResourceOptions(parent=self),
|
|
77
|
+
use_case_ids=use_case_ids,
|
|
78
|
+
)
|
|
79
|
+
|
|
80
|
+
self.deployment = drp.Deployment(
|
|
81
|
+
prediction_environment_id=prediction_environment.id,
|
|
82
|
+
registered_model_version_id=self.registered_model.version_id,
|
|
83
|
+
**deployment_args.model_dump(),
|
|
84
|
+
opts=pulumi.ResourceOptions(parent=self),
|
|
85
|
+
use_case_ids=use_case_ids,
|
|
86
|
+
)
|
|
87
|
+
|
|
88
|
+
self.register_outputs(
|
|
89
|
+
{
|
|
90
|
+
"custom_model_version_id": custom_model_version_id,
|
|
91
|
+
"registered_model_id": self.registered_model.id,
|
|
92
|
+
"registered_model_version_id": self.registered_model.version_id,
|
|
93
|
+
"deployment_id": self.deployment.id,
|
|
94
|
+
}
|
|
95
|
+
)
|
|
96
|
+
|
|
97
|
+
@property
|
|
98
|
+
def id(self) -> pulumi.Output[str]:
|
|
99
|
+
return self.deployment.id
|
|
100
|
+
|
|
101
|
+
@property
|
|
102
|
+
def deployment_id(self) -> pulumi.Output[str]:
|
|
103
|
+
return self.deployment.id
|
|
104
|
+
|
|
105
|
+
@property
|
|
106
|
+
def registered_model_id(self) -> pulumi.Output[str]:
|
|
107
|
+
return self.registered_model.id
|
|
108
|
+
|
|
109
|
+
@property
|
|
110
|
+
def registered_model_version_id(self) -> pulumi.Output[str]:
|
|
111
|
+
return self.registered_model.version_id
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# Copyright 2025 DataRobot, Inc.
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
from __future__ import annotations
|
|
15
|
+
|
|
16
|
+
import pulumi
|
|
17
|
+
import pulumi_datarobot as drp
|
|
18
|
+
|
|
19
|
+
from datarobot_pulumi_utils.schema.custom_models import CustomModelArgs
|
|
20
|
+
from datarobot_pulumi_utils.schema.llms import LLMBlueprintArgs, PlaygroundArgs
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class PlaygroundCustomModel(pulumi.ComponentResource):
|
|
24
|
+
def __init__(
|
|
25
|
+
self,
|
|
26
|
+
resource_name: str,
|
|
27
|
+
use_case: drp.UseCase,
|
|
28
|
+
playground_args: PlaygroundArgs,
|
|
29
|
+
llm_blueprint_args: LLMBlueprintArgs,
|
|
30
|
+
runtime_parameter_values: list[drp.CustomModelRuntimeParameterValueArgs],
|
|
31
|
+
custom_model_args: CustomModelArgs,
|
|
32
|
+
guard_configurations: list[drp.CustomModelGuardConfigurationArgs] | None = None,
|
|
33
|
+
opts: pulumi.ResourceOptions | None = None,
|
|
34
|
+
):
|
|
35
|
+
super().__init__("custom:datarobot:PlaygroundCustomModel", resource_name, None, opts)
|
|
36
|
+
|
|
37
|
+
self.playground = drp.Playground(
|
|
38
|
+
use_case_id=use_case.id,
|
|
39
|
+
**playground_args.model_dump(mode="json"),
|
|
40
|
+
opts=pulumi.ResourceOptions(parent=self),
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
self.llm_blueprint = drp.LlmBlueprint(
|
|
44
|
+
playground_id=self.playground.id,
|
|
45
|
+
**llm_blueprint_args.model_dump(),
|
|
46
|
+
opts=pulumi.ResourceOptions(parent=self),
|
|
47
|
+
)
|
|
48
|
+
|
|
49
|
+
self.custom_model = drp.CustomModel(
|
|
50
|
+
source_llm_blueprint_id=self.llm_blueprint.id,
|
|
51
|
+
runtime_parameter_values=runtime_parameter_values,
|
|
52
|
+
guard_configurations=guard_configurations,
|
|
53
|
+
use_case_ids=[use_case.id],
|
|
54
|
+
**custom_model_args.model_dump(mode="json", exclude_none=True),
|
|
55
|
+
opts=pulumi.ResourceOptions(parent=self),
|
|
56
|
+
)
|
|
57
|
+
|
|
58
|
+
self.register_outputs(
|
|
59
|
+
{
|
|
60
|
+
"playground_id": self.playground.id,
|
|
61
|
+
"llm_blueprint_id": self.llm_blueprint.id,
|
|
62
|
+
"id": self.custom_model.id,
|
|
63
|
+
"version_id": self.custom_model.version_id,
|
|
64
|
+
}
|
|
65
|
+
)
|
|
66
|
+
|
|
67
|
+
@property
|
|
68
|
+
@pulumi.getter(name="versionId")
|
|
69
|
+
def version_id(self) -> pulumi.Output[str]:
|
|
70
|
+
"""
|
|
71
|
+
The ID of the latest Playground Custom Model version.
|
|
72
|
+
"""
|
|
73
|
+
return self.custom_model.version_id
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
# Copyright 2025 DataRobot, Inc.
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
from __future__ import annotations
|
|
15
|
+
|
|
16
|
+
from typing import Any
|
|
17
|
+
|
|
18
|
+
import pulumi
|
|
19
|
+
import pulumi_datarobot as datarobot
|
|
20
|
+
|
|
21
|
+
from datarobot_pulumi_utils.schema.llms import LLMSettings
|
|
22
|
+
from datarobot_pulumi_utils.schema.vectordb import VectorDatabaseSettings
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class ProxyLLMBlueprint(pulumi.ComponentResource):
|
|
26
|
+
def __init__(
|
|
27
|
+
self,
|
|
28
|
+
resource_name: str,
|
|
29
|
+
proxy_llm_deployment_id: pulumi.Output[str],
|
|
30
|
+
use_case_id: pulumi.Output[str],
|
|
31
|
+
playground_id: pulumi.Output[str],
|
|
32
|
+
llm_id: str,
|
|
33
|
+
llm_settings: LLMSettings,
|
|
34
|
+
vector_database_settings: VectorDatabaseSettings | None = None,
|
|
35
|
+
vector_database_id: pulumi.Output[str] | None = None,
|
|
36
|
+
opts: pulumi.ResourceOptions | None = None,
|
|
37
|
+
chat_model_name: str | pulumi.Output[str] | None = None,
|
|
38
|
+
**kwargs: Any,
|
|
39
|
+
) -> None:
|
|
40
|
+
super().__init__("custom:datarobot:ProxyLLMBlueprint", resource_name, None, opts)
|
|
41
|
+
|
|
42
|
+
self.llm_validation = datarobot.CustomModelLlmValidation(
|
|
43
|
+
resource_name=f"{resource_name}-validation",
|
|
44
|
+
chat_model_id=chat_model_name,
|
|
45
|
+
deployment_id=proxy_llm_deployment_id,
|
|
46
|
+
use_case_id=use_case_id,
|
|
47
|
+
opts=pulumi.ResourceOptions(replace_on_changes=["*"], parent=self),
|
|
48
|
+
)
|
|
49
|
+
|
|
50
|
+
if isinstance(llm_settings, dict):
|
|
51
|
+
llm_settings = LLMSettings(**llm_settings)
|
|
52
|
+
if isinstance(vector_database_settings, dict):
|
|
53
|
+
vector_database_settings = VectorDatabaseSettings(**vector_database_settings)
|
|
54
|
+
|
|
55
|
+
self.llm_blueprint = datarobot.LlmBlueprint(
|
|
56
|
+
resource_name=resource_name,
|
|
57
|
+
custom_model_llm_settings=datarobot.LlmBlueprintCustomModelLlmSettingsArgs(
|
|
58
|
+
system_prompt=llm_settings.system_prompt,
|
|
59
|
+
validation_id=self.llm_validation.id,
|
|
60
|
+
),
|
|
61
|
+
llm_id=llm_id,
|
|
62
|
+
playground_id=playground_id,
|
|
63
|
+
vector_database_id=vector_database_id,
|
|
64
|
+
vector_database_settings=vector_database_settings.model_dump()
|
|
65
|
+
if vector_database_settings is not None
|
|
66
|
+
else None,
|
|
67
|
+
opts=pulumi.ResourceOptions(parent=self),
|
|
68
|
+
)
|
|
69
|
+
|
|
70
|
+
self.register_outputs(
|
|
71
|
+
{
|
|
72
|
+
"llm_validation_id": self.llm_validation.id,
|
|
73
|
+
"id": self.llm_blueprint.id,
|
|
74
|
+
}
|
|
75
|
+
)
|
|
76
|
+
|
|
77
|
+
@property
|
|
78
|
+
@pulumi.getter(name="id")
|
|
79
|
+
def id(self) -> pulumi.Output[str]:
|
|
80
|
+
"""
|
|
81
|
+
The ID of the latest LLM Blueprint version.
|
|
82
|
+
"""
|
|
83
|
+
return self.llm_blueprint.id
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
# Copyright 2024 DataRobot, Inc.
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
from __future__ import annotations
|
|
15
|
+
|
|
16
|
+
import pulumi
|
|
17
|
+
import pulumi_datarobot as datarobot
|
|
18
|
+
|
|
19
|
+
from datarobot_pulumi_utils.schema.custom_models import CustomModelArgs
|
|
20
|
+
from datarobot_pulumi_utils.schema.datasets import DatasetArgs
|
|
21
|
+
from datarobot_pulumi_utils.schema.llms import LLMBlueprintArgs, PlaygroundArgs
|
|
22
|
+
from datarobot_pulumi_utils.schema.vectordb import VectorDatabaseArgs
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class RAGCustomModel(pulumi.ComponentResource):
|
|
26
|
+
def __init__(
|
|
27
|
+
self,
|
|
28
|
+
resource_name: str,
|
|
29
|
+
use_case: datarobot.UseCase,
|
|
30
|
+
dataset_args: DatasetArgs,
|
|
31
|
+
playground_args: PlaygroundArgs,
|
|
32
|
+
vector_database_args: VectorDatabaseArgs,
|
|
33
|
+
llm_blueprint_args: LLMBlueprintArgs,
|
|
34
|
+
runtime_parameter_values: list[datarobot.CustomModelRuntimeParameterValueArgs],
|
|
35
|
+
guard_configurations: list[datarobot.CustomModelGuardConfigurationArgs],
|
|
36
|
+
custom_model_args: CustomModelArgs,
|
|
37
|
+
opts: pulumi.ResourceOptions | None = None,
|
|
38
|
+
):
|
|
39
|
+
super().__init__("custom:datarobot:RAGCustomModel", resource_name, None, opts)
|
|
40
|
+
|
|
41
|
+
self.playground = datarobot.Playground(
|
|
42
|
+
use_case_id=use_case.id,
|
|
43
|
+
**playground_args.model_dump(mode="json"),
|
|
44
|
+
opts=pulumi.ResourceOptions(parent=self),
|
|
45
|
+
)
|
|
46
|
+
|
|
47
|
+
self.vdb_dataset = datarobot.DatasetFromFile(
|
|
48
|
+
use_case_ids=[use_case.id],
|
|
49
|
+
**dataset_args.model_dump(mode="json"),
|
|
50
|
+
opts=pulumi.ResourceOptions(parent=self),
|
|
51
|
+
)
|
|
52
|
+
|
|
53
|
+
self.vector_database = datarobot.VectorDatabase(
|
|
54
|
+
dataset_id=self.vdb_dataset.id,
|
|
55
|
+
use_case_id=use_case.id,
|
|
56
|
+
**vector_database_args.model_dump(mode="json"),
|
|
57
|
+
opts=pulumi.ResourceOptions(parent=self),
|
|
58
|
+
)
|
|
59
|
+
|
|
60
|
+
self.llm_blueprint = datarobot.LlmBlueprint(
|
|
61
|
+
playground_id=self.playground.id,
|
|
62
|
+
vector_database_id=self.vector_database.id,
|
|
63
|
+
**llm_blueprint_args.model_dump(mode="json"),
|
|
64
|
+
opts=pulumi.ResourceOptions(parent=self),
|
|
65
|
+
)
|
|
66
|
+
|
|
67
|
+
self.custom_model = datarobot.CustomModel(
|
|
68
|
+
source_llm_blueprint_id=self.llm_blueprint.id,
|
|
69
|
+
runtime_parameter_values=runtime_parameter_values,
|
|
70
|
+
guard_configurations=guard_configurations,
|
|
71
|
+
use_case_ids=[use_case.id],
|
|
72
|
+
**custom_model_args.model_dump(mode="json", exclude_none=True),
|
|
73
|
+
opts=pulumi.ResourceOptions(parent=self),
|
|
74
|
+
)
|
|
75
|
+
|
|
76
|
+
self.register_outputs(
|
|
77
|
+
{
|
|
78
|
+
"playground_id": self.playground.id,
|
|
79
|
+
"dataset_id": self.vdb_dataset.id,
|
|
80
|
+
"vector_database_id": self.vector_database.id,
|
|
81
|
+
"llm_blueprint_id": self.llm_blueprint.id,
|
|
82
|
+
"id": self.custom_model.id,
|
|
83
|
+
"version_id": self.custom_model.version_id,
|
|
84
|
+
}
|
|
85
|
+
)
|
|
86
|
+
|
|
87
|
+
@property
|
|
88
|
+
@pulumi.getter(name="versionId")
|
|
89
|
+
def version_id(self) -> pulumi.Output[str]:
|
|
90
|
+
"""
|
|
91
|
+
The ID of the latest Custom Model version.
|
|
92
|
+
"""
|
|
93
|
+
return self.custom_model.version_id
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# Copyright 2024 DataRobot, Inc.
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
import os
|
|
15
|
+
import subprocess
|
|
16
|
+
|
|
17
|
+
import pulumi
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def get_stack() -> str:
|
|
21
|
+
"""Retrieve the active pulumi stack
|
|
22
|
+
|
|
23
|
+
Attempt to retrieve from the pulumi runtime
|
|
24
|
+
If no stack selected, attempt to infer from an env var
|
|
25
|
+
|
|
26
|
+
Allows subprocesses w/o access to the pulumi runtime to see the active stack even
|
|
27
|
+
if `pulumi up -s` syntax is used with no selected stack.
|
|
28
|
+
"""
|
|
29
|
+
try:
|
|
30
|
+
stack = pulumi.get_stack()
|
|
31
|
+
if stack != "stack":
|
|
32
|
+
os.environ["PULUMI_STACK_CONTEXT"] = stack
|
|
33
|
+
return stack
|
|
34
|
+
except Exception:
|
|
35
|
+
pass
|
|
36
|
+
try:
|
|
37
|
+
return os.environ["PULUMI_STACK_CONTEXT"]
|
|
38
|
+
except KeyError:
|
|
39
|
+
pass
|
|
40
|
+
try:
|
|
41
|
+
return subprocess.check_output(
|
|
42
|
+
["pulumi", "stack", "--show-name", "--non-interactive"],
|
|
43
|
+
text=True,
|
|
44
|
+
stderr=subprocess.STDOUT,
|
|
45
|
+
).strip()
|
|
46
|
+
except subprocess.CalledProcessError:
|
|
47
|
+
pass
|
|
48
|
+
raise ValueError(
|
|
49
|
+
(
|
|
50
|
+
"Unable to retrieve the currently active stack. "
|
|
51
|
+
"Verify you have created and selected a stack with `pulumi stack`."
|
|
52
|
+
)
|
|
53
|
+
)
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
PROJECT_NAME = get_stack()
|
|
File without changes
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Copyright 2025 DataRobot, Inc.
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|