truefoundry 0.5.0rc6__py3-none-any.whl → 0.5.1__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.
Potentially problematic release.
This version of truefoundry might be problematic. Click here for more details.
- truefoundry/common/auth_service_client.py +2 -2
- truefoundry/common/constants.py +9 -0
- truefoundry/common/utils.py +81 -1
- truefoundry/deploy/__init__.py +5 -0
- truefoundry/deploy/builder/builders/tfy_notebook_buildpack/__init__.py +4 -2
- truefoundry/deploy/builder/builders/tfy_python_buildpack/__init__.py +7 -5
- truefoundry/deploy/builder/builders/tfy_python_buildpack/dockerfile_template.py +87 -28
- truefoundry/deploy/builder/constants.py +8 -0
- truefoundry/deploy/builder/utils.py +9 -4
- truefoundry/deploy/cli/cli.py +2 -0
- truefoundry/deploy/cli/commands/__init__.py +1 -0
- truefoundry/deploy/cli/commands/deploy_init_command.py +22 -0
- truefoundry/deploy/lib/dao/application.py +2 -1
- truefoundry/deploy/v2/lib/patched_models.py +8 -0
- truefoundry/ml/__init__.py +25 -15
- truefoundry/ml/artifact/truefoundry_artifact_repo.py +8 -3
- truefoundry/ml/autogen/client/__init__.py +24 -0
- truefoundry/ml/autogen/client/api/mlfoundry_artifacts_api.py +325 -0
- truefoundry/ml/autogen/client/models/__init__.py +24 -0
- truefoundry/ml/autogen/client/models/artifact_version_manifest.py +2 -2
- truefoundry/ml/autogen/client/models/export_deployment_files_request_dto.py +82 -0
- truefoundry/ml/autogen/client/models/infer_method_name.py +34 -0
- truefoundry/ml/autogen/client/models/model_server.py +34 -0
- truefoundry/ml/autogen/client/models/model_version_environment.py +97 -0
- truefoundry/ml/autogen/client/models/model_version_manifest.py +13 -8
- truefoundry/ml/autogen/client/models/sklearn_framework.py +25 -2
- truefoundry/ml/autogen/client/models/sklearn_model_schema.py +82 -0
- truefoundry/ml/autogen/client/models/sklearn_serialization_format.py +35 -0
- truefoundry/ml/autogen/client/models/transformers_framework.py +2 -2
- truefoundry/ml/autogen/client/models/validate_external_storage_root_request_dto.py +71 -0
- truefoundry/ml/autogen/client/models/validate_external_storage_root_response_dto.py +69 -0
- truefoundry/ml/autogen/client/models/xg_boost_framework.py +28 -3
- truefoundry/ml/autogen/client/models/xg_boost_model_schema.py +88 -0
- truefoundry/ml/autogen/client/models/xg_boost_serialization_format.py +36 -0
- truefoundry/ml/autogen/client_README.md +12 -0
- truefoundry/ml/autogen/entities/artifacts.py +119 -26
- truefoundry/ml/autogen/models/signature.py +6 -3
- truefoundry/ml/autogen/models/utils.py +12 -7
- truefoundry/ml/cli/commands/model_init.py +97 -0
- truefoundry/ml/cli/utils.py +34 -0
- truefoundry/ml/log_types/artifacts/model.py +53 -38
- truefoundry/ml/log_types/artifacts/utils.py +38 -2
- truefoundry/ml/mlfoundry_api.py +77 -81
- truefoundry/ml/mlfoundry_run.py +3 -33
- truefoundry/ml/model_framework.py +372 -3
- truefoundry/ml/validation_utils.py +2 -0
- {truefoundry-0.5.0rc6.dist-info → truefoundry-0.5.1.dist-info}/METADATA +2 -6
- {truefoundry-0.5.0rc6.dist-info → truefoundry-0.5.1.dist-info}/RECORD +50 -55
- truefoundry/deploy/function_service/__init__.py +0 -3
- truefoundry/deploy/function_service/__main__.py +0 -27
- truefoundry/deploy/function_service/app.py +0 -92
- truefoundry/deploy/function_service/build.py +0 -45
- truefoundry/deploy/function_service/remote/__init__.py +0 -6
- truefoundry/deploy/function_service/remote/context.py +0 -3
- truefoundry/deploy/function_service/remote/method.py +0 -67
- truefoundry/deploy/function_service/remote/remote.py +0 -144
- truefoundry/deploy/function_service/route.py +0 -137
- truefoundry/deploy/function_service/service.py +0 -113
- truefoundry/deploy/function_service/utils.py +0 -53
- truefoundry/langchain/__init__.py +0 -12
- truefoundry/langchain/deprecated.py +0 -302
- truefoundry/langchain/truefoundry_chat.py +0 -130
- truefoundry/langchain/truefoundry_embeddings.py +0 -171
- truefoundry/langchain/truefoundry_llm.py +0 -106
- truefoundry/langchain/utils.py +0 -44
- truefoundry/ml/log_types/artifacts/model_extras.py +0 -48
- {truefoundry-0.5.0rc6.dist-info → truefoundry-0.5.1.dist-info}/WHEEL +0 -0
- {truefoundry-0.5.0rc6.dist-info → truefoundry-0.5.1.dist-info}/entry_points.txt +0 -0
|
@@ -102,6 +102,7 @@ Class | Method | HTTP request | Description
|
|
|
102
102
|
*MlfoundryArtifactsApi* | [**delete_dataset_post**](truefoundry/ml/autogen/client/docs/MlfoundryArtifactsApi.md#delete_dataset_post) | **POST** /api/2.0/mlflow/mlfoundry-artifacts/datasets/delete | Delete Dataset
|
|
103
103
|
*MlfoundryArtifactsApi* | [**delete_files_for_dataset_delete**](truefoundry/ml/autogen/client/docs/MlfoundryArtifactsApi.md#delete_files_for_dataset_delete) | **DELETE** /api/2.0/mlflow/mlfoundry-artifacts/datasets/files/ | Delete Files For Dataset
|
|
104
104
|
*MlfoundryArtifactsApi* | [**delete_model_version_post**](truefoundry/ml/autogen/client/docs/MlfoundryArtifactsApi.md#delete_model_version_post) | **POST** /api/2.0/mlflow/mlfoundry-artifacts/model-versions/delete | Delete Model Version
|
|
105
|
+
*MlfoundryArtifactsApi* | [**export_deployment_files_by_fqn_post**](truefoundry/ml/autogen/client/docs/MlfoundryArtifactsApi.md#export_deployment_files_by_fqn_post) | **POST** /api/2.0/mlflow/mlfoundry-artifacts/model-versions/export-deployment-files-by-fqn | Export Deployment Files By Fqn
|
|
105
106
|
*MlfoundryArtifactsApi* | [**finalize_artifact_version_post**](truefoundry/ml/autogen/client/docs/MlfoundryArtifactsApi.md#finalize_artifact_version_post) | **POST** /api/2.0/mlflow/mlfoundry-artifacts/artifact-versions/finalize | Finalize Artifact Version
|
|
106
107
|
*MlfoundryArtifactsApi* | [**get_artifact_by_fqn_get**](truefoundry/ml/autogen/client/docs/MlfoundryArtifactsApi.md#get_artifact_by_fqn_get) | **GET** /api/2.0/mlflow/mlfoundry-artifacts/artifacts/get-by-fqn | Get Artifact By Fqn
|
|
107
108
|
*MlfoundryArtifactsApi* | [**get_artifact_by_id_get**](truefoundry/ml/autogen/client/docs/MlfoundryArtifactsApi.md#get_artifact_by_id_get) | **GET** /api/2.0/mlflow/mlfoundry-artifacts/artifacts/get | Get Artifact By Id
|
|
@@ -132,6 +133,7 @@ Class | Method | HTTP request | Description
|
|
|
132
133
|
*MlfoundryArtifactsApi* | [**update_artifact_version_post**](truefoundry/ml/autogen/client/docs/MlfoundryArtifactsApi.md#update_artifact_version_post) | **POST** /api/2.0/mlflow/mlfoundry-artifacts/artifact-versions/update | Update Artifact Version
|
|
133
134
|
*MlfoundryArtifactsApi* | [**update_dataset_post**](truefoundry/ml/autogen/client/docs/MlfoundryArtifactsApi.md#update_dataset_post) | **POST** /api/2.0/mlflow/mlfoundry-artifacts/datasets/update | Update Dataset
|
|
134
135
|
*MlfoundryArtifactsApi* | [**update_model_version_post**](truefoundry/ml/autogen/client/docs/MlfoundryArtifactsApi.md#update_model_version_post) | **POST** /api/2.0/mlflow/mlfoundry-artifacts/model-versions/update | Update Model Version
|
|
136
|
+
*MlfoundryArtifactsApi* | [**validate_external_storage_root_path_post**](truefoundry/ml/autogen/client/docs/MlfoundryArtifactsApi.md#validate_external_storage_root_path_post) | **POST** /api/2.0/mlflow/mlfoundry-artifacts/artifact-versions/validate-storage-root | Validate External Storage Root Path
|
|
135
137
|
*RunArtifactsApi* | [**list_run_artifacts_get**](truefoundry/ml/autogen/client/docs/RunArtifactsApi.md#list_run_artifacts_get) | **GET** /api/2.0/mlflow/artifacts/list | List Run Artifacts
|
|
136
138
|
*RunsApi* | [**create_run_post**](truefoundry/ml/autogen/client/docs/RunsApi.md#create_run_post) | **POST** /api/2.0/mlflow/runs/create | Create Run
|
|
137
139
|
*RunsApi* | [**delete_run_post**](truefoundry/ml/autogen/client/docs/RunsApi.md#delete_run_post) | **POST** /api/2.0/mlflow/runs/delete | Delete Run
|
|
@@ -211,6 +213,7 @@ Class | Method | HTTP request | Description
|
|
|
211
213
|
- [ExperimentIdRequestDto](truefoundry/ml/autogen/client/docs/ExperimentIdRequestDto.md)
|
|
212
214
|
- [ExperimentResponseDto](truefoundry/ml/autogen/client/docs/ExperimentResponseDto.md)
|
|
213
215
|
- [ExperimentTagDto](truefoundry/ml/autogen/client/docs/ExperimentTagDto.md)
|
|
216
|
+
- [ExportDeploymentFilesRequestDto](truefoundry/ml/autogen/client/docs/ExportDeploymentFilesRequestDto.md)
|
|
214
217
|
- [ExternalArtifactSource](truefoundry/ml/autogen/client/docs/ExternalArtifactSource.md)
|
|
215
218
|
- [FastAIFramework](truefoundry/ml/autogen/client/docs/FastAIFramework.md)
|
|
216
219
|
- [FileInfoDto](truefoundry/ml/autogen/client/docs/FileInfoDto.md)
|
|
@@ -233,6 +236,7 @@ Class | Method | HTTP request | Description
|
|
|
233
236
|
- [HTTPValidationError](truefoundry/ml/autogen/client/docs/HTTPValidationError.md)
|
|
234
237
|
- [ImageContentPart](truefoundry/ml/autogen/client/docs/ImageContentPart.md)
|
|
235
238
|
- [ImageUrl](truefoundry/ml/autogen/client/docs/ImageUrl.md)
|
|
239
|
+
- [InferMethodName](truefoundry/ml/autogen/client/docs/InferMethodName.md)
|
|
236
240
|
- [InternalMetadata](truefoundry/ml/autogen/client/docs/InternalMetadata.md)
|
|
237
241
|
- [KerasFramework](truefoundry/ml/autogen/client/docs/KerasFramework.md)
|
|
238
242
|
- [LatestRunLogDto](truefoundry/ml/autogen/client/docs/LatestRunLogDto.md)
|
|
@@ -270,7 +274,9 @@ Class | Method | HTTP request | Description
|
|
|
270
274
|
- [ModelConfiguration](truefoundry/ml/autogen/client/docs/ModelConfiguration.md)
|
|
271
275
|
- [ModelDto](truefoundry/ml/autogen/client/docs/ModelDto.md)
|
|
272
276
|
- [ModelResponseDto](truefoundry/ml/autogen/client/docs/ModelResponseDto.md)
|
|
277
|
+
- [ModelServer](truefoundry/ml/autogen/client/docs/ModelServer.md)
|
|
273
278
|
- [ModelVersionDto](truefoundry/ml/autogen/client/docs/ModelVersionDto.md)
|
|
279
|
+
- [ModelVersionEnvironment](truefoundry/ml/autogen/client/docs/ModelVersionEnvironment.md)
|
|
274
280
|
- [ModelVersionManifest](truefoundry/ml/autogen/client/docs/ModelVersionManifest.md)
|
|
275
281
|
- [ModelVersionResponseDto](truefoundry/ml/autogen/client/docs/ModelVersionResponseDto.md)
|
|
276
282
|
- [MultiPartUploadDto](truefoundry/ml/autogen/client/docs/MultiPartUploadDto.md)
|
|
@@ -298,6 +304,8 @@ Class | Method | HTTP request | Description
|
|
|
298
304
|
- [SetTagRequestDto](truefoundry/ml/autogen/client/docs/SetTagRequestDto.md)
|
|
299
305
|
- [SignedURLDto](truefoundry/ml/autogen/client/docs/SignedURLDto.md)
|
|
300
306
|
- [SklearnFramework](truefoundry/ml/autogen/client/docs/SklearnFramework.md)
|
|
307
|
+
- [SklearnModelSchema](truefoundry/ml/autogen/client/docs/SklearnModelSchema.md)
|
|
308
|
+
- [SklearnSerializationFormat](truefoundry/ml/autogen/client/docs/SklearnSerializationFormat.md)
|
|
301
309
|
- [Source](truefoundry/ml/autogen/client/docs/Source.md)
|
|
302
310
|
- [Source1](truefoundry/ml/autogen/client/docs/Source1.md)
|
|
303
311
|
- [SpaCyFramework](truefoundry/ml/autogen/client/docs/SpaCyFramework.md)
|
|
@@ -322,9 +330,13 @@ Class | Method | HTTP request | Description
|
|
|
322
330
|
- [UpdateRunResponseDto](truefoundry/ml/autogen/client/docs/UpdateRunResponseDto.md)
|
|
323
331
|
- [Url](truefoundry/ml/autogen/client/docs/Url.md)
|
|
324
332
|
- [UserMessage](truefoundry/ml/autogen/client/docs/UserMessage.md)
|
|
333
|
+
- [ValidateExternalStorageRootRequestDto](truefoundry/ml/autogen/client/docs/ValidateExternalStorageRootRequestDto.md)
|
|
334
|
+
- [ValidateExternalStorageRootResponseDto](truefoundry/ml/autogen/client/docs/ValidateExternalStorageRootResponseDto.md)
|
|
325
335
|
- [ValidationError](truefoundry/ml/autogen/client/docs/ValidationError.md)
|
|
326
336
|
- [ValidationErrorLocInner](truefoundry/ml/autogen/client/docs/ValidationErrorLocInner.md)
|
|
327
337
|
- [XGBoostFramework](truefoundry/ml/autogen/client/docs/XGBoostFramework.md)
|
|
338
|
+
- [XGBoostModelSchema](truefoundry/ml/autogen/client/docs/XGBoostModelSchema.md)
|
|
339
|
+
- [XGBoostSerializationFormat](truefoundry/ml/autogen/client/docs/XGBoostSerializationFormat.md)
|
|
328
340
|
|
|
329
341
|
|
|
330
342
|
<a id="documentation-for-authorization"></a>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# generated by datamodel-codegen:
|
|
2
2
|
# filename: artifacts.json
|
|
3
|
-
# timestamp: 2024-
|
|
3
|
+
# timestamp: 2024-12-09T09:04:12+00:00
|
|
4
4
|
|
|
5
5
|
from __future__ import annotations
|
|
6
6
|
|
|
@@ -52,11 +52,11 @@ class AgentWithFQN(Agent):
|
|
|
52
52
|
class BaseArtifactVersion(BaseModel):
|
|
53
53
|
description: Optional[constr(max_length=512)] = Field(
|
|
54
54
|
None,
|
|
55
|
-
description="+label=Description\n+docs=Description of the artifact version",
|
|
55
|
+
description="+label=Description\n+usage=Description of the artifact or model version\n+docs=Description of the artifact or model version",
|
|
56
56
|
)
|
|
57
57
|
metadata: Dict[str, Any] = Field(
|
|
58
58
|
...,
|
|
59
|
-
description="+label=Metadata\n+docs=Metadata for the model version\n+usage=Metadata for the model version\n+uiType=JsonInput",
|
|
59
|
+
description="+label=Metadata\n+docs=Metadata for the artifact or model version\n+usage=Metadata for the artifact or model version\n+uiType=JsonInput",
|
|
60
60
|
)
|
|
61
61
|
|
|
62
62
|
|
|
@@ -226,6 +226,23 @@ class ModelConfiguration(BaseModel):
|
|
|
226
226
|
)
|
|
227
227
|
|
|
228
228
|
|
|
229
|
+
class ModelVersionEnvironment(BaseModel):
|
|
230
|
+
"""
|
|
231
|
+
+label=Environment
|
|
232
|
+
"""
|
|
233
|
+
|
|
234
|
+
python_version: Optional[constr(regex=r"^\d+(\.\d+){1,2}([\-\.a-z0-9]+)?$")] = (
|
|
235
|
+
Field(
|
|
236
|
+
None,
|
|
237
|
+
description="+label=Python Version\n+usage=Python version for the model version",
|
|
238
|
+
)
|
|
239
|
+
)
|
|
240
|
+
pip_packages: Optional[List[str]] = Field(
|
|
241
|
+
None,
|
|
242
|
+
description="+label=PIP Packages\n+usage=PIP packages for the model version",
|
|
243
|
+
)
|
|
244
|
+
|
|
245
|
+
|
|
229
246
|
class ONNXFramework(BaseModel):
|
|
230
247
|
"""
|
|
231
248
|
+docs=ONNX framework for the model version
|
|
@@ -259,17 +276,44 @@ class PyTorchFramework(BaseModel):
|
|
|
259
276
|
)
|
|
260
277
|
|
|
261
278
|
|
|
262
|
-
class
|
|
279
|
+
class InferMethodName(str, Enum):
|
|
263
280
|
"""
|
|
264
|
-
+
|
|
265
|
-
+
|
|
281
|
+
+label=Inference Method Name
|
|
282
|
+
+usage=Name of the method used for inference
|
|
266
283
|
"""
|
|
267
284
|
|
|
268
|
-
|
|
269
|
-
|
|
285
|
+
predict = "predict"
|
|
286
|
+
predict_proba = "predict_proba"
|
|
287
|
+
|
|
288
|
+
|
|
289
|
+
class SklearnModelSchema(BaseModel):
|
|
290
|
+
"""
|
|
291
|
+
+label=Sklearn Model Schema
|
|
292
|
+
"""
|
|
293
|
+
|
|
294
|
+
infer_method_name: InferMethodName = Field(
|
|
295
|
+
...,
|
|
296
|
+
description="+label=Inference Method Name\n+usage=Name of the method used for inference",
|
|
297
|
+
)
|
|
298
|
+
inputs: List[Dict[str, Any]] = Field(
|
|
299
|
+
..., description="+label= Input Schema\n+usage=Schema of the input"
|
|
300
|
+
)
|
|
301
|
+
outputs: List[Dict[str, Any]] = Field(
|
|
302
|
+
..., description="+label= Output Schema\n+usage=Schema of the output"
|
|
270
303
|
)
|
|
271
304
|
|
|
272
305
|
|
|
306
|
+
class SklearnSerializationFormat(str, Enum):
|
|
307
|
+
"""
|
|
308
|
+
+label=Serialization format
|
|
309
|
+
+usage=Serialization format used for sklearn models
|
|
310
|
+
"""
|
|
311
|
+
|
|
312
|
+
cloudpickle = "cloudpickle"
|
|
313
|
+
joblib = "joblib"
|
|
314
|
+
pickle = "pickle"
|
|
315
|
+
|
|
316
|
+
|
|
273
317
|
class SpaCyFramework(BaseModel):
|
|
274
318
|
"""
|
|
275
319
|
+docs=spaCy framework for the model version
|
|
@@ -357,11 +401,11 @@ class TransformersFramework(BaseModel):
|
|
|
357
401
|
)
|
|
358
402
|
pipeline_tag: Optional[str] = Field(
|
|
359
403
|
None,
|
|
360
|
-
description="+label=Pipeline Tag\n+usage=
|
|
404
|
+
description="+label=Pipeline Tag\n+usage=The `pipeline()` task this model can be used with e.g. `text-generation`. See [huggingface docs](https://huggingface.co/docs/transformers/main/en/main_classes/pipelines#transformers.pipeline.task) for all possible values\n+docs=Pipeline tag for the framework",
|
|
361
405
|
)
|
|
362
406
|
base_model: Optional[str] = Field(
|
|
363
407
|
None,
|
|
364
|
-
description="+label=Base Model\n+usage=Base model\n+docs=Base model Id. If this is a finetuned model, this points to the base model used for finetuning",
|
|
408
|
+
description="+label=Base Model\n+usage=Base model Id. If this is a finetuned model, this points to the base model used for finetuning\n+docs=Base model Id. If this is a finetuned model, this points to the base model used for finetuning",
|
|
365
409
|
)
|
|
366
410
|
|
|
367
411
|
|
|
@@ -401,17 +445,35 @@ class UserMessage(BaseModel):
|
|
|
401
445
|
)
|
|
402
446
|
|
|
403
447
|
|
|
404
|
-
class
|
|
448
|
+
class XGBoostModelSchema(BaseModel):
|
|
405
449
|
"""
|
|
406
|
-
+
|
|
407
|
-
+label=XGBoost
|
|
450
|
+
+label=XGBoost Model Schema
|
|
408
451
|
"""
|
|
409
452
|
|
|
410
|
-
|
|
411
|
-
...,
|
|
453
|
+
infer_method_name: Literal["predict"] = Field(
|
|
454
|
+
...,
|
|
455
|
+
description="+label=Inference Method Name\n+usage=Name of the method used for inference",
|
|
456
|
+
)
|
|
457
|
+
inputs: List[Dict[str, Any]] = Field(
|
|
458
|
+
..., description="+label= Input Schema\n+usage=Schema of the input"
|
|
459
|
+
)
|
|
460
|
+
outputs: List[Dict[str, Any]] = Field(
|
|
461
|
+
..., description="+label= Output Schema\n+usage=Schema of the output"
|
|
412
462
|
)
|
|
413
463
|
|
|
414
464
|
|
|
465
|
+
class XGBoostSerializationFormat(str, Enum):
|
|
466
|
+
"""
|
|
467
|
+
+label=Serialization format
|
|
468
|
+
+usage=Serialization format used for XGBoost models
|
|
469
|
+
"""
|
|
470
|
+
|
|
471
|
+
cloudpickle = "cloudpickle"
|
|
472
|
+
joblib = "joblib"
|
|
473
|
+
pickle = "pickle"
|
|
474
|
+
json = "json"
|
|
475
|
+
|
|
476
|
+
|
|
415
477
|
class AgentOpenAPITool(BaseModel):
|
|
416
478
|
type: Literal["openapi-tool"] = Field(..., description="+value=openapi-tool")
|
|
417
479
|
name: constr(regex=r"^[a-zA-Z][a-zA-Z0-9\-]{1,30}[a-zA-Z0-9]$") = Field(
|
|
@@ -505,6 +567,47 @@ class ChatPrompt(BasePrompt):
|
|
|
505
567
|
)
|
|
506
568
|
|
|
507
569
|
|
|
570
|
+
class SklearnFramework(BaseModel):
|
|
571
|
+
"""
|
|
572
|
+
+docs=Scikit-learn framework for the model version
|
|
573
|
+
+label=Sklearn
|
|
574
|
+
"""
|
|
575
|
+
|
|
576
|
+
type: Literal["sklearn"] = Field(
|
|
577
|
+
..., description="+label=Type\n+usage=Type of the framework\n+value=sklearn"
|
|
578
|
+
)
|
|
579
|
+
model_filepath: Optional[str] = Field(
|
|
580
|
+
None,
|
|
581
|
+
description="+label=Model file path\n+usage=Relative path to the model file",
|
|
582
|
+
)
|
|
583
|
+
serialization_format: Optional[SklearnSerializationFormat] = None
|
|
584
|
+
model_schema: Optional[SklearnModelSchema] = None
|
|
585
|
+
|
|
586
|
+
|
|
587
|
+
class XGBoostFramework(BaseModel):
|
|
588
|
+
"""
|
|
589
|
+
+docs=XGBoost framework for the model version
|
|
590
|
+
+label=XGBoost
|
|
591
|
+
"""
|
|
592
|
+
|
|
593
|
+
type: Literal["xgboost"] = Field(
|
|
594
|
+
..., description="+label=Type\n+usage=Type of the framework\n+value=xgboost"
|
|
595
|
+
)
|
|
596
|
+
serialization_format: Optional[XGBoostSerializationFormat] = None
|
|
597
|
+
model_filepath: Optional[str] = Field(
|
|
598
|
+
None,
|
|
599
|
+
description="+label=Model file path\n+usage=Relative path to the model file",
|
|
600
|
+
)
|
|
601
|
+
model_schema: Optional[XGBoostModelSchema] = None
|
|
602
|
+
|
|
603
|
+
|
|
604
|
+
class AgentApp(BaseModel):
|
|
605
|
+
type: Literal["agent-app"] = Field(..., description="+value=agent-app")
|
|
606
|
+
tools: List[AgentOpenAPIToolWithFQN]
|
|
607
|
+
agents: List[AgentWithFQN]
|
|
608
|
+
root_agent: constr(min_length=1)
|
|
609
|
+
|
|
610
|
+
|
|
508
611
|
class ModelVersion(BaseArtifactVersion):
|
|
509
612
|
type: Literal["model-version"] = Field(
|
|
510
613
|
..., description='+label=Type\n+usage=Model Version\n+value="model-version"'
|
|
@@ -533,18 +636,8 @@ class ModelVersion(BaseArtifactVersion):
|
|
|
533
636
|
] = Field(
|
|
534
637
|
None, description="+label=Framework\n+usage=Framework for the model version"
|
|
535
638
|
)
|
|
639
|
+
environment: Optional[ModelVersionEnvironment] = None
|
|
536
640
|
step: conint(ge=0) = Field(0, description="+label=Step")
|
|
537
|
-
model_schema: Optional[Dict[str, Any]] = Field(
|
|
538
|
-
None,
|
|
539
|
-
description="+label=Model Schema\n+usage=Schema of the model\n+uiType=Hidden",
|
|
540
|
-
)
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
class AgentApp(BaseModel):
|
|
544
|
-
type: Literal["agent-app"] = Field(..., description="+value=agent-app")
|
|
545
|
-
tools: List[AgentOpenAPIToolWithFQN]
|
|
546
|
-
agents: List[AgentWithFQN]
|
|
547
|
-
root_agent: constr(min_length=1)
|
|
548
641
|
|
|
549
642
|
|
|
550
643
|
class VersionedArtifactType(BaseModel):
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
from dataclasses import dataclass, is_dataclass
|
|
2
|
-
from typing import Any, Dict, Optional, Union
|
|
2
|
+
from typing import TYPE_CHECKING, Any, Dict, Optional, Union
|
|
3
3
|
|
|
4
4
|
import numpy as np
|
|
5
|
-
|
|
5
|
+
|
|
6
|
+
if TYPE_CHECKING:
|
|
7
|
+
import pandas as pd
|
|
8
|
+
|
|
6
9
|
|
|
7
10
|
from .schema import ParamSchema, Schema, convert_dataclass_to_schema
|
|
8
11
|
from .utils import infer_param_schema, infer_schema
|
|
9
12
|
|
|
10
|
-
MlflowInferableDataset = Union[pd.DataFrame, np.ndarray, Dict[str, np.ndarray]]
|
|
13
|
+
MlflowInferableDataset = Union["pd.DataFrame", "np.ndarray", Dict[str, "np.ndarray"]]
|
|
11
14
|
|
|
12
15
|
|
|
13
16
|
class ModelSignature:
|
|
@@ -4,7 +4,12 @@ from collections import defaultdict
|
|
|
4
4
|
from typing import Any, Dict, List, Optional, Union
|
|
5
5
|
|
|
6
6
|
import numpy as np
|
|
7
|
-
|
|
7
|
+
|
|
8
|
+
try:
|
|
9
|
+
import pandas as pd
|
|
10
|
+
except ImportError:
|
|
11
|
+
pd = None
|
|
12
|
+
|
|
8
13
|
|
|
9
14
|
from .exceptions import MlflowException
|
|
10
15
|
from .schema import (
|
|
@@ -330,7 +335,7 @@ def infer_schema(data: Any) -> Schema: # noqa: C901
|
|
|
330
335
|
]
|
|
331
336
|
)
|
|
332
337
|
# pandas.Series
|
|
333
|
-
elif isinstance(data, pd.Series):
|
|
338
|
+
elif pd and isinstance(data, pd.Series):
|
|
334
339
|
name = getattr(data, "name", None)
|
|
335
340
|
schema = Schema(
|
|
336
341
|
[
|
|
@@ -342,7 +347,7 @@ def infer_schema(data: Any) -> Schema: # noqa: C901
|
|
|
342
347
|
]
|
|
343
348
|
)
|
|
344
349
|
# pandas.DataFrame
|
|
345
|
-
elif isinstance(data, pd.DataFrame):
|
|
350
|
+
elif pd and isinstance(data, pd.DataFrame):
|
|
346
351
|
schema = Schema(
|
|
347
352
|
[
|
|
348
353
|
ColSpec(
|
|
@@ -473,13 +478,13 @@ def _is_none_or_nan(x):
|
|
|
473
478
|
|
|
474
479
|
|
|
475
480
|
def _infer_required(col) -> bool:
|
|
476
|
-
if isinstance(col, (list, pd.Series)):
|
|
481
|
+
if pd and isinstance(col, (list, pd.Series)):
|
|
477
482
|
return not any(_is_none_or_nan(x) for x in col)
|
|
478
483
|
return not _is_none_or_nan(col)
|
|
479
484
|
|
|
480
485
|
|
|
481
|
-
def _infer_pandas_column(col: pd.Series) -> DataType:
|
|
482
|
-
if not isinstance(col, pd.Series):
|
|
486
|
+
def _infer_pandas_column(col: "pd.Series") -> DataType:
|
|
487
|
+
if pd and not isinstance(col, pd.Series):
|
|
483
488
|
raise TypeError(f"Expected pandas.Series, got '{type(col)}'.")
|
|
484
489
|
if len(col.values.shape) > 1:
|
|
485
490
|
raise MlflowException(f"Expected 1d array, got array with shape {col.shape}")
|
|
@@ -496,7 +501,7 @@ def _infer_pandas_column(col: pd.Series) -> DataType:
|
|
|
496
501
|
# For backwards compatibility, we fall back to string
|
|
497
502
|
# if the provided array is of string type
|
|
498
503
|
# This is for diviner test where df field is ('key2', 'key1', 'key0')
|
|
499
|
-
if pd.api.types.is_string_dtype(col):
|
|
504
|
+
if pd and pd.api.types.is_string_dtype(col):
|
|
500
505
|
return DataType.string
|
|
501
506
|
raise MlflowException(
|
|
502
507
|
f"Failed to infer schema for pandas.Series {col}. Error: {e}"
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import os
|
|
2
|
+
from typing import Optional
|
|
3
|
+
|
|
4
|
+
import rich_click as click
|
|
5
|
+
|
|
6
|
+
from truefoundry.deploy.cli.console import console
|
|
7
|
+
from truefoundry.deploy.cli.const import COMMAND_CLS
|
|
8
|
+
from truefoundry.deploy.cli.util import handle_exception_wrapper
|
|
9
|
+
from truefoundry.ml.autogen.client.models import ModelServer
|
|
10
|
+
from truefoundry.ml.cli.utils import (
|
|
11
|
+
AppName,
|
|
12
|
+
NonEmptyString,
|
|
13
|
+
)
|
|
14
|
+
from truefoundry.ml.mlfoundry_api import get_client
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
@click.command(
|
|
18
|
+
name="model",
|
|
19
|
+
cls=COMMAND_CLS,
|
|
20
|
+
help="Generating application code for the specified model version.",
|
|
21
|
+
)
|
|
22
|
+
@click.option(
|
|
23
|
+
"--name",
|
|
24
|
+
required=True,
|
|
25
|
+
type=AppName(),
|
|
26
|
+
help="Name for the model server deployment",
|
|
27
|
+
show_default=True,
|
|
28
|
+
)
|
|
29
|
+
@click.option(
|
|
30
|
+
"--model-version-fqn",
|
|
31
|
+
"--model_version_fqn",
|
|
32
|
+
type=NonEmptyString(),
|
|
33
|
+
required=True,
|
|
34
|
+
show_default=True,
|
|
35
|
+
help="Fully Qualified Name (FQN) of the model version to deploy, e.g., 'model:tenant_name/my-model/linear-regression:2'",
|
|
36
|
+
)
|
|
37
|
+
@click.option(
|
|
38
|
+
"-w",
|
|
39
|
+
"--workspace-fqn",
|
|
40
|
+
"--workspace_fqn",
|
|
41
|
+
type=NonEmptyString(),
|
|
42
|
+
required=True,
|
|
43
|
+
show_default=True,
|
|
44
|
+
help="Fully Qualified Name (FQN) of the workspace to deploy",
|
|
45
|
+
)
|
|
46
|
+
@click.option(
|
|
47
|
+
"--model-server",
|
|
48
|
+
"--model_server",
|
|
49
|
+
type=click.Choice(ModelServer, case_sensitive=False),
|
|
50
|
+
default=ModelServer.FASTAPI.value,
|
|
51
|
+
show_default=True,
|
|
52
|
+
help="Specify the model server (Case Insensitive).",
|
|
53
|
+
)
|
|
54
|
+
@click.option(
|
|
55
|
+
"--output-dir",
|
|
56
|
+
"--output_dir",
|
|
57
|
+
type=click.Path(exists=True, file_okay=False, writable=True),
|
|
58
|
+
help="Output directory for the model server code",
|
|
59
|
+
required=False,
|
|
60
|
+
show_default=True,
|
|
61
|
+
default=os.getcwd(),
|
|
62
|
+
)
|
|
63
|
+
@handle_exception_wrapper
|
|
64
|
+
def model_init_command(
|
|
65
|
+
name: str,
|
|
66
|
+
model_version_fqn: str,
|
|
67
|
+
workspace_fqn: str,
|
|
68
|
+
model_server: ModelServer,
|
|
69
|
+
output_dir: Optional[str],
|
|
70
|
+
):
|
|
71
|
+
"""
|
|
72
|
+
Generates application code for the specified model version.
|
|
73
|
+
"""
|
|
74
|
+
ml_client = get_client()
|
|
75
|
+
console.print(f"Generating application code for {model_version_fqn!r}")
|
|
76
|
+
output_dir = ml_client._initialize_model_server(
|
|
77
|
+
name=name,
|
|
78
|
+
model_version_fqn=model_version_fqn,
|
|
79
|
+
workspace_fqn=workspace_fqn,
|
|
80
|
+
model_server=ModelServer[model_server.upper()],
|
|
81
|
+
output_dir=output_dir,
|
|
82
|
+
)
|
|
83
|
+
message = f"""
|
|
84
|
+
[bold green]Model Server code initialized successfully![/bold green]
|
|
85
|
+
|
|
86
|
+
[bold]Code Location:[/bold] {output_dir}
|
|
87
|
+
|
|
88
|
+
[bold]Next Steps:[/bold]
|
|
89
|
+
- Navigate to the model server directory:
|
|
90
|
+
[green]cd {output_dir}[/green]
|
|
91
|
+
- Refer to the README file in the directory for further instructions.
|
|
92
|
+
"""
|
|
93
|
+
console.print(message)
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
def get_model_init_command():
|
|
97
|
+
return model_init_command
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import rich_click as click
|
|
2
|
+
|
|
3
|
+
from truefoundry.ml import MlFoundryException
|
|
4
|
+
from truefoundry.ml.validation_utils import (
|
|
5
|
+
_APP_NAME_REGEX,
|
|
6
|
+
)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class AppName(click.ParamType):
|
|
10
|
+
"""
|
|
11
|
+
Custom ParamType to validate application names.
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
name = "application-name"
|
|
15
|
+
|
|
16
|
+
def convert(self, value, param, ctx):
|
|
17
|
+
try:
|
|
18
|
+
if not value or not _APP_NAME_REGEX.match(value):
|
|
19
|
+
raise MlFoundryException(
|
|
20
|
+
f"{value!r} must be lowercase and cannot contain spaces. It can only contain alphanumeric characters and hyphens. "
|
|
21
|
+
f"Length must be between 1 and 30 characters."
|
|
22
|
+
)
|
|
23
|
+
except MlFoundryException as e:
|
|
24
|
+
self.fail(str(e), param, ctx)
|
|
25
|
+
return value
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
class NonEmptyString(click.ParamType):
|
|
29
|
+
name = "non-empty-string"
|
|
30
|
+
|
|
31
|
+
def convert(self, value, param, ctx):
|
|
32
|
+
if isinstance(value, str) and not value.strip():
|
|
33
|
+
self.fail("Value cannot be empty or contain only spaces.", param, ctx)
|
|
34
|
+
return value
|