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
truefoundry/cli/display_util.py
CHANGED
|
@@ -1,23 +1,30 @@
|
|
|
1
|
+
from typing import Any, List, Optional
|
|
2
|
+
|
|
3
|
+
|
|
1
4
|
class OutputCallBack:
|
|
2
|
-
def print_header(self, line):
|
|
5
|
+
def print_header(self, line: Any) -> None:
|
|
3
6
|
print(line)
|
|
4
7
|
|
|
5
|
-
def _print_separator(self):
|
|
8
|
+
def _print_separator(self) -> None:
|
|
6
9
|
print("-" * 80)
|
|
7
10
|
|
|
8
|
-
def print_line(self, line):
|
|
11
|
+
def print_line(self, line: str) -> None:
|
|
9
12
|
print(line)
|
|
10
13
|
|
|
11
|
-
def print_lines_in_panel(
|
|
14
|
+
def print_lines_in_panel(
|
|
15
|
+
self, lines: List[str], header: Optional[str] = None
|
|
16
|
+
) -> None:
|
|
12
17
|
self.print_header(header)
|
|
13
18
|
self._print_separator()
|
|
14
19
|
for line in lines:
|
|
15
20
|
self.print_line(line)
|
|
16
21
|
self._print_separator()
|
|
17
22
|
|
|
18
|
-
def print_code_in_panel(
|
|
23
|
+
def print_code_in_panel(
|
|
24
|
+
self, lines: List[str], header: Optional[str] = None
|
|
25
|
+
) -> None:
|
|
19
26
|
self.print_lines_in_panel(lines, header)
|
|
20
27
|
|
|
21
|
-
def print(self, line):
|
|
28
|
+
def print(self, line: Any) -> None:
|
|
22
29
|
# just an alias
|
|
23
30
|
self.print_line(line)
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
from typing import Any, List, Optional
|
|
2
|
+
|
|
1
3
|
from rich.console import Console
|
|
2
4
|
from rich.highlighter import ReprHighlighter
|
|
3
5
|
from rich.panel import Panel
|
|
@@ -14,14 +16,16 @@ class RichOutputCallBack(OutputCallBack):
|
|
|
14
16
|
console = Console(soft_wrap=True)
|
|
15
17
|
highlighter = ReprHighlighter()
|
|
16
18
|
|
|
17
|
-
def print_header(self, line):
|
|
19
|
+
def print_header(self, line: Any) -> None:
|
|
18
20
|
self.console.rule(_text(line), style="cyan")
|
|
19
21
|
|
|
20
|
-
def print_line(self, line):
|
|
22
|
+
def print_line(self, line: Any) -> None:
|
|
21
23
|
self.console.print(_text(line))
|
|
22
24
|
|
|
23
|
-
def print_lines_in_panel(
|
|
25
|
+
def print_lines_in_panel(
|
|
26
|
+
self, lines: List[str], header: Optional[str] = None
|
|
27
|
+
) -> None:
|
|
24
28
|
self.console.print(Panel(self.highlighter("\n".join(lines)), title=header))
|
|
25
29
|
|
|
26
|
-
def print_code_in_panel(self, lines, header=None
|
|
30
|
+
def print_code_in_panel(self, lines: List[str], header: Optional[str] = None):
|
|
27
31
|
self.print_lines_in_panel(lines, header)
|
|
@@ -4,7 +4,7 @@ import json
|
|
|
4
4
|
import os
|
|
5
5
|
import time
|
|
6
6
|
from datetime import datetime, timezone
|
|
7
|
-
from typing import Any, Dict, List, Optional
|
|
7
|
+
from typing import Any, Dict, List, Optional, cast
|
|
8
8
|
from urllib.parse import urljoin
|
|
9
9
|
|
|
10
10
|
import requests
|
|
@@ -32,6 +32,8 @@ from truefoundry.deploy.lib.model.entity import (
|
|
|
32
32
|
Deployment,
|
|
33
33
|
DockerRegistryCredentials,
|
|
34
34
|
JobRun,
|
|
35
|
+
LogBody,
|
|
36
|
+
SocketEvent,
|
|
35
37
|
TriggerJobResult,
|
|
36
38
|
Workspace,
|
|
37
39
|
WorkspaceResources,
|
|
@@ -51,7 +53,7 @@ BUILD_LOGS_SUBSCRIBE_MESSAGE = "BUILD_LOGS"
|
|
|
51
53
|
MAX_RETRIES_WORKFLOW_TRIGGER = 3
|
|
52
54
|
|
|
53
55
|
|
|
54
|
-
def _upload_packaged_code(metadata, package_file):
|
|
56
|
+
def _upload_packaged_code(metadata: Dict[str, Any], package_file: str) -> None:
|
|
55
57
|
file_size = os.stat(package_file).st_size
|
|
56
58
|
with open(package_file, "rb") as file_to_upload:
|
|
57
59
|
with tqdm(
|
|
@@ -74,7 +76,9 @@ def _upload_packaged_code(metadata, package_file):
|
|
|
74
76
|
|
|
75
77
|
|
|
76
78
|
class ServiceFoundryServiceClient(BaseServiceFoundryServiceClient):
|
|
77
|
-
def __init__(
|
|
79
|
+
def __init__(
|
|
80
|
+
self, init_session: bool = True, tfy_host: Optional[str] = None
|
|
81
|
+
) -> None:
|
|
78
82
|
self._session: Optional[Session] = None
|
|
79
83
|
if init_session:
|
|
80
84
|
if tfy_host:
|
|
@@ -85,25 +89,19 @@ class ServiceFoundryServiceClient(BaseServiceFoundryServiceClient):
|
|
|
85
89
|
raise Exception("Neither session, not tfy_host provided")
|
|
86
90
|
super().__init__(tfy_host=tfy_host)
|
|
87
91
|
|
|
88
|
-
def _get_header(self):
|
|
92
|
+
def _get_header(self) -> Dict[str, str]:
|
|
89
93
|
if not self._session:
|
|
90
94
|
return {}
|
|
91
95
|
return {"Authorization": f"Bearer {self._session.access_token}"}
|
|
92
96
|
|
|
93
97
|
@check_min_cli_version
|
|
94
|
-
def get_id_from_fqn(self, fqn_type: str, fqn: str):
|
|
98
|
+
def get_id_from_fqn(self, fqn_type: str, fqn: str) -> Dict[str, Any]:
|
|
95
99
|
url = f"{self._api_server_url}/{VERSION_PREFIX}/fqn/{fqn_type}"
|
|
96
100
|
response = session_with_retries().get(
|
|
97
101
|
url, headers=self._get_header(), params={"fqn": fqn}
|
|
98
102
|
)
|
|
99
103
|
return request_handling(response)
|
|
100
104
|
|
|
101
|
-
@check_min_cli_version
|
|
102
|
-
def list_workspace(self):
|
|
103
|
-
url = f"{self._api_server_url}/{VERSION_PREFIX}/workspace"
|
|
104
|
-
response = session_with_retries().get(url, headers=self._get_header())
|
|
105
|
-
return request_handling(response)
|
|
106
|
-
|
|
107
105
|
@check_min_cli_version
|
|
108
106
|
def list_workspaces(
|
|
109
107
|
self,
|
|
@@ -148,33 +146,17 @@ class ServiceFoundryServiceClient(BaseServiceFoundryServiceClient):
|
|
|
148
146
|
return Workspace.parse_obj(response_data)
|
|
149
147
|
|
|
150
148
|
@check_min_cli_version
|
|
151
|
-
def remove_workspace(self, workspace_id, force=False) -> Workspace:
|
|
149
|
+
def remove_workspace(self, workspace_id: str, force: bool = False) -> Workspace:
|
|
152
150
|
url = f"{self._api_server_url}/{VERSION_PREFIX}/workspace/{workspace_id}"
|
|
153
|
-
|
|
151
|
+
force_str = json.dumps(
|
|
154
152
|
force
|
|
155
153
|
) # this dumb conversion is required because `params` just casts as str
|
|
156
154
|
response = session_with_retries().delete(
|
|
157
|
-
url, headers=self._get_header(), params={"force":
|
|
155
|
+
url, headers=self._get_header(), params={"force": force_str}
|
|
158
156
|
)
|
|
159
|
-
response = request_handling(response)
|
|
157
|
+
response = cast(Dict[str, Any], request_handling(response))
|
|
160
158
|
return Workspace.parse_obj(response["workspace"])
|
|
161
159
|
|
|
162
|
-
@check_min_cli_version
|
|
163
|
-
def get_workspace_by_name(self, workspace_name, cluster_id):
|
|
164
|
-
url = f"{self._api_server_url}/{VERSION_PREFIX}/workspace"
|
|
165
|
-
response = session_with_retries().get(
|
|
166
|
-
url,
|
|
167
|
-
headers=self._get_header(),
|
|
168
|
-
params={"name": workspace_name, "clusterId": cluster_id},
|
|
169
|
-
)
|
|
170
|
-
return request_handling(response)
|
|
171
|
-
|
|
172
|
-
@check_min_cli_version
|
|
173
|
-
def get_workspace(self, workspace_id):
|
|
174
|
-
url = f"{self._api_server_url}/{VERSION_PREFIX}/workspace/{workspace_id}"
|
|
175
|
-
response = session_with_retries().get(url, headers=self._get_header())
|
|
176
|
-
return request_handling(response)
|
|
177
|
-
|
|
178
160
|
@check_min_cli_version
|
|
179
161
|
def get_workspace_by_fqn(self, workspace_fqn: str) -> List[Workspace]:
|
|
180
162
|
url = f"{self._api_server_url}/{VERSION_PREFIX}/workspace"
|
|
@@ -187,30 +169,15 @@ class ServiceFoundryServiceClient(BaseServiceFoundryServiceClient):
|
|
|
187
169
|
return parse_obj_as(List[Workspace], response)
|
|
188
170
|
|
|
189
171
|
@check_min_cli_version
|
|
190
|
-
def
|
|
191
|
-
url = f"{self._api_server_url}/{VERSION_PREFIX}/deployment"
|
|
192
|
-
params = {}
|
|
193
|
-
if workspace_id:
|
|
194
|
-
params["workspaceId"] = workspace_id
|
|
195
|
-
response = session_with_retries().get(
|
|
196
|
-
url=url, params=params, headers=self._get_header()
|
|
197
|
-
)
|
|
198
|
-
return request_handling(response)
|
|
199
|
-
|
|
200
|
-
@check_min_cli_version
|
|
201
|
-
def list_cluster(self):
|
|
202
|
-
url = f"{self._api_server_url}/{VERSION_PREFIX}/cluster"
|
|
203
|
-
response = session_with_retries().get(url, headers=self._get_header())
|
|
204
|
-
return request_handling(response)
|
|
205
|
-
|
|
206
|
-
@check_min_cli_version
|
|
207
|
-
def get_cluster(self, cluster_id):
|
|
172
|
+
def get_cluster(self, cluster_id: str) -> Dict[str, Any]:
|
|
208
173
|
url = f"{self._api_server_url}/{VERSION_PREFIX}/cluster/{cluster_id}"
|
|
209
174
|
response = session_with_retries().get(url, headers=self._get_header())
|
|
210
|
-
return request_handling(response)
|
|
175
|
+
return cast(Dict[str, Any], request_handling(response))
|
|
211
176
|
|
|
212
177
|
@check_min_cli_version
|
|
213
|
-
def get_presigned_url(
|
|
178
|
+
def get_presigned_url(
|
|
179
|
+
self, space_name: str, service_name: str, env: str
|
|
180
|
+
) -> Dict[str, Any]:
|
|
214
181
|
url = f"{self._api_server_url}/{VERSION_PREFIX}/deployment/code-upload-url"
|
|
215
182
|
response = session_with_retries().post(
|
|
216
183
|
url,
|
|
@@ -221,7 +188,7 @@ class ServiceFoundryServiceClient(BaseServiceFoundryServiceClient):
|
|
|
221
188
|
},
|
|
222
189
|
headers=self._get_header(),
|
|
223
190
|
)
|
|
224
|
-
return request_handling(response)
|
|
191
|
+
return cast(Dict[str, Any], request_handling(response))
|
|
225
192
|
|
|
226
193
|
@check_min_cli_version
|
|
227
194
|
def upload_code_package(
|
|
@@ -231,7 +198,6 @@ class ServiceFoundryServiceClient(BaseServiceFoundryServiceClient):
|
|
|
231
198
|
space_name=workspace_fqn, service_name=component_name, env="default"
|
|
232
199
|
)
|
|
233
200
|
_upload_packaged_code(metadata=http_response, package_file=package_local_path)
|
|
234
|
-
|
|
235
201
|
return http_response["uri"]
|
|
236
202
|
|
|
237
203
|
@check_min_cli_version
|
|
@@ -252,28 +218,28 @@ class ServiceFoundryServiceClient(BaseServiceFoundryServiceClient):
|
|
|
252
218
|
response = session_with_retries().post(
|
|
253
219
|
url, json=data, headers=self._get_header()
|
|
254
220
|
)
|
|
255
|
-
response_data = request_handling(response)
|
|
221
|
+
response_data = cast(Dict[str, Any], request_handling(response))
|
|
256
222
|
return Deployment.parse_obj(response_data["deployment"])
|
|
257
223
|
|
|
258
|
-
def _get_log_print_line(self,
|
|
259
|
-
timestamp = int(
|
|
224
|
+
def _get_log_print_line(self, log_data: LogBody) -> str:
|
|
225
|
+
timestamp = int(log_data.time) / 1e6
|
|
260
226
|
|
|
261
227
|
time_obj = datetime.fromtimestamp(timestamp / 1000.0, tz=timezone.utc)
|
|
262
228
|
time_obj.replace(tzinfo=timezone.utc)
|
|
263
229
|
local_time = time_obj.astimezone(tzlocal())
|
|
264
230
|
local_time_str = local_time.isoformat()
|
|
265
|
-
return f"[{local_time_str}] {log
|
|
231
|
+
return f"[{local_time_str}] {log_data.log.strip()}"
|
|
266
232
|
|
|
267
233
|
def _tail_logs(
|
|
268
234
|
self,
|
|
269
235
|
tail_logs_url: str,
|
|
270
|
-
query_dict:
|
|
236
|
+
query_dict: Dict[str, Any],
|
|
271
237
|
# NOTE: Rather making this printer callback an argument,
|
|
272
238
|
# we should have global printer callback
|
|
273
239
|
# which will be initialized based on the running env (cli, lib, notebook)
|
|
274
240
|
subscribe_message: str,
|
|
275
241
|
socketio_path: str = "socket.io",
|
|
276
|
-
callback=None,
|
|
242
|
+
callback: Optional[OutputCallBack] = None,
|
|
277
243
|
) -> socketio.Client:
|
|
278
244
|
callback = callback or OutputCallBack()
|
|
279
245
|
sio = socketio.Client(request_timeout=60)
|
|
@@ -281,18 +247,20 @@ class ServiceFoundryServiceClient(BaseServiceFoundryServiceClient):
|
|
|
281
247
|
next_log_start_timestamp = query_dict.get("startTs")
|
|
282
248
|
|
|
283
249
|
@sio.on(subscribe_message)
|
|
284
|
-
def logs(data):
|
|
250
|
+
def logs(data: Any) -> None:
|
|
285
251
|
try:
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
252
|
+
event = SocketEvent.parse_obj(json.loads(data))
|
|
253
|
+
if not isinstance(event.body, LogBody):
|
|
254
|
+
logger.debug(f"Skipped log for {data!r}")
|
|
255
|
+
return
|
|
256
|
+
callback.print_line(self._get_log_print_line(event.body))
|
|
289
257
|
nonlocal next_log_start_timestamp
|
|
290
|
-
next_log_start_timestamp = body
|
|
258
|
+
next_log_start_timestamp = event.body.time
|
|
291
259
|
except Exception:
|
|
292
|
-
logger.
|
|
260
|
+
logger.debug(f"Error while parsing log line, {data!r}")
|
|
293
261
|
|
|
294
262
|
@sio.on("connect")
|
|
295
|
-
def on_connect():
|
|
263
|
+
def on_connect() -> None:
|
|
296
264
|
# TODO: We should have have a timeout here. `emit` does
|
|
297
265
|
# not support timeout. Explore `sio.call`.
|
|
298
266
|
query_dict["startTs"] = next_log_start_timestamp
|
|
@@ -301,7 +269,7 @@ class ServiceFoundryServiceClient(BaseServiceFoundryServiceClient):
|
|
|
301
269
|
json.dumps(query_dict),
|
|
302
270
|
)
|
|
303
271
|
|
|
304
|
-
def sio_disconnect_no_exception():
|
|
272
|
+
def sio_disconnect_no_exception() -> None:
|
|
305
273
|
try:
|
|
306
274
|
sio.disconnect()
|
|
307
275
|
except Exception:
|
|
@@ -351,11 +319,11 @@ class ServiceFoundryServiceClient(BaseServiceFoundryServiceClient):
|
|
|
351
319
|
end_ts_nano: Optional[int] = None,
|
|
352
320
|
limit: Optional[int] = None,
|
|
353
321
|
num_logs_to_ignore: Optional[int] = None,
|
|
354
|
-
) -> List:
|
|
322
|
+
) -> List[LogBody]:
|
|
355
323
|
get_logs_query = {"applicationId": application_id}
|
|
356
324
|
if deployment_id:
|
|
357
325
|
get_logs_query["deploymentId"] = deployment_id
|
|
358
|
-
data = {"getLogsQuery": json.dumps(get_logs_query)}
|
|
326
|
+
data: Dict[str, Any] = {"getLogsQuery": json.dumps(get_logs_query)}
|
|
359
327
|
if start_ts_nano:
|
|
360
328
|
data["startTs"] = str(start_ts_nano)
|
|
361
329
|
if end_ts_nano:
|
|
@@ -371,14 +339,14 @@ class ServiceFoundryServiceClient(BaseServiceFoundryServiceClient):
|
|
|
371
339
|
response = session_with_retries().get(
|
|
372
340
|
url=url, params=data, headers=self._get_header()
|
|
373
341
|
)
|
|
374
|
-
response_data = request_handling(response)
|
|
375
|
-
return
|
|
342
|
+
response_data = cast(Dict[str, Any], request_handling(response))
|
|
343
|
+
return parse_obj_as(List[LogBody], response_data["data"])
|
|
376
344
|
|
|
377
345
|
@check_min_cli_version
|
|
378
346
|
def tail_build_logs(
|
|
379
347
|
self,
|
|
380
348
|
build_response: BuildResponse,
|
|
381
|
-
callback=None,
|
|
349
|
+
callback: Optional[OutputCallBack] = None,
|
|
382
350
|
) -> socketio.Client:
|
|
383
351
|
callback = callback or OutputCallBack()
|
|
384
352
|
tail_logs_obj = json.loads(build_response.tailLogsUrl)
|
|
@@ -404,9 +372,9 @@ class ServiceFoundryServiceClient(BaseServiceFoundryServiceClient):
|
|
|
404
372
|
deployment_id: str,
|
|
405
373
|
start_ts: int,
|
|
406
374
|
limit: int,
|
|
407
|
-
callback=None,
|
|
375
|
+
callback: Optional[OutputCallBack] = None,
|
|
408
376
|
wait: bool = True,
|
|
409
|
-
):
|
|
377
|
+
) -> None:
|
|
410
378
|
callback = callback or OutputCallBack()
|
|
411
379
|
self._tail_logs(
|
|
412
380
|
tail_logs_url=urljoin(
|
|
@@ -435,8 +403,8 @@ class ServiceFoundryServiceClient(BaseServiceFoundryServiceClient):
|
|
|
435
403
|
start_ts: int,
|
|
436
404
|
limit: int,
|
|
437
405
|
poll_interval_seconds: int,
|
|
438
|
-
callback=None,
|
|
439
|
-
):
|
|
406
|
+
callback: Optional[OutputCallBack] = None,
|
|
407
|
+
) -> None:
|
|
440
408
|
callback = callback or OutputCallBack()
|
|
441
409
|
start_ts_nano = int(start_ts * 1e6)
|
|
442
410
|
|
|
@@ -444,7 +412,7 @@ class ServiceFoundryServiceClient(BaseServiceFoundryServiceClient):
|
|
|
444
412
|
num_logs_to_ignore = 0
|
|
445
413
|
|
|
446
414
|
while True:
|
|
447
|
-
|
|
415
|
+
logs = self._get_deployment_logs(
|
|
448
416
|
workspace_id=workspace_id,
|
|
449
417
|
application_id=application_id,
|
|
450
418
|
deployment_id=deployment_id,
|
|
@@ -454,18 +422,18 @@ class ServiceFoundryServiceClient(BaseServiceFoundryServiceClient):
|
|
|
454
422
|
num_logs_to_ignore=num_logs_to_ignore,
|
|
455
423
|
)
|
|
456
424
|
|
|
457
|
-
if
|
|
425
|
+
if not logs:
|
|
458
426
|
logger.warning("Did not receive any logs")
|
|
459
427
|
time.sleep(poll_interval_seconds)
|
|
460
428
|
continue
|
|
461
429
|
|
|
462
|
-
for log in
|
|
430
|
+
for log in logs:
|
|
463
431
|
callback.print_line(self._get_log_print_line(log))
|
|
464
432
|
|
|
465
|
-
last_log_time =
|
|
433
|
+
last_log_time = logs[-1].time
|
|
466
434
|
num_logs_to_ignore = 0
|
|
467
|
-
for log in reversed(
|
|
468
|
-
if log
|
|
435
|
+
for log in reversed(logs):
|
|
436
|
+
if log.time != last_log_time:
|
|
469
437
|
break
|
|
470
438
|
num_logs_to_ignore += 1
|
|
471
439
|
|
|
@@ -483,34 +451,37 @@ class ServiceFoundryServiceClient(BaseServiceFoundryServiceClient):
|
|
|
483
451
|
start_ts: Optional[int],
|
|
484
452
|
end_ts: Optional[int],
|
|
485
453
|
limit: Optional[int],
|
|
486
|
-
callback=None,
|
|
487
|
-
):
|
|
454
|
+
callback: Optional[OutputCallBack] = None,
|
|
455
|
+
) -> None:
|
|
488
456
|
callback = callback or OutputCallBack()
|
|
489
|
-
|
|
457
|
+
logs = self._get_deployment_logs(
|
|
490
458
|
workspace_id=workspace_id,
|
|
491
459
|
application_id=application_id,
|
|
492
460
|
deployment_id=deployment_id,
|
|
493
461
|
job_run_name=job_run_name,
|
|
494
|
-
start_ts_nano=int(start_ts * 1e6),
|
|
495
|
-
end_ts_nano=int(end_ts * 1e6),
|
|
462
|
+
start_ts_nano=int(start_ts * 1e6) if start_ts else None,
|
|
463
|
+
end_ts_nano=int(end_ts * 1e6) if end_ts else None,
|
|
496
464
|
limit=limit,
|
|
497
465
|
)
|
|
498
|
-
for log in
|
|
466
|
+
for log in logs:
|
|
499
467
|
callback.print_line(self._get_log_print_line(log))
|
|
500
468
|
|
|
501
469
|
@check_min_cli_version
|
|
502
470
|
def fetch_build_logs(
|
|
503
471
|
self,
|
|
504
472
|
build_response: BuildResponse,
|
|
505
|
-
callback=None,
|
|
473
|
+
callback: Optional[OutputCallBack] = None,
|
|
506
474
|
) -> None:
|
|
507
475
|
callback = callback or OutputCallBack()
|
|
508
476
|
url = build_response.getLogsUrl
|
|
509
477
|
response = session_with_retries().get(url=url, headers=self._get_header())
|
|
510
|
-
|
|
511
|
-
for
|
|
512
|
-
|
|
513
|
-
|
|
478
|
+
logs_response = cast(Dict[str, Any], request_handling(response))
|
|
479
|
+
for _log_body in logs_response["logs"]:
|
|
480
|
+
try:
|
|
481
|
+
log_body = LogBody.parse_obj(_log_body)
|
|
482
|
+
callback.print_line(self._get_log_print_line(log_body))
|
|
483
|
+
except Exception:
|
|
484
|
+
logger.debug(f"Failed to parse log body {_log_body}")
|
|
514
485
|
|
|
515
486
|
@check_min_cli_version
|
|
516
487
|
def get_deployment_info_by_fqn(self, deployment_fqn: str) -> DeploymentFqnResponse:
|
|
@@ -533,10 +504,10 @@ class ServiceFoundryServiceClient(BaseServiceFoundryServiceClient):
|
|
|
533
504
|
return ApplicationFqnResponse.parse_obj(response_data)
|
|
534
505
|
|
|
535
506
|
@check_min_cli_version
|
|
536
|
-
def remove_application(self, application_id: str):
|
|
507
|
+
def remove_application(self, application_id: str) -> Dict[str, Any]:
|
|
537
508
|
url = f"{self._api_server_url}/{VERSION_PREFIX}/app/{application_id}"
|
|
538
509
|
response = session_with_retries().delete(url, headers=self._get_header())
|
|
539
|
-
response = request_handling(response)
|
|
510
|
+
response = cast(Dict[str, Any], request_handling(response))
|
|
540
511
|
# TODO: Add pydantic here.
|
|
541
512
|
return response
|
|
542
513
|
|
|
@@ -565,14 +536,14 @@ class ServiceFoundryServiceClient(BaseServiceFoundryServiceClient):
|
|
|
565
536
|
response = session_with_retries().get(
|
|
566
537
|
url, headers=self._get_header(), params=params
|
|
567
538
|
)
|
|
568
|
-
response_data = request_handling(response)
|
|
539
|
+
response_data = cast(Dict[str, Any], request_handling(response))
|
|
569
540
|
return parse_obj_as(List[JobRun], response_data["data"])
|
|
570
541
|
|
|
571
542
|
def get_job_run(
|
|
572
543
|
self,
|
|
573
544
|
application_id: str,
|
|
574
545
|
job_run_name: str,
|
|
575
|
-
):
|
|
546
|
+
) -> JobRun:
|
|
576
547
|
url = f"{self._api_server_url}/{VERSION_PREFIX}/jobs/{application_id}/runs/{job_run_name}"
|
|
577
548
|
response = session_with_retries().get(url, headers=self._get_header())
|
|
578
549
|
response_data = request_handling(response)
|
|
@@ -599,13 +570,15 @@ class ServiceFoundryServiceClient(BaseServiceFoundryServiceClient):
|
|
|
599
570
|
response = request_handling(response)
|
|
600
571
|
return TriggerJobResult.parse_obj(response)
|
|
601
572
|
|
|
602
|
-
def trigger_workflow(
|
|
573
|
+
def trigger_workflow(
|
|
574
|
+
self, application_id: str, inputs: Dict[str, Any]
|
|
575
|
+
) -> Dict[str, Any]:
|
|
603
576
|
url = f"{self._api_server_url}/{VERSION_PREFIX}/workflow/{application_id}/executions"
|
|
604
577
|
body = {"inputs": inputs}
|
|
605
578
|
response = session_with_retries(retries=MAX_RETRIES_WORKFLOW_TRIGGER).post(
|
|
606
579
|
url, json=body, headers=self._get_header()
|
|
607
580
|
)
|
|
608
|
-
response = request_handling(response)
|
|
581
|
+
response = cast(Dict[str, Any], request_handling(response))
|
|
609
582
|
return response
|
|
610
583
|
|
|
611
584
|
@check_min_cli_version
|
|
@@ -684,30 +657,30 @@ class ServiceFoundryServiceClient(BaseServiceFoundryServiceClient):
|
|
|
684
657
|
return parse_obj_as(List[Deployment], response)
|
|
685
658
|
|
|
686
659
|
@check_min_cli_version
|
|
687
|
-
def apply(self, manifest: Dict[str, Any], dry_run: bool = False):
|
|
660
|
+
def apply(self, manifest: Dict[str, Any], dry_run: bool = False) -> Dict[str, Any]:
|
|
688
661
|
url = f"{self._api_server_url}/{VERSION_PREFIX}/apply"
|
|
689
662
|
body = {"manifest": manifest, "dryRun": dry_run}
|
|
690
663
|
response = session_with_retries().put(
|
|
691
664
|
url, headers=self._get_header(), json=body
|
|
692
665
|
)
|
|
693
|
-
response_data = request_handling(response)
|
|
666
|
+
response_data = cast(Dict[str, Any], request_handling(response))
|
|
694
667
|
return response_data
|
|
695
668
|
|
|
696
669
|
@check_min_cli_version
|
|
697
|
-
def delete(self, manifest: Dict[str, Any]):
|
|
670
|
+
def delete(self, manifest: Dict[str, Any]) -> Dict[str, Any]:
|
|
698
671
|
url = f"{self._api_server_url}/{VERSION_PREFIX}/delete"
|
|
699
672
|
body = {"manifest": manifest}
|
|
700
673
|
response = session_with_retries().post(
|
|
701
674
|
url, headers=self._get_header(), json=body
|
|
702
675
|
)
|
|
703
|
-
response_data = request_handling(response)
|
|
676
|
+
response_data = cast(Dict[str, Any], request_handling(response))
|
|
704
677
|
return response_data
|
|
705
678
|
|
|
706
679
|
def terminate_job_run(
|
|
707
680
|
self,
|
|
708
681
|
deployment_id: str,
|
|
709
682
|
job_run_name: str,
|
|
710
|
-
):
|
|
683
|
+
) -> Dict[str, Any]:
|
|
711
684
|
url = f"{self._api_server_url}/{VERSION_PREFIX}/jobs/terminate"
|
|
712
685
|
body = {
|
|
713
686
|
"deploymentId": deployment_id,
|
|
@@ -720,5 +693,5 @@ class ServiceFoundryServiceClient(BaseServiceFoundryServiceClient):
|
|
|
720
693
|
json=body,
|
|
721
694
|
headers=self._get_header(),
|
|
722
695
|
)
|
|
723
|
-
response_data = request_handling(response)
|
|
696
|
+
response_data = cast(Dict[str, Any], request_handling(response))
|
|
724
697
|
return response_data
|
|
@@ -6,7 +6,7 @@ import yaml
|
|
|
6
6
|
from truefoundry.deploy.lib.clients.servicefoundry_client import (
|
|
7
7
|
ServiceFoundryServiceClient,
|
|
8
8
|
)
|
|
9
|
-
from truefoundry.deploy.lib.model.entity import ApplyResult,
|
|
9
|
+
from truefoundry.deploy.lib.model.entity import ApplyResult, ManifestLike
|
|
10
10
|
from truefoundry.pydantic_v1 import ValidationError
|
|
11
11
|
|
|
12
12
|
|
|
@@ -26,7 +26,7 @@ def _apply_manifest(
|
|
|
26
26
|
file_metadata += f" from file {filename}"
|
|
27
27
|
|
|
28
28
|
try:
|
|
29
|
-
manifest =
|
|
29
|
+
manifest = ManifestLike.parse_obj(manifest)
|
|
30
30
|
except ValidationError as ex:
|
|
31
31
|
return ApplyResult(
|
|
32
32
|
success=False,
|
|
@@ -6,7 +6,7 @@ import yaml
|
|
|
6
6
|
from truefoundry.deploy.lib.clients.servicefoundry_client import (
|
|
7
7
|
ServiceFoundryServiceClient,
|
|
8
8
|
)
|
|
9
|
-
from truefoundry.deploy.lib.model.entity import DeleteResult,
|
|
9
|
+
from truefoundry.deploy.lib.model.entity import DeleteResult, ManifestLike
|
|
10
10
|
from truefoundry.pydantic_v1 import ValidationError
|
|
11
11
|
|
|
12
12
|
|
|
@@ -25,7 +25,7 @@ def _delete_manifest(
|
|
|
25
25
|
file_metadata += f" from file {filename}"
|
|
26
26
|
|
|
27
27
|
try:
|
|
28
|
-
manifest =
|
|
28
|
+
manifest = ManifestLike.parse_obj(manifest)
|
|
29
29
|
except ValidationError as ex:
|
|
30
30
|
return DeleteResult(
|
|
31
31
|
success=False,
|
|
@@ -71,25 +71,24 @@ class PortMetadata(BaseModel):
|
|
|
71
71
|
|
|
72
72
|
|
|
73
73
|
class DeploymentTransitionStatus(str, Enum):
|
|
74
|
-
INITIALIZED
|
|
75
|
-
BUILDING
|
|
76
|
-
DEPLOYING
|
|
77
|
-
BUILD_SUCCESS
|
|
78
|
-
DEPLOY_SUCCESS
|
|
79
|
-
DEPLOY_FAILED
|
|
80
|
-
BUILD_FAILED
|
|
81
|
-
CANCELLED
|
|
82
|
-
COMPONENTS_DEPLOYING
|
|
83
|
-
FAILED
|
|
84
|
-
REUSING_EXISTING_BUILD
|
|
85
|
-
REDEPLOY_STARTED
|
|
86
|
-
PAUSED
|
|
87
|
-
ROLLOUT_STARTED
|
|
88
|
-
SET_TRAFFIC
|
|
89
|
-
DEPLOY_FAILED_WITH_RETRY
|
|
90
|
-
WAITING
|
|
91
|
-
|
|
92
|
-
_: str = ""
|
|
74
|
+
INITIALIZED = "INITIALIZED"
|
|
75
|
+
BUILDING = "BUILDING"
|
|
76
|
+
DEPLOYING = "DEPLOYING"
|
|
77
|
+
BUILD_SUCCESS = "BUILD_SUCCESS"
|
|
78
|
+
DEPLOY_SUCCESS = "DEPLOY_SUCCESS"
|
|
79
|
+
DEPLOY_FAILED = "DEPLOY_FAILED"
|
|
80
|
+
BUILD_FAILED = "BUILD_FAILED"
|
|
81
|
+
CANCELLED = "CANCELLED"
|
|
82
|
+
COMPONENTS_DEPLOYING = "COMPONENTS_DEPLOYING"
|
|
83
|
+
FAILED = "FAILED"
|
|
84
|
+
REUSING_EXISTING_BUILD = "REUSING_EXISTING_BUILD"
|
|
85
|
+
REDEPLOY_STARTED = "REDEPLOY_STARTED"
|
|
86
|
+
PAUSED = "PAUSED"
|
|
87
|
+
ROLLOUT_STARTED = "ROLLOUT_STARTED"
|
|
88
|
+
SET_TRAFFIC = "SET_TRAFFIC"
|
|
89
|
+
DEPLOY_FAILED_WITH_RETRY = "DEPLOY_FAILED_WITH_RETRY"
|
|
90
|
+
WAITING = "WAITING"
|
|
91
|
+
_ = ""
|
|
93
92
|
|
|
94
93
|
@classmethod
|
|
95
94
|
def is_failure_state(cls, state: DeploymentTransitionStatus) -> bool:
|
|
@@ -112,6 +111,9 @@ class DeploymentManifest(Base):
|
|
|
112
111
|
|
|
113
112
|
|
|
114
113
|
class Deployment(Entity):
|
|
114
|
+
class Config:
|
|
115
|
+
extra = Extra.allow
|
|
116
|
+
|
|
115
117
|
id: str = Field(repr=False)
|
|
116
118
|
fqn: str
|
|
117
119
|
version: int
|
|
@@ -123,7 +125,8 @@ class Deployment(Entity):
|
|
|
123
125
|
metadata: Optional[
|
|
124
126
|
Union[Dict[str, Any], List[Dict[str, Any]]]
|
|
125
127
|
] # TODO (chiragjn): revisit the type of this field
|
|
126
|
-
|
|
128
|
+
# Server was not returning CurrentStatus
|
|
129
|
+
currentStatus: Optional[DeploymentStatus]
|
|
127
130
|
application_fqn: str
|
|
128
131
|
|
|
129
132
|
def __init__(self, **kwargs) -> None:
|
|
@@ -161,9 +164,6 @@ class Deployment(Entity):
|
|
|
161
164
|
"updated_at": self.updatedAt,
|
|
162
165
|
}
|
|
163
166
|
|
|
164
|
-
class Config:
|
|
165
|
-
extra = Extra.allow
|
|
166
|
-
|
|
167
167
|
|
|
168
168
|
class ApplicationWorkspace(Base):
|
|
169
169
|
name: str
|
|
@@ -285,6 +285,19 @@ class DeleteResult(BaseModel):
|
|
|
285
285
|
message: str
|
|
286
286
|
|
|
287
287
|
|
|
288
|
-
class
|
|
288
|
+
class ManifestLike(Base):
|
|
289
289
|
type: str
|
|
290
290
|
name: str
|
|
291
|
+
|
|
292
|
+
|
|
293
|
+
class LogBody(Base):
|
|
294
|
+
time: float
|
|
295
|
+
log: str
|
|
296
|
+
|
|
297
|
+
|
|
298
|
+
class SocketEvent(Base):
|
|
299
|
+
class Config:
|
|
300
|
+
smart_union = True
|
|
301
|
+
|
|
302
|
+
type: str
|
|
303
|
+
body: Union[LogBody, str, Any]
|