truefoundry 0.5.9__py3-none-any.whl → 0.5.10rc2__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/cli/display_util.py +1 -1
- truefoundry/deploy/auto_gen/models.py +1 -1
- truefoundry/deploy/io/output_callback.py +13 -6
- truefoundry/deploy/io/rich_output_callback.py +8 -4
- truefoundry/deploy/lib/clients/servicefoundry_client.py +78 -105
- truefoundry/deploy/lib/dao/apply.py +2 -2
- truefoundry/deploy/lib/dao/delete.py +2 -2
- truefoundry/deploy/lib/model/entity.py +37 -24
- truefoundry/ml/autogen/client/__init__.py +22 -14
- truefoundry/ml/autogen/client/api/auth_api.py +2 -2
- truefoundry/ml/autogen/client/api/deprecated_api.py +5 -338
- truefoundry/ml/autogen/client/api/experiments_api.py +77 -32
- truefoundry/ml/autogen/client/api/generate_code_snippet_api.py +2 -2
- truefoundry/ml/autogen/client/api/health_api.py +2 -2
- truefoundry/ml/autogen/client/api/metrics_api.py +4 -4
- truefoundry/ml/autogen/client/api/mlfoundry_artifacts_api.py +530 -140
- truefoundry/ml/autogen/client/api/run_artifacts_api.py +10 -5
- truefoundry/ml/autogen/client/api/runs_api.py +20 -20
- truefoundry/ml/autogen/client/api_client.py +2 -2
- truefoundry/ml/autogen/client/configuration.py +29 -57
- truefoundry/ml/autogen/client/exceptions.py +2 -2
- truefoundry/ml/autogen/client/models/__init__.py +22 -14
- truefoundry/ml/autogen/client/models/agent_app.py +13 -5
- truefoundry/ml/autogen/client/models/{agent.py → agent_manifest.py} +39 -30
- truefoundry/ml/autogen/client/models/{agent_open_api_tool.py → agent_open_api_tool_manifest.py} +50 -31
- truefoundry/ml/autogen/client/models/agent_open_api_tool_with_fqn.py +47 -26
- truefoundry/ml/autogen/client/models/agent_with_fqn.py +36 -25
- truefoundry/ml/autogen/client/models/{add_custom_metrics_to_model_version_request_dto.py → apply_request_dto.py} +23 -17
- truefoundry/ml/autogen/client/models/apply_response_dto.py +79 -0
- truefoundry/ml/autogen/client/models/artifact_dto.py +2 -2
- truefoundry/ml/autogen/client/models/{add_features_to_model_version_request_dto.py → artifact_path.py} +20 -17
- truefoundry/ml/autogen/client/models/artifact_response_dto.py +2 -2
- truefoundry/ml/autogen/client/models/artifact_type.py +3 -3
- truefoundry/ml/autogen/client/models/artifact_version_dto.py +7 -15
- truefoundry/ml/autogen/client/models/artifact_version_manifest.py +32 -19
- truefoundry/ml/autogen/client/models/artifact_version_response_dto.py +2 -2
- truefoundry/ml/autogen/client/models/artifact_version_serialization_format.py +2 -2
- truefoundry/ml/autogen/client/models/artifact_version_status.py +2 -2
- truefoundry/ml/autogen/client/models/assistant_message.py +9 -5
- truefoundry/ml/autogen/client/models/authorize_user_for_model_request_dto.py +2 -2
- truefoundry/ml/autogen/client/models/authorize_user_for_model_version_request_dto.py +2 -2
- truefoundry/ml/autogen/client/models/blob_storage_reference.py +4 -4
- truefoundry/ml/autogen/client/models/body_get_search_runs_get.py +2 -2
- truefoundry/ml/autogen/client/models/{chat_prompt.py → chat_prompt_manifest.py} +39 -32
- truefoundry/ml/autogen/client/models/{chat_prompt_messages_inner.py → chat_prompt_manifest_messages_inner.py} +12 -12
- truefoundry/ml/autogen/client/models/columns_dto.py +2 -2
- truefoundry/ml/autogen/client/models/command.py +2 -2
- truefoundry/ml/autogen/client/models/content.py +3 -3
- truefoundry/ml/autogen/client/models/content1.py +3 -3
- truefoundry/ml/autogen/client/models/content2.py +3 -3
- truefoundry/ml/autogen/client/models/content2_any_of_inner.py +2 -2
- truefoundry/ml/autogen/client/models/create_artifact_request_dto.py +2 -2
- truefoundry/ml/autogen/client/models/create_artifact_response_dto.py +2 -2
- truefoundry/ml/autogen/client/models/create_artifact_version_request_dto.py +2 -2
- truefoundry/ml/autogen/client/models/create_artifact_version_response_dto.py +2 -2
- truefoundry/ml/autogen/client/models/create_dataset_request_dto.py +21 -5
- truefoundry/ml/autogen/client/models/create_experiment_request_dto.py +2 -2
- truefoundry/ml/autogen/client/models/create_experiment_response_dto.py +2 -2
- truefoundry/ml/autogen/client/models/create_model_version_request_dto.py +4 -12
- truefoundry/ml/autogen/client/models/create_multi_part_upload_for_dataset_request_dto.py +2 -2
- truefoundry/ml/autogen/client/models/create_multi_part_upload_for_dataset_response_dto.py +2 -2
- truefoundry/ml/autogen/client/models/create_multi_part_upload_request_dto.py +2 -2
- truefoundry/ml/autogen/client/models/create_python_deployment_config_request_dto.py +2 -2
- truefoundry/ml/autogen/client/models/create_python_deployment_config_response_dto.py +2 -2
- truefoundry/ml/autogen/client/models/create_run_request_dto.py +2 -2
- truefoundry/ml/autogen/client/models/create_run_response_dto.py +2 -2
- truefoundry/ml/autogen/client/models/create_workflow_task_config_request_dto.py +2 -2
- truefoundry/ml/autogen/client/models/data_directory_manifest.py +126 -0
- truefoundry/ml/autogen/client/models/dataset_dto.py +13 -2
- truefoundry/ml/autogen/client/models/dataset_response_dto.py +2 -2
- truefoundry/ml/autogen/client/models/delete_artifact_versions_request_dto.py +2 -2
- truefoundry/ml/autogen/client/models/delete_dataset_request_dto.py +2 -2
- truefoundry/ml/autogen/client/models/delete_files_for_dataset_request_dto.py +2 -2
- truefoundry/ml/autogen/client/models/delete_model_version_request_dto.py +2 -2
- truefoundry/ml/autogen/client/models/delete_run_request.py +2 -2
- truefoundry/ml/autogen/client/models/delete_tag_request_dto.py +2 -2
- truefoundry/ml/autogen/client/models/experiment_dto.py +3 -3
- truefoundry/ml/autogen/client/models/experiment_id_request_dto.py +2 -2
- truefoundry/ml/autogen/client/models/experiment_response_dto.py +2 -2
- truefoundry/ml/autogen/client/models/experiment_tag_dto.py +2 -2
- truefoundry/ml/autogen/client/models/export_deployment_files_request_dto.py +2 -2
- truefoundry/ml/autogen/client/models/external_blob_storage_source.py +5 -4
- truefoundry/ml/autogen/client/models/fast_ai_framework.py +3 -3
- truefoundry/ml/autogen/client/models/file_info_dto.py +2 -2
- truefoundry/ml/autogen/client/models/finalize_artifact_version_request_dto.py +7 -15
- truefoundry/ml/autogen/client/models/framework.py +3 -3
- truefoundry/ml/autogen/client/models/get_artifact_version_aliases_response_dto.py +2 -2
- truefoundry/ml/autogen/client/models/get_experiment_response_dto.py +2 -2
- truefoundry/ml/autogen/client/models/get_latest_run_log_response_dto.py +2 -2
- truefoundry/ml/autogen/client/models/get_metric_history_response.py +2 -2
- truefoundry/ml/autogen/client/models/get_signed_url_for_dataset_write_request_dto.py +2 -2
- truefoundry/ml/autogen/client/models/get_signed_urls_for_artifact_version_read_request_dto.py +2 -2
- truefoundry/ml/autogen/client/models/get_signed_urls_for_artifact_version_read_response_dto.py +2 -2
- truefoundry/ml/autogen/client/models/get_signed_urls_for_artifact_version_write_request_dto.py +2 -2
- truefoundry/ml/autogen/client/models/get_signed_urls_for_artifact_version_write_response_dto.py +2 -2
- truefoundry/ml/autogen/client/models/get_signed_urls_for_dataset_read_request_dto.py +2 -2
- truefoundry/ml/autogen/client/models/get_signed_urls_for_dataset_read_response_dto.py +2 -2
- truefoundry/ml/autogen/client/models/get_signed_urls_for_dataset_write_response_dto.py +2 -2
- truefoundry/ml/autogen/client/models/get_tenant_id_response_dto.py +2 -2
- truefoundry/ml/autogen/client/models/gluon_framework.py +3 -3
- truefoundry/ml/autogen/client/models/h2_o_framework.py +3 -3
- truefoundry/ml/autogen/client/models/http_validation_error.py +2 -2
- truefoundry/ml/autogen/client/models/image_content_part.py +7 -5
- truefoundry/ml/autogen/client/models/image_url.py +3 -3
- truefoundry/ml/autogen/client/models/infer_method_name.py +2 -2
- truefoundry/ml/autogen/client/models/keras_framework.py +3 -3
- truefoundry/ml/autogen/client/models/latest_run_log_dto.py +2 -2
- truefoundry/ml/autogen/client/models/library_name.py +2 -2
- truefoundry/ml/autogen/client/models/light_gbm_framework.py +3 -3
- truefoundry/ml/autogen/client/models/list_artifact_versions_request_dto.py +2 -2
- truefoundry/ml/autogen/client/models/list_artifact_versions_response_dto.py +2 -2
- truefoundry/ml/autogen/client/models/list_artifacts_request_dto.py +2 -2
- truefoundry/ml/autogen/client/models/list_artifacts_response_dto.py +2 -2
- truefoundry/ml/autogen/client/models/list_colums_response_dto.py +2 -2
- truefoundry/ml/autogen/client/models/list_datasets_request_dto.py +2 -2
- truefoundry/ml/autogen/client/models/list_datasets_response_dto.py +2 -2
- truefoundry/ml/autogen/client/models/list_experiments_response_dto.py +2 -2
- truefoundry/ml/autogen/client/models/list_files_for_artifact_version_request_dto.py +2 -2
- truefoundry/ml/autogen/client/models/list_files_for_artifact_versions_response_dto.py +2 -2
- truefoundry/ml/autogen/client/models/list_files_for_dataset_request_dto.py +2 -2
- truefoundry/ml/autogen/client/models/list_files_for_dataset_response_dto.py +2 -2
- truefoundry/ml/autogen/client/models/list_latest_run_logs_response_dto.py +2 -2
- truefoundry/ml/autogen/client/models/list_metric_history_request_dto.py +2 -2
- truefoundry/ml/autogen/client/models/list_metric_history_response_dto.py +2 -2
- truefoundry/ml/autogen/client/models/list_model_version_response_dto.py +2 -2
- truefoundry/ml/autogen/client/models/list_model_versions_request_dto.py +2 -2
- truefoundry/ml/autogen/client/models/list_models_request_dto.py +2 -2
- truefoundry/ml/autogen/client/models/list_models_response_dto.py +2 -2
- truefoundry/ml/autogen/client/models/list_run_artifacts_response_dto.py +2 -2
- truefoundry/ml/autogen/client/models/list_run_logs_response_dto.py +2 -2
- truefoundry/ml/autogen/client/models/local_artifact_source.py +93 -0
- truefoundry/ml/autogen/client/models/local_model_source.py +80 -0
- truefoundry/ml/autogen/client/models/log_batch_request_dto.py +2 -2
- truefoundry/ml/autogen/client/models/log_metric_request_dto.py +2 -2
- truefoundry/ml/autogen/client/models/log_param_request_dto.py +2 -2
- truefoundry/ml/autogen/client/models/manifest.py +100 -23
- truefoundry/ml/autogen/client/models/manifest1.py +219 -0
- truefoundry/ml/autogen/client/models/manifest2.py +198 -0
- truefoundry/ml/autogen/client/models/method.py +3 -3
- truefoundry/ml/autogen/client/models/metric_collection_dto.py +2 -2
- truefoundry/ml/autogen/client/models/metric_dto.py +2 -2
- truefoundry/ml/autogen/client/models/mime_type.py +2 -2
- truefoundry/ml/autogen/client/models/model_configuration.py +7 -7
- truefoundry/ml/autogen/client/models/model_dto.py +2 -2
- truefoundry/ml/autogen/client/models/model_response_dto.py +2 -2
- truefoundry/ml/autogen/client/models/model_server.py +2 -2
- truefoundry/ml/autogen/client/models/model_version_dto.py +2 -2
- truefoundry/ml/autogen/client/models/model_version_environment.py +5 -5
- truefoundry/ml/autogen/client/models/model_version_manifest.py +35 -22
- truefoundry/ml/autogen/client/models/model_version_response_dto.py +2 -2
- truefoundry/ml/autogen/client/models/multi_part_upload_dto.py +2 -2
- truefoundry/ml/autogen/client/models/multi_part_upload_response_dto.py +2 -2
- truefoundry/ml/autogen/client/models/multi_part_upload_storage_provider.py +2 -2
- truefoundry/ml/autogen/client/models/notify_artifact_version_failure_dto.py +2 -2
- truefoundry/ml/autogen/client/models/onnx_framework.py +3 -3
- truefoundry/ml/autogen/client/models/openapi_spec.py +3 -3
- truefoundry/ml/autogen/client/models/paddle_framework.py +3 -3
- truefoundry/ml/autogen/client/models/param_dto.py +2 -2
- truefoundry/ml/autogen/client/models/parameters.py +3 -3
- truefoundry/ml/autogen/client/models/py_torch_framework.py +3 -3
- truefoundry/ml/autogen/client/models/resolve_agent_app_response_dto.py +2 -2
- truefoundry/ml/autogen/client/models/restore_run_request_dto.py +2 -2
- truefoundry/ml/autogen/client/models/run_data_dto.py +2 -2
- truefoundry/ml/autogen/client/models/run_dto.py +2 -2
- truefoundry/ml/autogen/client/models/run_info_dto.py +2 -2
- truefoundry/ml/autogen/client/models/run_log_dto.py +2 -2
- truefoundry/ml/autogen/client/models/run_log_input_dto.py +2 -2
- truefoundry/ml/autogen/client/models/run_response_dto.py +2 -2
- truefoundry/ml/autogen/client/models/run_tag_dto.py +2 -2
- truefoundry/ml/autogen/client/models/search_runs_request_dto.py +2 -2
- truefoundry/ml/autogen/client/models/search_runs_response_dto.py +2 -2
- truefoundry/ml/autogen/client/models/set_experiment_tag_request_dto.py +2 -2
- truefoundry/ml/autogen/client/models/set_tag_request_dto.py +2 -2
- truefoundry/ml/autogen/client/models/signed_url_dto.py +2 -2
- truefoundry/ml/autogen/client/models/sklearn_framework.py +4 -4
- truefoundry/ml/autogen/client/models/sklearn_model_schema.py +7 -5
- truefoundry/ml/autogen/client/models/sklearn_serialization_format.py +3 -3
- truefoundry/ml/autogen/client/models/source.py +32 -7
- truefoundry/ml/autogen/client/models/source1.py +3 -3
- truefoundry/ml/autogen/client/models/{internal_metadata.py → source2.py} +52 -55
- truefoundry/ml/autogen/client/models/spa_cy_framework.py +3 -3
- truefoundry/ml/autogen/client/models/stats_models_framework.py +3 -3
- truefoundry/ml/autogen/client/models/stop.py +2 -2
- truefoundry/ml/autogen/client/models/store_run_logs_request_dto.py +2 -2
- truefoundry/ml/autogen/client/models/subject.py +2 -2
- truefoundry/ml/autogen/client/models/subject_type.py +2 -2
- truefoundry/ml/autogen/client/models/system_message.py +7 -4
- truefoundry/ml/autogen/client/models/tensor_flow_framework.py +3 -3
- truefoundry/ml/autogen/client/models/text.py +3 -3
- truefoundry/ml/autogen/client/models/text_content_part.py +6 -4
- truefoundry/ml/autogen/client/models/transformers_framework.py +5 -5
- truefoundry/ml/autogen/client/models/trigger_job_run_config_request_dto.py +2 -2
- truefoundry/ml/autogen/client/models/trigger_job_run_config_response_dto.py +2 -2
- truefoundry/ml/autogen/client/models/true_foundry_managed_source.py +3 -3
- truefoundry/ml/autogen/client/models/update_artifact_version_request_dto.py +5 -7
- truefoundry/ml/autogen/client/models/update_dataset_request_dto.py +13 -3
- truefoundry/ml/autogen/client/models/update_experiment_request_dto.py +2 -2
- truefoundry/ml/autogen/client/models/update_model_version_request_dto.py +2 -2
- truefoundry/ml/autogen/client/models/update_run_request_dto.py +2 -2
- truefoundry/ml/autogen/client/models/update_run_response_dto.py +2 -2
- truefoundry/ml/autogen/client/models/url.py +3 -3
- truefoundry/ml/autogen/client/models/user_message.py +8 -5
- truefoundry/ml/autogen/client/models/validate_external_storage_root_request_dto.py +2 -2
- truefoundry/ml/autogen/client/models/validate_external_storage_root_response_dto.py +2 -2
- truefoundry/ml/autogen/client/models/validation_error.py +2 -2
- truefoundry/ml/autogen/client/models/validation_error_loc_inner.py +2 -2
- truefoundry/ml/autogen/client/models/xg_boost_framework.py +4 -4
- truefoundry/ml/autogen/client/models/xg_boost_model_schema.py +7 -5
- truefoundry/ml/autogen/client/models/xg_boost_serialization_format.py +3 -3
- truefoundry/ml/autogen/client/rest.py +2 -2
- truefoundry/ml/autogen/client_README.md +17 -19
- truefoundry/ml/autogen/entities/artifacts.py +264 -139
- truefoundry/ml/clients/servicefoundry_client.py +5 -8
- truefoundry/ml/log_types/artifacts/artifact.py +15 -78
- truefoundry/ml/log_types/artifacts/model.py +4 -5
- truefoundry/ml/log_types/artifacts/utils.py +18 -2
- truefoundry/ml/mlfoundry_api.py +0 -40
- {truefoundry-0.5.9.dist-info → truefoundry-0.5.10rc2.dist-info}/METADATA +3 -6
- {truefoundry-0.5.9.dist-info → truefoundry-0.5.10rc2.dist-info}/RECORD +221 -215
- {truefoundry-0.5.9.dist-info → truefoundry-0.5.10rc2.dist-info}/WHEEL +0 -0
- {truefoundry-0.5.9.dist-info → truefoundry-0.5.10rc2.dist-info}/entry_points.txt +0 -0
|
@@ -39,8 +39,8 @@ class ServiceFoundryServiceClient(BaseServiceFoundryServiceClient):
|
|
|
39
39
|
)
|
|
40
40
|
|
|
41
41
|
try:
|
|
42
|
-
|
|
43
|
-
assert isinstance(
|
|
42
|
+
result = request_handling(response)
|
|
43
|
+
assert isinstance(result, dict)
|
|
44
44
|
except HttpRequestException as he:
|
|
45
45
|
raise MlFoundryException(
|
|
46
46
|
f"Failed to get storage integration from id: {integration_id}. Error: {he.message}",
|
|
@@ -51,13 +51,10 @@ class ServiceFoundryServiceClient(BaseServiceFoundryServiceClient):
|
|
|
51
51
|
f"Failed to get storage integration from id: {integration_id}. Error: {str(e)}"
|
|
52
52
|
) from None
|
|
53
53
|
|
|
54
|
+
data = result.get("data", result.get("providerAccounts"))
|
|
54
55
|
# TODO (chiragjn): Parse this using Pydantic
|
|
55
|
-
if (
|
|
56
|
-
data
|
|
57
|
-
and len(data["providerIntegrations"]) > 0
|
|
58
|
-
and data["providerIntegrations"][0]
|
|
59
|
-
):
|
|
60
|
-
return data["providerIntegrations"][0]
|
|
56
|
+
if data and len(data) > 0 and data[0]:
|
|
57
|
+
return data[0]
|
|
61
58
|
else:
|
|
62
59
|
raise MlFoundryException(
|
|
63
60
|
f"Invalid storage integration id: {integration_id}"
|
|
@@ -3,11 +3,10 @@ import datetime
|
|
|
3
3
|
import json
|
|
4
4
|
import os
|
|
5
5
|
import tempfile
|
|
6
|
-
import typing
|
|
7
6
|
import uuid
|
|
8
7
|
import warnings
|
|
9
8
|
from pathlib import Path
|
|
10
|
-
from typing import TYPE_CHECKING, Any, Dict,
|
|
9
|
+
from typing import TYPE_CHECKING, Any, Dict, NamedTuple, Optional, Union
|
|
11
10
|
|
|
12
11
|
from truefoundry.common.warnings import TrueFoundryDeprecationWarning
|
|
13
12
|
from truefoundry.ml.artifact.truefoundry_artifact_repo import (
|
|
@@ -24,16 +23,11 @@ from truefoundry.ml.autogen.client import ( # type: ignore[attr-defined]
|
|
|
24
23
|
ExperimentsApi,
|
|
25
24
|
ExternalBlobStorageSource,
|
|
26
25
|
FinalizeArtifactVersionRequestDto,
|
|
27
|
-
Manifest,
|
|
28
26
|
MlfoundryArtifactsApi,
|
|
29
27
|
NotifyArtifactVersionFailureDto,
|
|
30
28
|
TrueFoundryManagedSource,
|
|
31
29
|
UpdateArtifactVersionRequestDto,
|
|
32
30
|
)
|
|
33
|
-
from truefoundry.ml.autogen.client import ( # type: ignore[attr-defined]
|
|
34
|
-
InternalMetadata as InternalMetadataDto,
|
|
35
|
-
)
|
|
36
|
-
from truefoundry.ml.autogen.entities.artifacts import ChatPrompt
|
|
37
31
|
from truefoundry.ml.exceptions import MlFoundryException
|
|
38
32
|
from truefoundry.ml.log_types.artifacts.constants import INTERNAL_METADATA_PATH
|
|
39
33
|
from truefoundry.ml.log_types.artifacts.utils import (
|
|
@@ -41,6 +35,7 @@ from truefoundry.ml.log_types.artifacts.utils import (
|
|
|
41
35
|
_validate_artifact_metadata,
|
|
42
36
|
_validate_description,
|
|
43
37
|
calculate_total_size,
|
|
38
|
+
get_autogen_type,
|
|
44
39
|
)
|
|
45
40
|
from truefoundry.ml.logger import logger
|
|
46
41
|
from truefoundry.ml.session import _get_api_client
|
|
@@ -404,13 +399,18 @@ class ArtifactVersion:
|
|
|
404
399
|
else:
|
|
405
400
|
manifest = None
|
|
406
401
|
try:
|
|
402
|
+
_manifest_cls = get_autogen_type(
|
|
403
|
+
UpdateArtifactVersionRequestDto, "manifest"
|
|
404
|
+
)
|
|
407
405
|
_artifact_version = (
|
|
408
406
|
self._mlfoundry_artifacts_api.update_artifact_version_post(
|
|
409
407
|
update_artifact_version_request_dto=UpdateArtifactVersionRequestDto(
|
|
410
408
|
id=self._artifact_version.id,
|
|
411
409
|
description=self.description,
|
|
412
410
|
artifact_metadata=self.metadata,
|
|
413
|
-
manifest=manifest
|
|
411
|
+
manifest=_manifest_cls.from_dict(manifest.to_dict())
|
|
412
|
+
if manifest
|
|
413
|
+
else None,
|
|
414
414
|
)
|
|
415
415
|
)
|
|
416
416
|
)
|
|
@@ -423,66 +423,6 @@ class ArtifactVersion:
|
|
|
423
423
|
self._set_mutable_attrs()
|
|
424
424
|
|
|
425
425
|
|
|
426
|
-
class ChatPromptVersion(ArtifactVersion):
|
|
427
|
-
def __init__(self, artifact_version: ArtifactVersionDto, artifact: ArtifactDto):
|
|
428
|
-
if artifact.type != ArtifactType.CHAT_PROMPT:
|
|
429
|
-
raise ValueError(
|
|
430
|
-
f"{artifact_version.fqn!r} is not a chat prompt type artifact"
|
|
431
|
-
)
|
|
432
|
-
super().__init__(
|
|
433
|
-
artifact_version=artifact_version,
|
|
434
|
-
artifact=artifact,
|
|
435
|
-
)
|
|
436
|
-
self._chat_prompt = ChatPrompt.parse_obj(
|
|
437
|
-
artifact_version.internal_metadata.to_dict()
|
|
438
|
-
)
|
|
439
|
-
|
|
440
|
-
@classmethod
|
|
441
|
-
def from_fqn(cls, fqn: str) -> "ChatPromptVersion":
|
|
442
|
-
api_client = _get_api_client()
|
|
443
|
-
mlfoundry_artifacts_api = MlfoundryArtifactsApi(api_client=api_client)
|
|
444
|
-
_artifact_version = mlfoundry_artifacts_api.get_artifact_version_by_fqn_get(
|
|
445
|
-
fqn=fqn
|
|
446
|
-
)
|
|
447
|
-
artifact_version = _artifact_version.artifact_version
|
|
448
|
-
_artifact = mlfoundry_artifacts_api.get_artifact_by_id_get(
|
|
449
|
-
id=artifact_version.artifact_id
|
|
450
|
-
)
|
|
451
|
-
return cls(
|
|
452
|
-
artifact_version=_artifact_version.artifact_version,
|
|
453
|
-
artifact=_artifact.artifact,
|
|
454
|
-
)
|
|
455
|
-
|
|
456
|
-
@property
|
|
457
|
-
def model(self) -> str:
|
|
458
|
-
return self._chat_prompt.model_configuration.model
|
|
459
|
-
|
|
460
|
-
@property
|
|
461
|
-
def provider(self) -> str:
|
|
462
|
-
return self._chat_prompt.model_configuration.provider
|
|
463
|
-
|
|
464
|
-
@property
|
|
465
|
-
def messages(self) -> List[Dict[str, Any]]:
|
|
466
|
-
return [message.dict() for message in self._chat_prompt.messages]
|
|
467
|
-
|
|
468
|
-
@property
|
|
469
|
-
def parameters(self) -> Dict[str, Any]:
|
|
470
|
-
_parameters = self._chat_prompt.model_configuration.parameters
|
|
471
|
-
return _parameters.dict(exclude_unset=True) if _parameters else {}
|
|
472
|
-
|
|
473
|
-
@property
|
|
474
|
-
def extra_parameters(self) -> Dict[str, Any]:
|
|
475
|
-
_extra_parameters = self._chat_prompt.model_configuration.extra_parameters
|
|
476
|
-
return _extra_parameters if _extra_parameters else {}
|
|
477
|
-
|
|
478
|
-
@property
|
|
479
|
-
def variables(self) -> Dict[str, Any]:
|
|
480
|
-
return self._chat_prompt.variables or {}
|
|
481
|
-
|
|
482
|
-
def update(self):
|
|
483
|
-
raise NotImplementedError("ChatPromptVersion does not support update operation")
|
|
484
|
-
|
|
485
|
-
|
|
486
426
|
def _log_artifact_version_helper(
|
|
487
427
|
run: Optional["MlFoundryRun"],
|
|
488
428
|
name: str,
|
|
@@ -525,6 +465,7 @@ def _log_artifact_version_helper(
|
|
|
525
465
|
)
|
|
526
466
|
version_id = _create_artifact_response.id
|
|
527
467
|
artifact_storage_root = _create_artifact_response.artifact_storage_root
|
|
468
|
+
total_size = 0
|
|
528
469
|
if isinstance(artifact_dir, tempfile.TemporaryDirectory):
|
|
529
470
|
# Source is of type TrueFoundryManagedSource
|
|
530
471
|
source = TrueFoundryManagedSource(type="truefoundry", uri=artifact_storage_root)
|
|
@@ -556,13 +497,6 @@ def _log_artifact_version_helper(
|
|
|
556
497
|
raise MlFoundryException("Failed to log Artifact") from e
|
|
557
498
|
finally:
|
|
558
499
|
artifact_dir.cleanup()
|
|
559
|
-
|
|
560
|
-
# Note: Here we call from_dict instead of directly passing in init and relying on it
|
|
561
|
-
# to convert because the complicated union of types generates a custom type to handle casting
|
|
562
|
-
# Check the source of `InternalMetadataDto` to see the generated code
|
|
563
|
-
internal_metadata_dto = InternalMetadataDto.from_dict(
|
|
564
|
-
internal_metadata.dict() if internal_metadata is not None else {}
|
|
565
|
-
)
|
|
566
500
|
elif isinstance(artifact_dir, BlobStorageDirectory):
|
|
567
501
|
source = ExternalBlobStorageSource(type="external", uri=artifact_dir.uri)
|
|
568
502
|
else:
|
|
@@ -570,7 +504,7 @@ def _log_artifact_version_helper(
|
|
|
570
504
|
|
|
571
505
|
artifact_manifest = None
|
|
572
506
|
if artifact_type == ArtifactType.ARTIFACT:
|
|
573
|
-
_source_cls =
|
|
507
|
+
_source_cls = get_autogen_type(ArtifactVersionManifest, "source")
|
|
574
508
|
artifact_manifest = ArtifactVersionManifest(
|
|
575
509
|
name=name,
|
|
576
510
|
ml_repo=ml_repo,
|
|
@@ -579,15 +513,18 @@ def _log_artifact_version_helper(
|
|
|
579
513
|
source=_source_cls.from_dict(source.dict()),
|
|
580
514
|
step=step,
|
|
581
515
|
)
|
|
516
|
+
_manifest_cls = get_autogen_type(FinalizeArtifactVersionRequestDto, "manifest")
|
|
582
517
|
finalize_artifact_version_request_dto = FinalizeArtifactVersionRequestDto(
|
|
583
518
|
id=version_id,
|
|
584
519
|
run_uuid=run.run_id if run else None,
|
|
585
|
-
internal_metadata=
|
|
520
|
+
internal_metadata=internal_metadata.dict()
|
|
521
|
+
if internal_metadata is not None
|
|
522
|
+
else {},
|
|
586
523
|
artifact_metadata=metadata,
|
|
587
524
|
data_path=INTERNAL_METADATA_PATH if internal_metadata else None,
|
|
588
525
|
step=step,
|
|
589
526
|
artifact_size=total_size,
|
|
590
|
-
manifest=
|
|
527
|
+
manifest=_manifest_cls.from_dict(artifact_manifest.to_dict())
|
|
591
528
|
if artifact_manifest
|
|
592
529
|
else None,
|
|
593
530
|
)
|
|
@@ -4,7 +4,6 @@ import json
|
|
|
4
4
|
import logging
|
|
5
5
|
import os.path
|
|
6
6
|
import tempfile
|
|
7
|
-
import typing
|
|
8
7
|
import uuid
|
|
9
8
|
import warnings
|
|
10
9
|
from pathlib import Path
|
|
@@ -23,7 +22,6 @@ from truefoundry.ml.autogen.client import ( # type: ignore[attr-defined]
|
|
|
23
22
|
ExternalBlobStorageSource,
|
|
24
23
|
FinalizeArtifactVersionRequestDto,
|
|
25
24
|
Framework,
|
|
26
|
-
Manifest,
|
|
27
25
|
MlfoundryArtifactsApi,
|
|
28
26
|
ModelDto,
|
|
29
27
|
ModelVersionDto,
|
|
@@ -46,6 +44,7 @@ from truefoundry.ml.log_types.artifacts.utils import (
|
|
|
46
44
|
_validate_artifact_metadata,
|
|
47
45
|
_validate_description,
|
|
48
46
|
calculate_total_size,
|
|
47
|
+
get_autogen_type,
|
|
49
48
|
)
|
|
50
49
|
from truefoundry.ml.model_framework import (
|
|
51
50
|
ModelFrameworkType,
|
|
@@ -618,8 +617,7 @@ def _log_model_version( # noqa: C901
|
|
|
618
617
|
else:
|
|
619
618
|
raise MlFoundryException("Invalid model_file_or_folder provided")
|
|
620
619
|
|
|
621
|
-
_source_cls =
|
|
622
|
-
|
|
620
|
+
_source_cls = get_autogen_type(ModelVersionManifest, "source")
|
|
623
621
|
# Auto fetch the framework & environment details if not provided
|
|
624
622
|
framework = _ModelFramework.to_model_framework_type(framework)
|
|
625
623
|
if framework and isinstance(model_file_or_folder, str):
|
|
@@ -639,6 +637,7 @@ def _log_model_version( # noqa: C901
|
|
|
639
637
|
environment=environment,
|
|
640
638
|
step=step,
|
|
641
639
|
)
|
|
640
|
+
_manifest_cls = get_autogen_type(FinalizeArtifactVersionRequestDto, "manifest")
|
|
642
641
|
artifact_version_response = mlfoundry_artifacts_api.finalize_artifact_version_post(
|
|
643
642
|
finalize_artifact_version_request_dto=FinalizeArtifactVersionRequestDto(
|
|
644
643
|
id=version_id,
|
|
@@ -647,7 +646,7 @@ def _log_model_version( # noqa: C901
|
|
|
647
646
|
artifact_metadata=metadata,
|
|
648
647
|
internal_metadata=None,
|
|
649
648
|
step=model_manifest.step,
|
|
650
|
-
manifest=
|
|
649
|
+
manifest=_manifest_cls.from_dict(model_manifest.to_dict()),
|
|
651
650
|
)
|
|
652
651
|
)
|
|
653
652
|
return ModelVersion.from_fqn(fqn=artifact_version_response.artifact_version.fqn)
|
|
@@ -2,11 +2,13 @@ import json
|
|
|
2
2
|
import logging
|
|
3
3
|
import os
|
|
4
4
|
import posixpath
|
|
5
|
+
import typing
|
|
5
6
|
from pathlib import Path, PureWindowsPath
|
|
6
|
-
from typing import Any, Dict, List, Optional, Sequence, Tuple, Union
|
|
7
|
+
from typing import Any, Dict, List, Optional, Sequence, Tuple, Type, Union
|
|
7
8
|
|
|
8
9
|
from truefoundry.ml.exceptions import MlFoundryException
|
|
9
10
|
from truefoundry.ml.log_types.artifacts.constants import DESCRIPTION_MAX_LENGTH
|
|
11
|
+
from truefoundry.pydantic_v1 import BaseModel
|
|
10
12
|
|
|
11
13
|
logger = logging.getLogger(__name__)
|
|
12
14
|
|
|
@@ -206,9 +208,23 @@ def calculate_total_size(
|
|
|
206
208
|
Tells about the size of the artifact
|
|
207
209
|
|
|
208
210
|
Args:
|
|
209
|
-
|
|
211
|
+
paths (str): list of paths to include in total size calculation
|
|
210
212
|
|
|
211
213
|
Returns:
|
|
212
214
|
total size of the artifact
|
|
213
215
|
"""
|
|
214
216
|
return sum(os.stat(os.path.realpath(file_path)).st_size for file_path in paths)
|
|
217
|
+
|
|
218
|
+
|
|
219
|
+
def get_autogen_type(parent_type: Type[BaseModel], field_name: str) -> Type[BaseModel]:
|
|
220
|
+
type_ = typing.get_type_hints(parent_type)[field_name]
|
|
221
|
+
origin = typing.get_origin(type_)
|
|
222
|
+
|
|
223
|
+
if origin is None:
|
|
224
|
+
return type_
|
|
225
|
+
elif origin is typing.Union:
|
|
226
|
+
args = typing.get_args(type_)
|
|
227
|
+
if len(args) == 2 and args[-1] is type(None):
|
|
228
|
+
return args[0]
|
|
229
|
+
|
|
230
|
+
raise NotImplementedError(f"Cannot extract main type from {type_}")
|
truefoundry/ml/mlfoundry_api.py
CHANGED
|
@@ -52,7 +52,6 @@ from truefoundry.ml.log_types.artifacts.artifact import (
|
|
|
52
52
|
ArtifactPath,
|
|
53
53
|
ArtifactVersion,
|
|
54
54
|
BlobStorageDirectory,
|
|
55
|
-
ChatPromptVersion,
|
|
56
55
|
)
|
|
57
56
|
from truefoundry.ml.log_types.artifacts.dataset import DataDirectory
|
|
58
57
|
from truefoundry.ml.log_types.artifacts.general_artifact import _log_artifact_version
|
|
@@ -1556,45 +1555,6 @@ class MlFoundry:
|
|
|
1556
1555
|
if not datasets or not page_token:
|
|
1557
1556
|
done = True
|
|
1558
1557
|
|
|
1559
|
-
def get_chat_prompt_version_by_fqn(self, fqn: str) -> ChatPromptVersion:
|
|
1560
|
-
"""
|
|
1561
|
-
Get the prompt by prompt version FQN
|
|
1562
|
-
Args:
|
|
1563
|
-
fqn (str): Fully qualified name of the chat prompt version.
|
|
1564
|
-
Returns:
|
|
1565
|
-
ChatPromptVersion: An instance of the ChatPromptVersion class with the fetched prompt details.
|
|
1566
|
-
|
|
1567
|
-
Examples:
|
|
1568
|
-
```python
|
|
1569
|
-
from truefoundry.ml import get_client
|
|
1570
|
-
client = get_client()
|
|
1571
|
-
|
|
1572
|
-
# Get the chat prompt by FQN
|
|
1573
|
-
fqn = 'chat_prompt:truefoundry/prompt-demo/demo-prompt-1:2'
|
|
1574
|
-
chat_prompt = client.get_chat_prompt_version_by_fqn(fqn=fqn)
|
|
1575
|
-
|
|
1576
|
-
# Check the chat prompt values
|
|
1577
|
-
print(chat_prompt)
|
|
1578
|
-
|
|
1579
|
-
# Use with OpenAI client
|
|
1580
|
-
from openai import OpenAI
|
|
1581
|
-
openai_client = OpenAI(api_key="api_key")
|
|
1582
|
-
|
|
1583
|
-
# Make the OpenAI call
|
|
1584
|
-
response = openai_client.chat.completions.create(
|
|
1585
|
-
model=chat_prompt.model,
|
|
1586
|
-
messages=chat_prompt.messages,
|
|
1587
|
-
**chat_prompt.parameters,
|
|
1588
|
-
**chat_prompt.extra_parameters
|
|
1589
|
-
)
|
|
1590
|
-
|
|
1591
|
-
# Extract the content from the response
|
|
1592
|
-
response_content = response.choices[0].message.content
|
|
1593
|
-
print(response_content)
|
|
1594
|
-
```
|
|
1595
|
-
"""
|
|
1596
|
-
return ChatPromptVersion.from_fqn(fqn=fqn)
|
|
1597
|
-
|
|
1598
1558
|
|
|
1599
1559
|
def get_client() -> MlFoundry:
|
|
1600
1560
|
"""Initializes and returns the mlfoundry client.
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: truefoundry
|
|
3
|
-
Version: 0.5.
|
|
3
|
+
Version: 0.5.10rc2
|
|
4
4
|
Summary: TrueFoundry CLI
|
|
5
5
|
Author-email: TrueFoundry Team <abhishek@truefoundry.com>
|
|
6
|
-
Requires-Python: <3.
|
|
6
|
+
Requires-Python: <3.14,>=3.8.1
|
|
7
7
|
Requires-Dist: aenum<4.0.0,>=3.0.0
|
|
8
8
|
Requires-Dist: click<9.0.0,>=7.0.0
|
|
9
9
|
Requires-Dist: coolname<2.0.0,>=1.1.0
|
|
@@ -14,8 +14,7 @@ Requires-Dist: gitpython<4.0.0,>=3.1.43
|
|
|
14
14
|
Requires-Dist: importlib-metadata<9.0.0,>=4.11.3
|
|
15
15
|
Requires-Dist: importlib-resources<7.0.0,>=5.2.0
|
|
16
16
|
Requires-Dist: mako<2.0.0,>=1.1.6
|
|
17
|
-
Requires-Dist: numpy<
|
|
18
|
-
Requires-Dist: numpy<2.0.0,>=1.26.0; python_version >= '3.12'
|
|
17
|
+
Requires-Dist: numpy<3.0.0,>=1.23.0
|
|
19
18
|
Requires-Dist: openai<2.0.0,>=1.16.2
|
|
20
19
|
Requires-Dist: packaging<25.0,>=20.0
|
|
21
20
|
Requires-Dist: pydantic<3.0.0,>=1.8.2
|
|
@@ -30,8 +29,6 @@ Requires-Dist: requests<3.0.0,>=2.18.0
|
|
|
30
29
|
Requires-Dist: requirements-parser<0.12.0,>=0.11.0
|
|
31
30
|
Requires-Dist: rich-click<2.0.0,>=1.2.1
|
|
32
31
|
Requires-Dist: rich<14.0.0,>=13.7.1
|
|
33
|
-
Requires-Dist: scipy<2.0.0,>=1.12.0; python_version >= '3.12'
|
|
34
|
-
Requires-Dist: scipy<2.0.0,>=1.5.0; python_version < '3.12'
|
|
35
32
|
Requires-Dist: tqdm<5.0.0,>=4.0.0
|
|
36
33
|
Requires-Dist: typing-extensions>=4.0
|
|
37
34
|
Requires-Dist: urllib3<3,>=1.26.18
|