truefoundry 0.5.9__py3-none-any.whl → 0.5.10__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/common/utils.py +9 -0
- 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 +115 -136
- 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 +3 -4
- 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 +266 -141
- truefoundry/ml/clients/servicefoundry_client.py +9 -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/ml/session.py +6 -3
- {truefoundry-0.5.9.dist-info → truefoundry-0.5.10.dist-info}/METADATA +3 -6
- {truefoundry-0.5.9.dist-info → truefoundry-0.5.10.dist-info}/RECORD +223 -217
- {truefoundry-0.5.9.dist-info → truefoundry-0.5.10.dist-info}/WHEEL +0 -0
- {truefoundry-0.5.9.dist-info → truefoundry-0.5.10.dist-info}/entry_points.txt +0 -0
|
@@ -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
|
|
@@ -24,6 +24,7 @@ from truefoundry.common.servicefoundry_client import (
|
|
|
24
24
|
session_with_retries,
|
|
25
25
|
)
|
|
26
26
|
from truefoundry.common.session import Session
|
|
27
|
+
from truefoundry.common.utils import get_user_agent
|
|
27
28
|
from truefoundry.deploy.auto_gen import models as auto_gen_models
|
|
28
29
|
from truefoundry.deploy.io.output_callback import OutputCallBack
|
|
29
30
|
from truefoundry.deploy.lib.model.entity import (
|
|
@@ -32,6 +33,8 @@ from truefoundry.deploy.lib.model.entity import (
|
|
|
32
33
|
Deployment,
|
|
33
34
|
DockerRegistryCredentials,
|
|
34
35
|
JobRun,
|
|
36
|
+
LogBody,
|
|
37
|
+
SocketEvent,
|
|
35
38
|
TriggerJobResult,
|
|
36
39
|
Workspace,
|
|
37
40
|
WorkspaceResources,
|
|
@@ -51,7 +54,7 @@ BUILD_LOGS_SUBSCRIBE_MESSAGE = "BUILD_LOGS"
|
|
|
51
54
|
MAX_RETRIES_WORKFLOW_TRIGGER = 3
|
|
52
55
|
|
|
53
56
|
|
|
54
|
-
def _upload_packaged_code(metadata, package_file):
|
|
57
|
+
def _upload_packaged_code(metadata: Dict[str, Any], package_file: str) -> None:
|
|
55
58
|
file_size = os.stat(package_file).st_size
|
|
56
59
|
with open(package_file, "rb") as file_to_upload:
|
|
57
60
|
with tqdm(
|
|
@@ -74,7 +77,9 @@ def _upload_packaged_code(metadata, package_file):
|
|
|
74
77
|
|
|
75
78
|
|
|
76
79
|
class ServiceFoundryServiceClient(BaseServiceFoundryServiceClient):
|
|
77
|
-
def __init__(
|
|
80
|
+
def __init__(
|
|
81
|
+
self, init_session: bool = True, tfy_host: Optional[str] = None
|
|
82
|
+
) -> None:
|
|
78
83
|
self._session: Optional[Session] = None
|
|
79
84
|
if init_session:
|
|
80
85
|
if tfy_host:
|
|
@@ -85,25 +90,23 @@ class ServiceFoundryServiceClient(BaseServiceFoundryServiceClient):
|
|
|
85
90
|
raise Exception("Neither session, not tfy_host provided")
|
|
86
91
|
super().__init__(tfy_host=tfy_host)
|
|
87
92
|
|
|
88
|
-
def
|
|
93
|
+
def _get_headers(self) -> Dict[str, str]:
|
|
94
|
+
headers = {"User-Agent": get_user_agent()}
|
|
89
95
|
if not self._session:
|
|
90
|
-
return
|
|
91
|
-
return {
|
|
96
|
+
return headers
|
|
97
|
+
return {
|
|
98
|
+
**headers,
|
|
99
|
+
"Authorization": f"Bearer {self._session.access_token}",
|
|
100
|
+
}
|
|
92
101
|
|
|
93
102
|
@check_min_cli_version
|
|
94
|
-
def get_id_from_fqn(self, fqn_type: str, fqn: str):
|
|
103
|
+
def get_id_from_fqn(self, fqn_type: str, fqn: str) -> Dict[str, Any]:
|
|
95
104
|
url = f"{self._api_server_url}/{VERSION_PREFIX}/fqn/{fqn_type}"
|
|
96
105
|
response = session_with_retries().get(
|
|
97
|
-
url, headers=self.
|
|
106
|
+
url, headers=self._get_headers(), params={"fqn": fqn}
|
|
98
107
|
)
|
|
99
108
|
return request_handling(response)
|
|
100
109
|
|
|
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
110
|
@check_min_cli_version
|
|
108
111
|
def list_workspaces(
|
|
109
112
|
self,
|
|
@@ -120,7 +123,7 @@ class ServiceFoundryServiceClient(BaseServiceFoundryServiceClient):
|
|
|
120
123
|
if workspace_fqn:
|
|
121
124
|
params["workspaceFqn"] = workspace_fqn
|
|
122
125
|
response = session_with_retries().get(
|
|
123
|
-
url, params=params, headers=self.
|
|
126
|
+
url, params=params, headers=self._get_headers()
|
|
124
127
|
)
|
|
125
128
|
response = request_handling(response)
|
|
126
129
|
return parse_obj_as(List[Workspace], response)
|
|
@@ -142,75 +145,44 @@ class ServiceFoundryServiceClient(BaseServiceFoundryServiceClient):
|
|
|
142
145
|
"resources": resources.dict(exclude_none=True),
|
|
143
146
|
}
|
|
144
147
|
},
|
|
145
|
-
headers=self.
|
|
148
|
+
headers=self._get_headers(),
|
|
146
149
|
)
|
|
147
150
|
response_data = request_handling(response)
|
|
148
151
|
return Workspace.parse_obj(response_data)
|
|
149
152
|
|
|
150
153
|
@check_min_cli_version
|
|
151
|
-
def remove_workspace(self, workspace_id, force=False) -> Workspace:
|
|
154
|
+
def remove_workspace(self, workspace_id: str, force: bool = False) -> Workspace:
|
|
152
155
|
url = f"{self._api_server_url}/{VERSION_PREFIX}/workspace/{workspace_id}"
|
|
153
|
-
|
|
156
|
+
force_str = json.dumps(
|
|
154
157
|
force
|
|
155
158
|
) # this dumb conversion is required because `params` just casts as str
|
|
156
159
|
response = session_with_retries().delete(
|
|
157
|
-
url, headers=self.
|
|
160
|
+
url, headers=self._get_headers(), params={"force": force_str}
|
|
158
161
|
)
|
|
159
|
-
response = request_handling(response)
|
|
162
|
+
response = cast(Dict[str, Any], request_handling(response))
|
|
160
163
|
return Workspace.parse_obj(response["workspace"])
|
|
161
164
|
|
|
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
165
|
@check_min_cli_version
|
|
179
166
|
def get_workspace_by_fqn(self, workspace_fqn: str) -> List[Workspace]:
|
|
180
167
|
url = f"{self._api_server_url}/{VERSION_PREFIX}/workspace"
|
|
181
168
|
response = session_with_retries().get(
|
|
182
169
|
url,
|
|
183
|
-
headers=self.
|
|
170
|
+
headers=self._get_headers(),
|
|
184
171
|
params={"fqn": workspace_fqn},
|
|
185
172
|
)
|
|
186
173
|
response = request_handling(response)
|
|
187
174
|
return parse_obj_as(List[Workspace], response)
|
|
188
175
|
|
|
189
176
|
@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):
|
|
177
|
+
def get_cluster(self, cluster_id: str) -> Dict[str, Any]:
|
|
208
178
|
url = f"{self._api_server_url}/{VERSION_PREFIX}/cluster/{cluster_id}"
|
|
209
|
-
response = session_with_retries().get(url, headers=self.
|
|
210
|
-
return request_handling(response)
|
|
179
|
+
response = session_with_retries().get(url, headers=self._get_headers())
|
|
180
|
+
return cast(Dict[str, Any], request_handling(response))
|
|
211
181
|
|
|
212
182
|
@check_min_cli_version
|
|
213
|
-
def get_presigned_url(
|
|
183
|
+
def get_presigned_url(
|
|
184
|
+
self, space_name: str, service_name: str, env: str
|
|
185
|
+
) -> Dict[str, Any]:
|
|
214
186
|
url = f"{self._api_server_url}/{VERSION_PREFIX}/deployment/code-upload-url"
|
|
215
187
|
response = session_with_retries().post(
|
|
216
188
|
url,
|
|
@@ -219,9 +191,9 @@ class ServiceFoundryServiceClient(BaseServiceFoundryServiceClient):
|
|
|
219
191
|
"serviceName": service_name,
|
|
220
192
|
"stage": env,
|
|
221
193
|
},
|
|
222
|
-
headers=self.
|
|
194
|
+
headers=self._get_headers(),
|
|
223
195
|
)
|
|
224
|
-
return request_handling(response)
|
|
196
|
+
return cast(Dict[str, Any], request_handling(response))
|
|
225
197
|
|
|
226
198
|
@check_min_cli_version
|
|
227
199
|
def upload_code_package(
|
|
@@ -231,7 +203,6 @@ class ServiceFoundryServiceClient(BaseServiceFoundryServiceClient):
|
|
|
231
203
|
space_name=workspace_fqn, service_name=component_name, env="default"
|
|
232
204
|
)
|
|
233
205
|
_upload_packaged_code(metadata=http_response, package_file=package_local_path)
|
|
234
|
-
|
|
235
206
|
return http_response["uri"]
|
|
236
207
|
|
|
237
208
|
@check_min_cli_version
|
|
@@ -250,30 +221,30 @@ class ServiceFoundryServiceClient(BaseServiceFoundryServiceClient):
|
|
|
250
221
|
logger.debug(json.dumps(data))
|
|
251
222
|
url = f"{self._api_server_url}/{VERSION_PREFIX}/deployment"
|
|
252
223
|
response = session_with_retries().post(
|
|
253
|
-
url, json=data, headers=self.
|
|
224
|
+
url, json=data, headers=self._get_headers()
|
|
254
225
|
)
|
|
255
|
-
response_data = request_handling(response)
|
|
226
|
+
response_data = cast(Dict[str, Any], request_handling(response))
|
|
256
227
|
return Deployment.parse_obj(response_data["deployment"])
|
|
257
228
|
|
|
258
|
-
def _get_log_print_line(self,
|
|
259
|
-
timestamp = int(
|
|
229
|
+
def _get_log_print_line(self, log_data: LogBody) -> str:
|
|
230
|
+
timestamp = int(log_data.time) / 1e6
|
|
260
231
|
|
|
261
232
|
time_obj = datetime.fromtimestamp(timestamp / 1000.0, tz=timezone.utc)
|
|
262
233
|
time_obj.replace(tzinfo=timezone.utc)
|
|
263
234
|
local_time = time_obj.astimezone(tzlocal())
|
|
264
235
|
local_time_str = local_time.isoformat()
|
|
265
|
-
return f"[{local_time_str}] {log
|
|
236
|
+
return f"[{local_time_str}] {log_data.log.strip()}"
|
|
266
237
|
|
|
267
238
|
def _tail_logs(
|
|
268
239
|
self,
|
|
269
240
|
tail_logs_url: str,
|
|
270
|
-
query_dict:
|
|
241
|
+
query_dict: Dict[str, Any],
|
|
271
242
|
# NOTE: Rather making this printer callback an argument,
|
|
272
243
|
# we should have global printer callback
|
|
273
244
|
# which will be initialized based on the running env (cli, lib, notebook)
|
|
274
245
|
subscribe_message: str,
|
|
275
246
|
socketio_path: str = "socket.io",
|
|
276
|
-
callback=None,
|
|
247
|
+
callback: Optional[OutputCallBack] = None,
|
|
277
248
|
) -> socketio.Client:
|
|
278
249
|
callback = callback or OutputCallBack()
|
|
279
250
|
sio = socketio.Client(request_timeout=60)
|
|
@@ -281,18 +252,20 @@ class ServiceFoundryServiceClient(BaseServiceFoundryServiceClient):
|
|
|
281
252
|
next_log_start_timestamp = query_dict.get("startTs")
|
|
282
253
|
|
|
283
254
|
@sio.on(subscribe_message)
|
|
284
|
-
def logs(data):
|
|
255
|
+
def logs(data: Any) -> None:
|
|
285
256
|
try:
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
257
|
+
event = SocketEvent.parse_obj(json.loads(data))
|
|
258
|
+
if not isinstance(event.body, LogBody):
|
|
259
|
+
logger.debug(f"Skipped log for {data!r}")
|
|
260
|
+
return
|
|
261
|
+
callback.print_line(self._get_log_print_line(event.body))
|
|
289
262
|
nonlocal next_log_start_timestamp
|
|
290
|
-
next_log_start_timestamp = body
|
|
263
|
+
next_log_start_timestamp = event.body.time
|
|
291
264
|
except Exception:
|
|
292
|
-
logger.
|
|
265
|
+
logger.debug(f"Error while parsing log line, {data!r}")
|
|
293
266
|
|
|
294
267
|
@sio.on("connect")
|
|
295
|
-
def on_connect():
|
|
268
|
+
def on_connect() -> None:
|
|
296
269
|
# TODO: We should have have a timeout here. `emit` does
|
|
297
270
|
# not support timeout. Explore `sio.call`.
|
|
298
271
|
query_dict["startTs"] = next_log_start_timestamp
|
|
@@ -301,7 +274,7 @@ class ServiceFoundryServiceClient(BaseServiceFoundryServiceClient):
|
|
|
301
274
|
json.dumps(query_dict),
|
|
302
275
|
)
|
|
303
276
|
|
|
304
|
-
def sio_disconnect_no_exception():
|
|
277
|
+
def sio_disconnect_no_exception() -> None:
|
|
305
278
|
try:
|
|
306
279
|
sio.disconnect()
|
|
307
280
|
except Exception:
|
|
@@ -311,7 +284,7 @@ class ServiceFoundryServiceClient(BaseServiceFoundryServiceClient):
|
|
|
311
284
|
sio.connect(
|
|
312
285
|
tail_logs_url,
|
|
313
286
|
transports="websocket",
|
|
314
|
-
headers=self.
|
|
287
|
+
headers=self._get_headers(),
|
|
315
288
|
socketio_path=socketio_path,
|
|
316
289
|
)
|
|
317
290
|
return sio
|
|
@@ -319,7 +292,7 @@ class ServiceFoundryServiceClient(BaseServiceFoundryServiceClient):
|
|
|
319
292
|
@check_min_cli_version
|
|
320
293
|
def get_deployment(self, application_id: str, deployment_id: str) -> Deployment:
|
|
321
294
|
url = f"{self._api_server_url}/{VERSION_PREFIX}/app/{application_id}/deployments/{deployment_id}"
|
|
322
|
-
response = session_with_retries().get(url, headers=self.
|
|
295
|
+
response = session_with_retries().get(url, headers=self._get_headers())
|
|
323
296
|
response_data = request_handling(response)
|
|
324
297
|
return Deployment.parse_obj(response_data)
|
|
325
298
|
|
|
@@ -328,7 +301,7 @@ class ServiceFoundryServiceClient(BaseServiceFoundryServiceClient):
|
|
|
328
301
|
self, application_id: str, deployment_id: str
|
|
329
302
|
) -> List[AppDeploymentStatusResponse]:
|
|
330
303
|
url = f"{self._api_server_url}/{VERSION_PREFIX}/app/{application_id}/deployments/{deployment_id}/statuses"
|
|
331
|
-
response = session_with_retries().get(url, headers=self.
|
|
304
|
+
response = session_with_retries().get(url, headers=self._get_headers())
|
|
332
305
|
response_data = request_handling(response)
|
|
333
306
|
return parse_obj_as(List[AppDeploymentStatusResponse], response_data)
|
|
334
307
|
|
|
@@ -337,7 +310,7 @@ class ServiceFoundryServiceClient(BaseServiceFoundryServiceClient):
|
|
|
337
310
|
self, application_id: str, deployment_id: str
|
|
338
311
|
) -> List[BuildResponse]:
|
|
339
312
|
url = f"{self._api_server_url}/{VERSION_PREFIX}/app/{application_id}/deployments/{deployment_id}/builds"
|
|
340
|
-
response = session_with_retries().get(url, headers=self.
|
|
313
|
+
response = session_with_retries().get(url, headers=self._get_headers())
|
|
341
314
|
response_data = request_handling(response)
|
|
342
315
|
return parse_obj_as(List[BuildResponse], response_data)
|
|
343
316
|
|
|
@@ -351,11 +324,11 @@ class ServiceFoundryServiceClient(BaseServiceFoundryServiceClient):
|
|
|
351
324
|
end_ts_nano: Optional[int] = None,
|
|
352
325
|
limit: Optional[int] = None,
|
|
353
326
|
num_logs_to_ignore: Optional[int] = None,
|
|
354
|
-
) -> List:
|
|
327
|
+
) -> List[LogBody]:
|
|
355
328
|
get_logs_query = {"applicationId": application_id}
|
|
356
329
|
if deployment_id:
|
|
357
330
|
get_logs_query["deploymentId"] = deployment_id
|
|
358
|
-
data = {"getLogsQuery": json.dumps(get_logs_query)}
|
|
331
|
+
data: Dict[str, Any] = {"getLogsQuery": json.dumps(get_logs_query)}
|
|
359
332
|
if start_ts_nano:
|
|
360
333
|
data["startTs"] = str(start_ts_nano)
|
|
361
334
|
if end_ts_nano:
|
|
@@ -369,22 +342,23 @@ class ServiceFoundryServiceClient(BaseServiceFoundryServiceClient):
|
|
|
369
342
|
|
|
370
343
|
url = f"{self._api_server_url}/{VERSION_PREFIX}/logs/{workspace_id}"
|
|
371
344
|
response = session_with_retries().get(
|
|
372
|
-
url=url, params=data, headers=self.
|
|
345
|
+
url=url, params=data, headers=self._get_headers()
|
|
373
346
|
)
|
|
374
|
-
response_data = request_handling(response)
|
|
375
|
-
return
|
|
347
|
+
response_data = cast(Dict[str, Any], request_handling(response))
|
|
348
|
+
return parse_obj_as(List[LogBody], response_data["data"])
|
|
376
349
|
|
|
377
350
|
@check_min_cli_version
|
|
378
351
|
def tail_build_logs(
|
|
379
352
|
self,
|
|
380
353
|
build_response: BuildResponse,
|
|
381
|
-
callback=None,
|
|
354
|
+
callback: Optional[OutputCallBack] = None,
|
|
382
355
|
) -> socketio.Client:
|
|
383
356
|
callback = callback or OutputCallBack()
|
|
384
357
|
tail_logs_obj = json.loads(build_response.tailLogsUrl)
|
|
385
358
|
socket = self._tail_logs(
|
|
386
359
|
tail_logs_url=urljoin(
|
|
387
|
-
tail_logs_obj["uri"],
|
|
360
|
+
tail_logs_obj["uri"],
|
|
361
|
+
f"/?type={BUILD_LOGS_SUBSCRIBE_MESSAGE}",
|
|
388
362
|
),
|
|
389
363
|
socketio_path=tail_logs_obj["path"],
|
|
390
364
|
query_dict={
|
|
@@ -404,9 +378,9 @@ class ServiceFoundryServiceClient(BaseServiceFoundryServiceClient):
|
|
|
404
378
|
deployment_id: str,
|
|
405
379
|
start_ts: int,
|
|
406
380
|
limit: int,
|
|
407
|
-
callback=None,
|
|
381
|
+
callback: Optional[OutputCallBack] = None,
|
|
408
382
|
wait: bool = True,
|
|
409
|
-
):
|
|
383
|
+
) -> None:
|
|
410
384
|
callback = callback or OutputCallBack()
|
|
411
385
|
self._tail_logs(
|
|
412
386
|
tail_logs_url=urljoin(
|
|
@@ -435,8 +409,8 @@ class ServiceFoundryServiceClient(BaseServiceFoundryServiceClient):
|
|
|
435
409
|
start_ts: int,
|
|
436
410
|
limit: int,
|
|
437
411
|
poll_interval_seconds: int,
|
|
438
|
-
callback=None,
|
|
439
|
-
):
|
|
412
|
+
callback: Optional[OutputCallBack] = None,
|
|
413
|
+
) -> None:
|
|
440
414
|
callback = callback or OutputCallBack()
|
|
441
415
|
start_ts_nano = int(start_ts * 1e6)
|
|
442
416
|
|
|
@@ -444,7 +418,7 @@ class ServiceFoundryServiceClient(BaseServiceFoundryServiceClient):
|
|
|
444
418
|
num_logs_to_ignore = 0
|
|
445
419
|
|
|
446
420
|
while True:
|
|
447
|
-
|
|
421
|
+
logs = self._get_deployment_logs(
|
|
448
422
|
workspace_id=workspace_id,
|
|
449
423
|
application_id=application_id,
|
|
450
424
|
deployment_id=deployment_id,
|
|
@@ -454,18 +428,18 @@ class ServiceFoundryServiceClient(BaseServiceFoundryServiceClient):
|
|
|
454
428
|
num_logs_to_ignore=num_logs_to_ignore,
|
|
455
429
|
)
|
|
456
430
|
|
|
457
|
-
if
|
|
431
|
+
if not logs:
|
|
458
432
|
logger.warning("Did not receive any logs")
|
|
459
433
|
time.sleep(poll_interval_seconds)
|
|
460
434
|
continue
|
|
461
435
|
|
|
462
|
-
for log in
|
|
436
|
+
for log in logs:
|
|
463
437
|
callback.print_line(self._get_log_print_line(log))
|
|
464
438
|
|
|
465
|
-
last_log_time =
|
|
439
|
+
last_log_time = logs[-1].time
|
|
466
440
|
num_logs_to_ignore = 0
|
|
467
|
-
for log in reversed(
|
|
468
|
-
if log
|
|
441
|
+
for log in reversed(logs):
|
|
442
|
+
if log.time != last_log_time:
|
|
469
443
|
break
|
|
470
444
|
num_logs_to_ignore += 1
|
|
471
445
|
|
|
@@ -483,40 +457,43 @@ class ServiceFoundryServiceClient(BaseServiceFoundryServiceClient):
|
|
|
483
457
|
start_ts: Optional[int],
|
|
484
458
|
end_ts: Optional[int],
|
|
485
459
|
limit: Optional[int],
|
|
486
|
-
callback=None,
|
|
487
|
-
):
|
|
460
|
+
callback: Optional[OutputCallBack] = None,
|
|
461
|
+
) -> None:
|
|
488
462
|
callback = callback or OutputCallBack()
|
|
489
|
-
|
|
463
|
+
logs = self._get_deployment_logs(
|
|
490
464
|
workspace_id=workspace_id,
|
|
491
465
|
application_id=application_id,
|
|
492
466
|
deployment_id=deployment_id,
|
|
493
467
|
job_run_name=job_run_name,
|
|
494
|
-
start_ts_nano=int(start_ts * 1e6),
|
|
495
|
-
end_ts_nano=int(end_ts * 1e6),
|
|
468
|
+
start_ts_nano=int(start_ts * 1e6) if start_ts else None,
|
|
469
|
+
end_ts_nano=int(end_ts * 1e6) if end_ts else None,
|
|
496
470
|
limit=limit,
|
|
497
471
|
)
|
|
498
|
-
for log in
|
|
472
|
+
for log in logs:
|
|
499
473
|
callback.print_line(self._get_log_print_line(log))
|
|
500
474
|
|
|
501
475
|
@check_min_cli_version
|
|
502
476
|
def fetch_build_logs(
|
|
503
477
|
self,
|
|
504
478
|
build_response: BuildResponse,
|
|
505
|
-
callback=None,
|
|
479
|
+
callback: Optional[OutputCallBack] = None,
|
|
506
480
|
) -> None:
|
|
507
481
|
callback = callback or OutputCallBack()
|
|
508
482
|
url = build_response.getLogsUrl
|
|
509
|
-
response = session_with_retries().get(url=url, headers=self.
|
|
510
|
-
|
|
511
|
-
for
|
|
512
|
-
|
|
513
|
-
|
|
483
|
+
response = session_with_retries().get(url=url, headers=self._get_headers())
|
|
484
|
+
logs_response = cast(Dict[str, Any], request_handling(response))
|
|
485
|
+
for _log_body in logs_response["logs"]:
|
|
486
|
+
try:
|
|
487
|
+
log_body = LogBody.parse_obj(_log_body)
|
|
488
|
+
callback.print_line(self._get_log_print_line(log_body))
|
|
489
|
+
except Exception:
|
|
490
|
+
logger.debug(f"Failed to parse log body {_log_body}")
|
|
514
491
|
|
|
515
492
|
@check_min_cli_version
|
|
516
493
|
def get_deployment_info_by_fqn(self, deployment_fqn: str) -> DeploymentFqnResponse:
|
|
517
494
|
url = f"{self._api_server_url}/{VERSION_PREFIX}/fqn/deployment"
|
|
518
495
|
response = session_with_retries().get(
|
|
519
|
-
url, headers=self.
|
|
496
|
+
url, headers=self._get_headers(), params={"fqn": deployment_fqn}
|
|
520
497
|
)
|
|
521
498
|
response_data = request_handling(response)
|
|
522
499
|
return DeploymentFqnResponse.parse_obj(response_data)
|
|
@@ -527,23 +504,23 @@ class ServiceFoundryServiceClient(BaseServiceFoundryServiceClient):
|
|
|
527
504
|
) -> ApplicationFqnResponse:
|
|
528
505
|
url = f"{self._api_server_url}/{VERSION_PREFIX}/fqn/app"
|
|
529
506
|
response = session_with_retries().get(
|
|
530
|
-
url, headers=self.
|
|
507
|
+
url, headers=self._get_headers(), params={"fqn": application_fqn}
|
|
531
508
|
)
|
|
532
509
|
response_data = request_handling(response)
|
|
533
510
|
return ApplicationFqnResponse.parse_obj(response_data)
|
|
534
511
|
|
|
535
512
|
@check_min_cli_version
|
|
536
|
-
def remove_application(self, application_id: str):
|
|
513
|
+
def remove_application(self, application_id: str) -> Dict[str, Any]:
|
|
537
514
|
url = f"{self._api_server_url}/{VERSION_PREFIX}/app/{application_id}"
|
|
538
|
-
response = session_with_retries().delete(url, headers=self.
|
|
539
|
-
response = request_handling(response)
|
|
515
|
+
response = session_with_retries().delete(url, headers=self._get_headers())
|
|
516
|
+
response = cast(Dict[str, Any], request_handling(response))
|
|
540
517
|
# TODO: Add pydantic here.
|
|
541
518
|
return response
|
|
542
519
|
|
|
543
520
|
@check_min_cli_version
|
|
544
521
|
def get_application_info(self, application_id: str) -> Application:
|
|
545
522
|
url = f"{self._api_server_url}/{VERSION_PREFIX}/app/{application_id}"
|
|
546
|
-
response = session_with_retries().get(url, headers=self.
|
|
523
|
+
response = session_with_retries().get(url, headers=self._get_headers())
|
|
547
524
|
response = request_handling(response)
|
|
548
525
|
return Application.parse_obj(response)
|
|
549
526
|
|
|
@@ -563,18 +540,18 @@ class ServiceFoundryServiceClient(BaseServiceFoundryServiceClient):
|
|
|
563
540
|
if search_prefix:
|
|
564
541
|
params["searchPrefix"] = search_prefix
|
|
565
542
|
response = session_with_retries().get(
|
|
566
|
-
url, headers=self.
|
|
543
|
+
url, headers=self._get_headers(), params=params
|
|
567
544
|
)
|
|
568
|
-
response_data = request_handling(response)
|
|
545
|
+
response_data = cast(Dict[str, Any], request_handling(response))
|
|
569
546
|
return parse_obj_as(List[JobRun], response_data["data"])
|
|
570
547
|
|
|
571
548
|
def get_job_run(
|
|
572
549
|
self,
|
|
573
550
|
application_id: str,
|
|
574
551
|
job_run_name: str,
|
|
575
|
-
):
|
|
552
|
+
) -> JobRun:
|
|
576
553
|
url = f"{self._api_server_url}/{VERSION_PREFIX}/jobs/{application_id}/runs/{job_run_name}"
|
|
577
|
-
response = session_with_retries().get(url, headers=self.
|
|
554
|
+
response = session_with_retries().get(url, headers=self._get_headers())
|
|
578
555
|
response_data = request_handling(response)
|
|
579
556
|
return parse_obj_as(JobRun, response_data)
|
|
580
557
|
|
|
@@ -594,18 +571,20 @@ class ServiceFoundryServiceClient(BaseServiceFoundryServiceClient):
|
|
|
594
571
|
if params:
|
|
595
572
|
body["input"]["params"] = params
|
|
596
573
|
response = session_with_retries().post(
|
|
597
|
-
url, json=body, headers=self.
|
|
574
|
+
url, json=body, headers=self._get_headers()
|
|
598
575
|
)
|
|
599
576
|
response = request_handling(response)
|
|
600
577
|
return TriggerJobResult.parse_obj(response)
|
|
601
578
|
|
|
602
|
-
def trigger_workflow(
|
|
579
|
+
def trigger_workflow(
|
|
580
|
+
self, application_id: str, inputs: Dict[str, Any]
|
|
581
|
+
) -> Dict[str, Any]:
|
|
603
582
|
url = f"{self._api_server_url}/{VERSION_PREFIX}/workflow/{application_id}/executions"
|
|
604
583
|
body = {"inputs": inputs}
|
|
605
584
|
response = session_with_retries(retries=MAX_RETRIES_WORKFLOW_TRIGGER).post(
|
|
606
|
-
url, json=body, headers=self.
|
|
585
|
+
url, json=body, headers=self._get_headers()
|
|
607
586
|
)
|
|
608
|
-
response = request_handling(response)
|
|
587
|
+
response = cast(Dict[str, Any], request_handling(response))
|
|
609
588
|
return response
|
|
610
589
|
|
|
611
590
|
@check_min_cli_version
|
|
@@ -615,7 +594,7 @@ class ServiceFoundryServiceClient(BaseServiceFoundryServiceClient):
|
|
|
615
594
|
url = f"{self._api_server_url}/{VERSION_PREFIX}/docker-registry/creds"
|
|
616
595
|
response = session_with_retries().get(
|
|
617
596
|
url,
|
|
618
|
-
headers=self.
|
|
597
|
+
headers=self._get_headers(),
|
|
619
598
|
params={
|
|
620
599
|
"fqn": docker_registry_fqn,
|
|
621
600
|
"clusterId": cluster_id,
|
|
@@ -631,7 +610,7 @@ class ServiceFoundryServiceClient(BaseServiceFoundryServiceClient):
|
|
|
631
610
|
url = f"{self._api_server_url}/{VERSION_PREFIX}/docker-registry/create-repo"
|
|
632
611
|
response = session_with_retries().post(
|
|
633
612
|
url,
|
|
634
|
-
headers=self.
|
|
613
|
+
headers=self._get_headers(),
|
|
635
614
|
data={
|
|
636
615
|
"fqn": docker_registry_fqn,
|
|
637
616
|
"workspaceFqn": workspace_fqn,
|
|
@@ -657,7 +636,7 @@ class ServiceFoundryServiceClient(BaseServiceFoundryServiceClient):
|
|
|
657
636
|
if application_name:
|
|
658
637
|
params["applicationName"] = application_name
|
|
659
638
|
response = session_with_retries().get(
|
|
660
|
-
url, params=params, headers=self.
|
|
639
|
+
url, params=params, headers=self._get_headers()
|
|
661
640
|
)
|
|
662
641
|
response = request_handling(response)
|
|
663
642
|
return parse_obj_as(List[Application], response)
|
|
@@ -678,36 +657,36 @@ class ServiceFoundryServiceClient(BaseServiceFoundryServiceClient):
|
|
|
678
657
|
if deployment_id:
|
|
679
658
|
params["deploymentId"] = deployment_id
|
|
680
659
|
response = session_with_retries().get(
|
|
681
|
-
url, params=params, headers=self.
|
|
660
|
+
url, params=params, headers=self._get_headers()
|
|
682
661
|
)
|
|
683
662
|
response = request_handling(response)
|
|
684
663
|
return parse_obj_as(List[Deployment], response)
|
|
685
664
|
|
|
686
665
|
@check_min_cli_version
|
|
687
|
-
def apply(self, manifest: Dict[str, Any], dry_run: bool = False):
|
|
666
|
+
def apply(self, manifest: Dict[str, Any], dry_run: bool = False) -> Dict[str, Any]:
|
|
688
667
|
url = f"{self._api_server_url}/{VERSION_PREFIX}/apply"
|
|
689
668
|
body = {"manifest": manifest, "dryRun": dry_run}
|
|
690
669
|
response = session_with_retries().put(
|
|
691
|
-
url, headers=self.
|
|
670
|
+
url, headers=self._get_headers(), json=body
|
|
692
671
|
)
|
|
693
|
-
response_data = request_handling(response)
|
|
672
|
+
response_data = cast(Dict[str, Any], request_handling(response))
|
|
694
673
|
return response_data
|
|
695
674
|
|
|
696
675
|
@check_min_cli_version
|
|
697
|
-
def delete(self, manifest: Dict[str, Any]):
|
|
676
|
+
def delete(self, manifest: Dict[str, Any]) -> Dict[str, Any]:
|
|
698
677
|
url = f"{self._api_server_url}/{VERSION_PREFIX}/delete"
|
|
699
678
|
body = {"manifest": manifest}
|
|
700
679
|
response = session_with_retries().post(
|
|
701
|
-
url, headers=self.
|
|
680
|
+
url, headers=self._get_headers(), json=body
|
|
702
681
|
)
|
|
703
|
-
response_data = request_handling(response)
|
|
682
|
+
response_data = cast(Dict[str, Any], request_handling(response))
|
|
704
683
|
return response_data
|
|
705
684
|
|
|
706
685
|
def terminate_job_run(
|
|
707
686
|
self,
|
|
708
687
|
deployment_id: str,
|
|
709
688
|
job_run_name: str,
|
|
710
|
-
):
|
|
689
|
+
) -> Dict[str, Any]:
|
|
711
690
|
url = f"{self._api_server_url}/{VERSION_PREFIX}/jobs/terminate"
|
|
712
691
|
body = {
|
|
713
692
|
"deploymentId": deployment_id,
|
|
@@ -718,7 +697,7 @@ class ServiceFoundryServiceClient(BaseServiceFoundryServiceClient):
|
|
|
718
697
|
# TODO (chiragjn): Check if this is supposed to be params or json
|
|
719
698
|
params=body,
|
|
720
699
|
json=body,
|
|
721
|
-
headers=self.
|
|
700
|
+
headers=self._get_headers(),
|
|
722
701
|
)
|
|
723
|
-
response_data = request_handling(response)
|
|
702
|
+
response_data = cast(Dict[str, Any], request_handling(response))
|
|
724
703
|
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,
|