truefoundry 0.3.4rc1__py3-none-any.whl → 0.4.0__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/__init__.py +2 -0
- truefoundry/autodeploy/agents/developer.py +1 -1
- truefoundry/autodeploy/agents/project_identifier.py +2 -2
- truefoundry/autodeploy/agents/tester.py +1 -1
- truefoundry/autodeploy/cli.py +1 -1
- truefoundry/autodeploy/tools/list_files.py +1 -1
- truefoundry/cli/__main__.py +3 -17
- truefoundry/common/__init__.py +0 -0
- truefoundry/{deploy/lib/auth → common}/auth_service_client.py +50 -40
- truefoundry/common/constants.py +12 -0
- truefoundry/{deploy/lib/auth → common}/credential_file_manager.py +7 -7
- truefoundry/{deploy/lib/auth → common}/credential_provider.py +10 -23
- truefoundry/common/entities.py +124 -0
- truefoundry/common/exceptions.py +12 -0
- truefoundry/common/request_utils.py +84 -0
- truefoundry/common/servicefoundry_client.py +91 -0
- truefoundry/common/utils.py +56 -0
- truefoundry/deploy/auto_gen/models.py +4 -6
- truefoundry/deploy/cli/cli.py +3 -1
- truefoundry/deploy/cli/commands/apply_command.py +1 -1
- truefoundry/deploy/cli/commands/build_command.py +1 -1
- truefoundry/deploy/cli/commands/deploy_command.py +1 -1
- truefoundry/deploy/cli/commands/login_command.py +2 -2
- truefoundry/deploy/cli/commands/patch_application_command.py +1 -1
- truefoundry/deploy/cli/commands/patch_command.py +1 -1
- truefoundry/deploy/cli/commands/terminate_comand.py +1 -1
- truefoundry/deploy/cli/util.py +1 -1
- truefoundry/deploy/function_service/remote/remote.py +1 -1
- truefoundry/deploy/lib/auth/servicefoundry_session.py +2 -2
- truefoundry/deploy/lib/clients/servicefoundry_client.py +120 -159
- truefoundry/deploy/lib/const.py +1 -35
- truefoundry/deploy/lib/exceptions.py +0 -16
- truefoundry/deploy/lib/model/entity.py +1 -112
- truefoundry/deploy/lib/session.py +14 -42
- truefoundry/deploy/lib/util.py +0 -37
- truefoundry/{python_deploy_codegen.py → deploy/python_deploy_codegen.py} +2 -2
- truefoundry/deploy/v2/lib/deploy.py +3 -3
- truefoundry/deploy/v2/lib/deployable_patched_models.py +1 -1
- truefoundry/langchain/truefoundry_chat.py +1 -1
- truefoundry/langchain/truefoundry_embeddings.py +1 -1
- truefoundry/langchain/truefoundry_llm.py +1 -1
- truefoundry/langchain/utils.py +0 -41
- truefoundry/ml/__init__.py +37 -6
- truefoundry/ml/artifact/__init__.py +0 -0
- truefoundry/ml/artifact/truefoundry_artifact_repo.py +1161 -0
- truefoundry/ml/autogen/__init__.py +0 -0
- truefoundry/ml/autogen/client/__init__.py +370 -0
- truefoundry/ml/autogen/client/api/__init__.py +16 -0
- truefoundry/ml/autogen/client/api/auth_api.py +184 -0
- truefoundry/ml/autogen/client/api/deprecated_api.py +605 -0
- truefoundry/ml/autogen/client/api/experiments_api.py +1944 -0
- truefoundry/ml/autogen/client/api/health_api.py +299 -0
- truefoundry/ml/autogen/client/api/metrics_api.py +371 -0
- truefoundry/ml/autogen/client/api/mlfoundry_artifacts_api.py +7213 -0
- truefoundry/ml/autogen/client/api/python_deployment_config_api.py +201 -0
- truefoundry/ml/autogen/client/api/run_artifacts_api.py +231 -0
- truefoundry/ml/autogen/client/api/runs_api.py +2919 -0
- truefoundry/ml/autogen/client/api_client.py +822 -0
- truefoundry/ml/autogen/client/api_response.py +30 -0
- truefoundry/ml/autogen/client/configuration.py +489 -0
- truefoundry/ml/autogen/client/exceptions.py +161 -0
- truefoundry/ml/autogen/client/models/__init__.py +341 -0
- truefoundry/ml/autogen/client/models/add_custom_metrics_to_model_version_request_dto.py +69 -0
- truefoundry/ml/autogen/client/models/add_features_to_model_version_request_dto.py +83 -0
- truefoundry/ml/autogen/client/models/agent.py +125 -0
- truefoundry/ml/autogen/client/models/agent_app.py +118 -0
- truefoundry/ml/autogen/client/models/agent_open_api_tool.py +143 -0
- truefoundry/ml/autogen/client/models/agent_open_api_tool_with_fqn.py +144 -0
- truefoundry/ml/autogen/client/models/agent_with_fqn.py +127 -0
- truefoundry/ml/autogen/client/models/artifact_dto.py +115 -0
- truefoundry/ml/autogen/client/models/artifact_response_dto.py +75 -0
- truefoundry/ml/autogen/client/models/artifact_type.py +39 -0
- truefoundry/ml/autogen/client/models/artifact_version_dto.py +141 -0
- truefoundry/ml/autogen/client/models/artifact_version_response_dto.py +77 -0
- truefoundry/ml/autogen/client/models/artifact_version_status.py +35 -0
- truefoundry/ml/autogen/client/models/assistant_message.py +89 -0
- truefoundry/ml/autogen/client/models/authorize_user_for_model_request_dto.py +69 -0
- truefoundry/ml/autogen/client/models/authorize_user_for_model_version_request_dto.py +69 -0
- truefoundry/ml/autogen/client/models/blob_storage_reference.py +93 -0
- truefoundry/ml/autogen/client/models/body_get_search_runs_get.py +72 -0
- truefoundry/ml/autogen/client/models/chat_prompt.py +156 -0
- truefoundry/ml/autogen/client/models/chat_prompt_messages_inner.py +171 -0
- truefoundry/ml/autogen/client/models/columns_dto.py +73 -0
- truefoundry/ml/autogen/client/models/content.py +153 -0
- truefoundry/ml/autogen/client/models/content1.py +153 -0
- truefoundry/ml/autogen/client/models/content2.py +174 -0
- truefoundry/ml/autogen/client/models/content2_any_of_inner.py +150 -0
- truefoundry/ml/autogen/client/models/create_artifact_request_dto.py +74 -0
- truefoundry/ml/autogen/client/models/create_artifact_response_dto.py +65 -0
- truefoundry/ml/autogen/client/models/create_artifact_version_request_dto.py +74 -0
- truefoundry/ml/autogen/client/models/create_artifact_version_response_dto.py +65 -0
- truefoundry/ml/autogen/client/models/create_dataset_request_dto.py +76 -0
- truefoundry/ml/autogen/client/models/create_experiment_request_dto.py +94 -0
- truefoundry/ml/autogen/client/models/create_experiment_response_dto.py +67 -0
- truefoundry/ml/autogen/client/models/create_model_version_request_dto.py +95 -0
- truefoundry/ml/autogen/client/models/create_multi_part_upload_for_dataset_request_dto.py +73 -0
- truefoundry/ml/autogen/client/models/create_multi_part_upload_for_dataset_response_dto.py +79 -0
- truefoundry/ml/autogen/client/models/create_multi_part_upload_request_dto.py +73 -0
- truefoundry/ml/autogen/client/models/create_python_deployment_config_request_dto.py +72 -0
- truefoundry/ml/autogen/client/models/create_python_deployment_config_response_dto.py +67 -0
- truefoundry/ml/autogen/client/models/create_run_request_dto.py +97 -0
- truefoundry/ml/autogen/client/models/create_run_response_dto.py +75 -0
- truefoundry/ml/autogen/client/models/dataset_dto.py +112 -0
- truefoundry/ml/autogen/client/models/dataset_response_dto.py +75 -0
- truefoundry/ml/autogen/client/models/delete_artifact_versions_request_dto.py +65 -0
- truefoundry/ml/autogen/client/models/delete_dataset_request_dto.py +74 -0
- truefoundry/ml/autogen/client/models/delete_model_version_request_dto.py +65 -0
- truefoundry/ml/autogen/client/models/delete_run_request.py +65 -0
- truefoundry/ml/autogen/client/models/delete_tag_request_dto.py +68 -0
- truefoundry/ml/autogen/client/models/experiment_dto.py +127 -0
- truefoundry/ml/autogen/client/models/experiment_id_request_dto.py +67 -0
- truefoundry/ml/autogen/client/models/experiment_response_dto.py +75 -0
- truefoundry/ml/autogen/client/models/experiment_tag_dto.py +69 -0
- truefoundry/ml/autogen/client/models/feature_dto.py +68 -0
- truefoundry/ml/autogen/client/models/feature_value_type.py +35 -0
- truefoundry/ml/autogen/client/models/file_info_dto.py +76 -0
- truefoundry/ml/autogen/client/models/finalize_artifact_version_request_dto.py +101 -0
- truefoundry/ml/autogen/client/models/get_experiment_response_dto.py +88 -0
- truefoundry/ml/autogen/client/models/get_latest_run_log_response_dto.py +75 -0
- truefoundry/ml/autogen/client/models/get_metric_history_response.py +79 -0
- truefoundry/ml/autogen/client/models/get_signed_url_for_dataset_write_request_dto.py +68 -0
- truefoundry/ml/autogen/client/models/get_signed_urls_for_artifact_version_read_request_dto.py +68 -0
- truefoundry/ml/autogen/client/models/get_signed_urls_for_artifact_version_read_response_dto.py +81 -0
- truefoundry/ml/autogen/client/models/get_signed_urls_for_artifact_version_write_request_dto.py +69 -0
- truefoundry/ml/autogen/client/models/get_signed_urls_for_artifact_version_write_response_dto.py +83 -0
- truefoundry/ml/autogen/client/models/get_signed_urls_for_dataset_read_request_dto.py +68 -0
- truefoundry/ml/autogen/client/models/get_signed_urls_for_dataset_read_response_dto.py +81 -0
- truefoundry/ml/autogen/client/models/get_signed_urls_for_dataset_write_response_dto.py +81 -0
- truefoundry/ml/autogen/client/models/get_tenant_id_response_dto.py +73 -0
- truefoundry/ml/autogen/client/models/http_validation_error.py +82 -0
- truefoundry/ml/autogen/client/models/image_content_part.py +87 -0
- truefoundry/ml/autogen/client/models/image_url.py +75 -0
- truefoundry/ml/autogen/client/models/internal_metadata.py +180 -0
- truefoundry/ml/autogen/client/models/latest_run_log_dto.py +78 -0
- truefoundry/ml/autogen/client/models/list_artifact_versions_request_dto.py +107 -0
- truefoundry/ml/autogen/client/models/list_artifact_versions_response_dto.py +87 -0
- truefoundry/ml/autogen/client/models/list_artifacts_request_dto.py +96 -0
- truefoundry/ml/autogen/client/models/list_artifacts_response_dto.py +86 -0
- truefoundry/ml/autogen/client/models/list_colums_response_dto.py +75 -0
- truefoundry/ml/autogen/client/models/list_datasets_request_dto.py +78 -0
- truefoundry/ml/autogen/client/models/list_datasets_response_dto.py +86 -0
- truefoundry/ml/autogen/client/models/list_experiments_response_dto.py +86 -0
- truefoundry/ml/autogen/client/models/list_files_for_artifact_version_request_dto.py +76 -0
- truefoundry/ml/autogen/client/models/list_files_for_artifact_versions_response_dto.py +82 -0
- truefoundry/ml/autogen/client/models/list_files_for_dataset_request_dto.py +76 -0
- truefoundry/ml/autogen/client/models/list_files_for_dataset_response_dto.py +82 -0
- truefoundry/ml/autogen/client/models/list_latest_run_logs_response_dto.py +82 -0
- truefoundry/ml/autogen/client/models/list_metric_history_request_dto.py +69 -0
- truefoundry/ml/autogen/client/models/list_metric_history_response_dto.py +84 -0
- truefoundry/ml/autogen/client/models/list_model_version_response_dto.py +87 -0
- truefoundry/ml/autogen/client/models/list_model_versions_request_dto.py +93 -0
- truefoundry/ml/autogen/client/models/list_models_request_dto.py +89 -0
- truefoundry/ml/autogen/client/models/list_models_response_dto.py +84 -0
- truefoundry/ml/autogen/client/models/list_run_artifacts_response_dto.py +84 -0
- truefoundry/ml/autogen/client/models/list_run_logs_response_dto.py +82 -0
- truefoundry/ml/autogen/client/models/list_seed_experiments_response_dto.py +81 -0
- truefoundry/ml/autogen/client/models/log_batch_request_dto.py +106 -0
- truefoundry/ml/autogen/client/models/log_metric_request_dto.py +80 -0
- truefoundry/ml/autogen/client/models/log_param_request_dto.py +76 -0
- truefoundry/ml/autogen/client/models/method.py +37 -0
- truefoundry/ml/autogen/client/models/metric_collection_dto.py +82 -0
- truefoundry/ml/autogen/client/models/metric_dto.py +76 -0
- truefoundry/ml/autogen/client/models/mime_type.py +37 -0
- truefoundry/ml/autogen/client/models/model_configuration.py +103 -0
- truefoundry/ml/autogen/client/models/model_dto.py +122 -0
- truefoundry/ml/autogen/client/models/model_response_dto.py +75 -0
- truefoundry/ml/autogen/client/models/model_schema_dto.py +85 -0
- truefoundry/ml/autogen/client/models/model_version_dto.py +170 -0
- truefoundry/ml/autogen/client/models/model_version_response_dto.py +75 -0
- truefoundry/ml/autogen/client/models/multi_part_upload_dto.py +107 -0
- truefoundry/ml/autogen/client/models/multi_part_upload_response_dto.py +79 -0
- truefoundry/ml/autogen/client/models/multi_part_upload_storage_provider.py +34 -0
- truefoundry/ml/autogen/client/models/notify_artifact_version_failure_dto.py +65 -0
- truefoundry/ml/autogen/client/models/openapi_spec.py +152 -0
- truefoundry/ml/autogen/client/models/param_dto.py +66 -0
- truefoundry/ml/autogen/client/models/parameters.py +84 -0
- truefoundry/ml/autogen/client/models/prediction_type.py +34 -0
- truefoundry/ml/autogen/client/models/resolve_agent_app_response_dto.py +75 -0
- truefoundry/ml/autogen/client/models/restore_run_request_dto.py +65 -0
- truefoundry/ml/autogen/client/models/run_data_dto.py +104 -0
- truefoundry/ml/autogen/client/models/run_dto.py +84 -0
- truefoundry/ml/autogen/client/models/run_info_dto.py +105 -0
- truefoundry/ml/autogen/client/models/run_log_dto.py +90 -0
- truefoundry/ml/autogen/client/models/run_log_input_dto.py +80 -0
- truefoundry/ml/autogen/client/models/run_response_dto.py +75 -0
- truefoundry/ml/autogen/client/models/run_tag_dto.py +66 -0
- truefoundry/ml/autogen/client/models/search_runs_request_dto.py +94 -0
- truefoundry/ml/autogen/client/models/search_runs_response_dto.py +84 -0
- truefoundry/ml/autogen/client/models/set_experiment_tag_request_dto.py +73 -0
- truefoundry/ml/autogen/client/models/set_tag_request_dto.py +76 -0
- truefoundry/ml/autogen/client/models/signed_url_dto.py +69 -0
- truefoundry/ml/autogen/client/models/stop.py +152 -0
- truefoundry/ml/autogen/client/models/store_run_logs_request_dto.py +83 -0
- truefoundry/ml/autogen/client/models/system_message.py +89 -0
- truefoundry/ml/autogen/client/models/text.py +153 -0
- truefoundry/ml/autogen/client/models/text_content_part.py +84 -0
- truefoundry/ml/autogen/client/models/update_artifact_version_request_dto.py +74 -0
- truefoundry/ml/autogen/client/models/update_dataset_request_dto.py +74 -0
- truefoundry/ml/autogen/client/models/update_experiment_request_dto.py +74 -0
- truefoundry/ml/autogen/client/models/update_model_version_request_dto.py +93 -0
- truefoundry/ml/autogen/client/models/update_run_request_dto.py +78 -0
- truefoundry/ml/autogen/client/models/update_run_response_dto.py +75 -0
- truefoundry/ml/autogen/client/models/url.py +153 -0
- truefoundry/ml/autogen/client/models/user_message.py +89 -0
- truefoundry/ml/autogen/client/models/validation_error.py +87 -0
- truefoundry/ml/autogen/client/models/validation_error_loc_inner.py +154 -0
- truefoundry/ml/autogen/client/rest.py +426 -0
- truefoundry/ml/autogen/client_README.md +320 -0
- truefoundry/ml/cli/__init__.py +0 -0
- truefoundry/ml/cli/cli.py +18 -0
- truefoundry/ml/cli/commands/__init__.py +3 -0
- truefoundry/ml/cli/commands/download.py +87 -0
- truefoundry/ml/clients/__init__.py +0 -0
- truefoundry/ml/clients/entities.py +8 -0
- truefoundry/ml/clients/servicefoundry_client.py +45 -0
- truefoundry/ml/clients/utils.py +122 -0
- truefoundry/ml/constants.py +84 -0
- truefoundry/ml/entities.py +62 -0
- truefoundry/ml/enums.py +70 -0
- truefoundry/ml/env_vars.py +9 -0
- truefoundry/ml/exceptions.py +8 -0
- truefoundry/ml/git_info.py +60 -0
- truefoundry/ml/internal_namespace.py +52 -0
- truefoundry/ml/log_types/__init__.py +4 -0
- truefoundry/ml/log_types/artifacts/artifact.py +431 -0
- truefoundry/ml/log_types/artifacts/constants.py +33 -0
- truefoundry/ml/log_types/artifacts/dataset.py +384 -0
- truefoundry/ml/log_types/artifacts/general_artifact.py +110 -0
- truefoundry/ml/log_types/artifacts/model.py +611 -0
- truefoundry/ml/log_types/artifacts/model_extras.py +48 -0
- truefoundry/ml/log_types/artifacts/utils.py +161 -0
- truefoundry/ml/log_types/image/__init__.py +3 -0
- truefoundry/ml/log_types/image/constants.py +8 -0
- truefoundry/ml/log_types/image/image.py +357 -0
- truefoundry/ml/log_types/image/image_normalizer.py +102 -0
- truefoundry/ml/log_types/image/types.py +68 -0
- truefoundry/ml/log_types/plot.py +281 -0
- truefoundry/ml/log_types/pydantic_base.py +10 -0
- truefoundry/ml/log_types/utils.py +12 -0
- truefoundry/ml/logger.py +17 -0
- truefoundry/ml/mlfoundry_api.py +1575 -0
- truefoundry/ml/mlfoundry_run.py +1203 -0
- truefoundry/ml/run_utils.py +93 -0
- truefoundry/ml/session.py +168 -0
- truefoundry/ml/validation_utils.py +346 -0
- truefoundry/pydantic_v1.py +8 -1
- truefoundry/workflow/__init__.py +16 -1
- {truefoundry-0.3.4rc1.dist-info → truefoundry-0.4.0.dist-info}/METADATA +21 -14
- truefoundry-0.4.0.dist-info/RECORD +344 -0
- truefoundry/deploy/lib/clients/utils.py +0 -41
- truefoundry-0.3.4rc1.dist-info/RECORD +0 -136
- {truefoundry-0.3.4rc1.dist-info → truefoundry-0.4.0.dist-info}/WHEEL +0 -0
- {truefoundry-0.3.4rc1.dist-info → truefoundry-0.4.0.dist-info}/entry_points.txt +0 -0
|
@@ -1,39 +1,41 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
|
-
import functools
|
|
4
3
|
import json
|
|
5
4
|
import os
|
|
6
5
|
import time
|
|
7
6
|
from datetime import datetime, timezone
|
|
8
7
|
from typing import TYPE_CHECKING, Any, Dict, List, Optional
|
|
9
|
-
from urllib.parse import urljoin
|
|
8
|
+
from urllib.parse import urljoin
|
|
10
9
|
|
|
11
10
|
import requests
|
|
12
11
|
import socketio
|
|
13
12
|
from dateutil.tz import tzlocal
|
|
14
|
-
from packaging import version
|
|
15
13
|
from rich.status import Status
|
|
16
14
|
from tqdm import tqdm
|
|
17
15
|
from tqdm.utils import CallbackIOWrapper
|
|
18
16
|
|
|
17
|
+
from truefoundry.common.constants import VERSION_PREFIX
|
|
18
|
+
from truefoundry.common.request_utils import request_handling
|
|
19
|
+
from truefoundry.common.servicefoundry_client import (
|
|
20
|
+
ServiceFoundryServiceClient as BaseServiceFoundryServiceClient,
|
|
21
|
+
)
|
|
22
|
+
from truefoundry.common.servicefoundry_client import (
|
|
23
|
+
check_min_cli_version,
|
|
24
|
+
session_with_retries,
|
|
25
|
+
)
|
|
26
|
+
from truefoundry.deploy.auto_gen import models as auto_gen_models
|
|
19
27
|
from truefoundry.deploy.io.output_callback import OutputCallBack
|
|
20
28
|
from truefoundry.deploy.lib.auth.servicefoundry_session import ServiceFoundrySession
|
|
21
|
-
from truefoundry.deploy.lib.clients.utils import request_handling
|
|
22
|
-
from truefoundry.deploy.lib.const import API_SERVER_RELATIVE_PATH, VERSION_PREFIX
|
|
23
29
|
from truefoundry.deploy.lib.model.entity import (
|
|
24
30
|
Application,
|
|
25
31
|
CreateDockerRepositoryResponse,
|
|
26
32
|
Deployment,
|
|
27
33
|
DockerRegistryCredentials,
|
|
28
34
|
JobRun,
|
|
29
|
-
PythonSDKConfig,
|
|
30
|
-
TenantInfo,
|
|
31
|
-
Token,
|
|
32
35
|
TriggerJobResult,
|
|
33
36
|
Workspace,
|
|
34
37
|
WorkspaceResources,
|
|
35
38
|
)
|
|
36
|
-
from truefoundry.deploy.lib.util import timed_lru_cache
|
|
37
39
|
from truefoundry.deploy.lib.win32 import allow_interrupt
|
|
38
40
|
from truefoundry.deploy.v2.lib.models import (
|
|
39
41
|
AppDeploymentStatusResponse,
|
|
@@ -43,7 +45,6 @@ from truefoundry.deploy.v2.lib.models import (
|
|
|
43
45
|
)
|
|
44
46
|
from truefoundry.logger import logger
|
|
45
47
|
from truefoundry.pydantic_v1 import parse_obj_as
|
|
46
|
-
from truefoundry.version import __version__
|
|
47
48
|
|
|
48
49
|
DEPLOYMENT_LOGS_SUBSCRIBE_MESSAGE = "DEPLOYMENT_LOGS"
|
|
49
50
|
BUILD_LOGS_SUBSCRIBE_MESSAGE = "BUILD_LOGS"
|
|
@@ -74,46 +75,7 @@ def _upload_packaged_code(metadata, package_file):
|
|
|
74
75
|
raise RuntimeError(f"Failed to upload code {http_response.content}")
|
|
75
76
|
|
|
76
77
|
|
|
77
|
-
|
|
78
|
-
@functools.wraps(fn)
|
|
79
|
-
def inner(*args, **kwargs):
|
|
80
|
-
if __version__ != "0.0.0":
|
|
81
|
-
client: "ServiceFoundryServiceClient" = args[0]
|
|
82
|
-
# "0.0.0" indicates dev version
|
|
83
|
-
# noinspection PyProtectedMember
|
|
84
|
-
min_cli_version_required = client._min_cli_version_required
|
|
85
|
-
if version.parse(__version__) < version.parse(min_cli_version_required):
|
|
86
|
-
raise Exception(
|
|
87
|
-
"You are using an outdated version of `truefoundry`.\n"
|
|
88
|
-
f"Run `pip install truefoundry>={min_cli_version_required}` to install the supported version.",
|
|
89
|
-
)
|
|
90
|
-
else:
|
|
91
|
-
logger.debug("Ignoring minimum cli version check")
|
|
92
|
-
|
|
93
|
-
return fn(*args, **kwargs)
|
|
94
|
-
|
|
95
|
-
return inner
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
@timed_lru_cache(seconds=30 * 60)
|
|
99
|
-
def _cached_get_tenant_info(api_server_url: str) -> TenantInfo:
|
|
100
|
-
res = requests.get(
|
|
101
|
-
url=f"{api_server_url}/v1/tenant-id",
|
|
102
|
-
params={"hostName": urlparse(api_server_url).netloc},
|
|
103
|
-
)
|
|
104
|
-
res = request_handling(res)
|
|
105
|
-
return TenantInfo.parse_obj(res)
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
@timed_lru_cache(seconds=30 * 60)
|
|
109
|
-
def _cached_get_python_sdk_config(api_server_url: str) -> PythonSDKConfig:
|
|
110
|
-
url = f"{api_server_url}/v1/min-cli-version"
|
|
111
|
-
res = requests.get(url)
|
|
112
|
-
res = request_handling(res)
|
|
113
|
-
return PythonSDKConfig.parse_obj(res)
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
class ServiceFoundryServiceClient:
|
|
78
|
+
class ServiceFoundryServiceClient(BaseServiceFoundryServiceClient):
|
|
117
79
|
def __init__(self, init_session: bool = True, base_url: Optional[str] = None):
|
|
118
80
|
self._session: Optional[ServiceFoundrySession] = None
|
|
119
81
|
if init_session:
|
|
@@ -123,27 +85,7 @@ class ServiceFoundryServiceClient:
|
|
|
123
85
|
base_url = self._session.base_url
|
|
124
86
|
elif not base_url:
|
|
125
87
|
raise Exception("Neither session, not base_url provided")
|
|
126
|
-
|
|
127
|
-
self._base_url = base_url.strip("/")
|
|
128
|
-
self._api_server_url = f"{self._base_url}/{API_SERVER_RELATIVE_PATH}"
|
|
129
|
-
|
|
130
|
-
@property
|
|
131
|
-
def base_url(self) -> str:
|
|
132
|
-
return self._base_url
|
|
133
|
-
|
|
134
|
-
@property
|
|
135
|
-
def tenant_info(self) -> TenantInfo:
|
|
136
|
-
return _cached_get_tenant_info(self._api_server_url)
|
|
137
|
-
|
|
138
|
-
@property
|
|
139
|
-
def python_sdk_config(self) -> PythonSDKConfig:
|
|
140
|
-
return _cached_get_python_sdk_config(self._api_server_url)
|
|
141
|
-
|
|
142
|
-
@functools.cached_property
|
|
143
|
-
def _min_cli_version_required(self) -> str:
|
|
144
|
-
return _cached_get_python_sdk_config(
|
|
145
|
-
self._api_server_url
|
|
146
|
-
).truefoundry_cli_min_version
|
|
88
|
+
super().__init__(base_url=base_url)
|
|
147
89
|
|
|
148
90
|
def _get_header(self):
|
|
149
91
|
if not self._session:
|
|
@@ -153,14 +95,16 @@ class ServiceFoundryServiceClient:
|
|
|
153
95
|
@check_min_cli_version
|
|
154
96
|
def get_id_from_fqn(self, fqn_type: str, fqn: str):
|
|
155
97
|
url = f"{self._api_server_url}/{VERSION_PREFIX}/fqn/{fqn_type}"
|
|
156
|
-
|
|
157
|
-
|
|
98
|
+
response = session_with_retries().get(
|
|
99
|
+
url, headers=self._get_header(), params={"fqn": fqn}
|
|
100
|
+
)
|
|
101
|
+
return request_handling(response)
|
|
158
102
|
|
|
159
103
|
@check_min_cli_version
|
|
160
104
|
def list_workspace(self):
|
|
161
105
|
url = f"{self._api_server_url}/{VERSION_PREFIX}/workspace"
|
|
162
|
-
|
|
163
|
-
return request_handling(
|
|
106
|
+
response = session_with_retries().get(url, headers=self._get_header())
|
|
107
|
+
return request_handling(response)
|
|
164
108
|
|
|
165
109
|
@check_min_cli_version
|
|
166
110
|
def list_workspaces(
|
|
@@ -177,8 +121,10 @@ class ServiceFoundryServiceClient:
|
|
|
177
121
|
params["workspaceName"] = workspace_name
|
|
178
122
|
if workspace_fqn:
|
|
179
123
|
params["workspaceFqn"] = workspace_fqn
|
|
180
|
-
|
|
181
|
-
|
|
124
|
+
response = session_with_retries().get(
|
|
125
|
+
url, params=params, headers=self._get_header()
|
|
126
|
+
)
|
|
127
|
+
response = request_handling(response)
|
|
182
128
|
return parse_obj_as(List[Workspace], response)
|
|
183
129
|
|
|
184
130
|
@check_min_cli_version
|
|
@@ -189,7 +135,7 @@ class ServiceFoundryServiceClient:
|
|
|
189
135
|
resources: WorkspaceResources,
|
|
190
136
|
) -> Workspace:
|
|
191
137
|
url = f"{self._api_server_url}/{VERSION_PREFIX}/workspace"
|
|
192
|
-
|
|
138
|
+
response = session_with_retries().post(
|
|
193
139
|
url,
|
|
194
140
|
json={
|
|
195
141
|
"manifest": {
|
|
@@ -200,8 +146,8 @@ class ServiceFoundryServiceClient:
|
|
|
200
146
|
},
|
|
201
147
|
headers=self._get_header(),
|
|
202
148
|
)
|
|
203
|
-
|
|
204
|
-
return Workspace.parse_obj(
|
|
149
|
+
response_data = request_handling(response)
|
|
150
|
+
return Workspace.parse_obj(response_data)
|
|
205
151
|
|
|
206
152
|
@check_min_cli_version
|
|
207
153
|
def remove_workspace(self, workspace_id, force=False) -> Workspace:
|
|
@@ -209,35 +155,37 @@ class ServiceFoundryServiceClient:
|
|
|
209
155
|
force = json.dumps(
|
|
210
156
|
force
|
|
211
157
|
) # this dumb conversion is required because `params` just casts as str
|
|
212
|
-
|
|
213
|
-
|
|
158
|
+
response = session_with_retries().delete(
|
|
159
|
+
url, headers=self._get_header(), params={"force": force}
|
|
160
|
+
)
|
|
161
|
+
response = request_handling(response)
|
|
214
162
|
return Workspace.parse_obj(response["workspace"])
|
|
215
163
|
|
|
216
164
|
@check_min_cli_version
|
|
217
165
|
def get_workspace_by_name(self, workspace_name, cluster_id):
|
|
218
166
|
url = f"{self._api_server_url}/{VERSION_PREFIX}/workspace"
|
|
219
|
-
|
|
167
|
+
response = session_with_retries().get(
|
|
220
168
|
url,
|
|
221
169
|
headers=self._get_header(),
|
|
222
170
|
params={"name": workspace_name, "clusterId": cluster_id},
|
|
223
171
|
)
|
|
224
|
-
return request_handling(
|
|
172
|
+
return request_handling(response)
|
|
225
173
|
|
|
226
174
|
@check_min_cli_version
|
|
227
175
|
def get_workspace(self, workspace_id):
|
|
228
176
|
url = f"{self._api_server_url}/{VERSION_PREFIX}/workspace/{workspace_id}"
|
|
229
|
-
|
|
230
|
-
return request_handling(
|
|
177
|
+
response = session_with_retries().get(url, headers=self._get_header())
|
|
178
|
+
return request_handling(response)
|
|
231
179
|
|
|
232
180
|
@check_min_cli_version
|
|
233
181
|
def get_workspace_by_fqn(self, workspace_fqn: str) -> List[Workspace]:
|
|
234
182
|
url = f"{self._api_server_url}/{VERSION_PREFIX}/workspace"
|
|
235
|
-
|
|
183
|
+
response = session_with_retries().get(
|
|
236
184
|
url,
|
|
237
185
|
headers=self._get_header(),
|
|
238
186
|
params={"fqn": workspace_fqn},
|
|
239
187
|
)
|
|
240
|
-
response = request_handling(
|
|
188
|
+
response = request_handling(response)
|
|
241
189
|
return parse_obj_as(List[Workspace], response)
|
|
242
190
|
|
|
243
191
|
@check_min_cli_version
|
|
@@ -246,25 +194,27 @@ class ServiceFoundryServiceClient:
|
|
|
246
194
|
params = {}
|
|
247
195
|
if workspace_id:
|
|
248
196
|
params["workspaceId"] = workspace_id
|
|
249
|
-
|
|
250
|
-
|
|
197
|
+
response = session_with_retries().get(
|
|
198
|
+
url=url, params=params, headers=self._get_header()
|
|
199
|
+
)
|
|
200
|
+
return request_handling(response)
|
|
251
201
|
|
|
252
202
|
@check_min_cli_version
|
|
253
203
|
def list_cluster(self):
|
|
254
204
|
url = f"{self._api_server_url}/{VERSION_PREFIX}/cluster"
|
|
255
|
-
|
|
256
|
-
return request_handling(
|
|
205
|
+
response = session_with_retries().get(url, headers=self._get_header())
|
|
206
|
+
return request_handling(response)
|
|
257
207
|
|
|
258
208
|
@check_min_cli_version
|
|
259
209
|
def get_cluster(self, cluster_id):
|
|
260
210
|
url = f"{self._api_server_url}/{VERSION_PREFIX}/cluster/{cluster_id}"
|
|
261
|
-
|
|
262
|
-
return request_handling(
|
|
211
|
+
response = session_with_retries().get(url, headers=self._get_header())
|
|
212
|
+
return request_handling(response)
|
|
263
213
|
|
|
264
214
|
@check_min_cli_version
|
|
265
215
|
def get_presigned_url(self, space_name, service_name, env):
|
|
266
216
|
url = f"{self._api_server_url}/{VERSION_PREFIX}/deployment/code-upload-url"
|
|
267
|
-
|
|
217
|
+
response = session_with_retries().post(
|
|
268
218
|
url,
|
|
269
219
|
json={
|
|
270
220
|
"workspaceFqn": space_name,
|
|
@@ -273,7 +223,7 @@ class ServiceFoundryServiceClient:
|
|
|
273
223
|
},
|
|
274
224
|
headers=self._get_header(),
|
|
275
225
|
)
|
|
276
|
-
return request_handling(
|
|
226
|
+
return request_handling(response)
|
|
277
227
|
|
|
278
228
|
@check_min_cli_version
|
|
279
229
|
def upload_code_package(
|
|
@@ -288,7 +238,7 @@ class ServiceFoundryServiceClient:
|
|
|
288
238
|
|
|
289
239
|
@check_min_cli_version
|
|
290
240
|
def deploy_application(
|
|
291
|
-
self, workspace_id: str, application:
|
|
241
|
+
self, workspace_id: str, application: auto_gen_models.Workflow
|
|
292
242
|
) -> Deployment:
|
|
293
243
|
data = {
|
|
294
244
|
"workspaceId": workspace_id,
|
|
@@ -297,7 +247,9 @@ class ServiceFoundryServiceClient:
|
|
|
297
247
|
}
|
|
298
248
|
logger.debug(json.dumps(data))
|
|
299
249
|
url = f"{self._api_server_url}/{VERSION_PREFIX}/deployment"
|
|
300
|
-
deploy_response =
|
|
250
|
+
deploy_response = session_with_retries().post(
|
|
251
|
+
url, json=data, headers=self._get_header()
|
|
252
|
+
)
|
|
301
253
|
response = request_handling(deploy_response)
|
|
302
254
|
return Deployment.parse_obj(response["deployment"])
|
|
303
255
|
|
|
@@ -359,27 +311,27 @@ class ServiceFoundryServiceClient:
|
|
|
359
311
|
@check_min_cli_version
|
|
360
312
|
def get_deployment(self, application_id: str, deployment_id: str) -> Deployment:
|
|
361
313
|
url = f"{self._api_server_url}/{VERSION_PREFIX}/app/{application_id}/deployments/{deployment_id}"
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
return Deployment.parse_obj(
|
|
314
|
+
response = session_with_retries().get(url, headers=self._get_header())
|
|
315
|
+
response_data = request_handling(response)
|
|
316
|
+
return Deployment.parse_obj(response_data)
|
|
365
317
|
|
|
366
318
|
@check_min_cli_version
|
|
367
319
|
def get_deployment_statuses(
|
|
368
320
|
self, application_id: str, deployment_id: str
|
|
369
321
|
) -> List[AppDeploymentStatusResponse]:
|
|
370
322
|
url = f"{self._api_server_url}/{VERSION_PREFIX}/app/{application_id}/deployments/{deployment_id}/statuses"
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
return parse_obj_as(List[AppDeploymentStatusResponse],
|
|
323
|
+
response = session_with_retries().get(url, headers=self._get_header())
|
|
324
|
+
response_data = request_handling(response)
|
|
325
|
+
return parse_obj_as(List[AppDeploymentStatusResponse], response_data)
|
|
374
326
|
|
|
375
327
|
@check_min_cli_version
|
|
376
328
|
def get_deployment_build_response(
|
|
377
329
|
self, application_id: str, deployment_id: str
|
|
378
330
|
) -> List[BuildResponse]:
|
|
379
331
|
url = f"{self._api_server_url}/{VERSION_PREFIX}/app/{application_id}/deployments/{deployment_id}/builds"
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
return parse_obj_as(List[BuildResponse],
|
|
332
|
+
response = session_with_retries().get(url, headers=self._get_header())
|
|
333
|
+
response_data = request_handling(response)
|
|
334
|
+
return parse_obj_as(List[BuildResponse], response_data)
|
|
383
335
|
|
|
384
336
|
def _get_deployment_logs(
|
|
385
337
|
self,
|
|
@@ -408,9 +360,11 @@ class ServiceFoundryServiceClient:
|
|
|
408
360
|
data["jobRunName"] = job_run_name
|
|
409
361
|
|
|
410
362
|
url = f"{self._api_server_url}/{VERSION_PREFIX}/logs/{workspace_id}"
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
363
|
+
response = session_with_retries().get(
|
|
364
|
+
url=url, params=data, headers=self._get_header()
|
|
365
|
+
)
|
|
366
|
+
response_data = request_handling(response)
|
|
367
|
+
return list(response_data["logs"])
|
|
414
368
|
|
|
415
369
|
@check_min_cli_version
|
|
416
370
|
def tail_build_logs(
|
|
@@ -546,8 +500,8 @@ class ServiceFoundryServiceClient:
|
|
|
546
500
|
) -> None:
|
|
547
501
|
callback = callback or OutputCallBack()
|
|
548
502
|
url = build_response.getLogsUrl
|
|
549
|
-
|
|
550
|
-
logs_list = request_handling(
|
|
503
|
+
response = session_with_retries().get(url=url, headers=self._get_header())
|
|
504
|
+
logs_list = request_handling(response)
|
|
551
505
|
for log in logs_list["logs"]:
|
|
552
506
|
# TODO: Have to establish a log line format that includes timestamp, level, message
|
|
553
507
|
callback.print_line(self._get_log_print_line(log))
|
|
@@ -555,36 +509,36 @@ class ServiceFoundryServiceClient:
|
|
|
555
509
|
@check_min_cli_version
|
|
556
510
|
def get_deployment_info_by_fqn(self, deployment_fqn: str) -> DeploymentFqnResponse:
|
|
557
511
|
url = f"{self._api_server_url}/{VERSION_PREFIX}/fqn/deployment"
|
|
558
|
-
|
|
512
|
+
response = session_with_retries().get(
|
|
559
513
|
url, headers=self._get_header(), params={"fqn": deployment_fqn}
|
|
560
514
|
)
|
|
561
|
-
|
|
562
|
-
return DeploymentFqnResponse.parse_obj(
|
|
515
|
+
response_data = request_handling(response)
|
|
516
|
+
return DeploymentFqnResponse.parse_obj(response_data)
|
|
563
517
|
|
|
564
518
|
@check_min_cli_version
|
|
565
519
|
def get_application_info_by_fqn(
|
|
566
520
|
self, application_fqn: str
|
|
567
521
|
) -> ApplicationFqnResponse:
|
|
568
522
|
url = f"{self._api_server_url}/{VERSION_PREFIX}/fqn/app"
|
|
569
|
-
|
|
523
|
+
response = session_with_retries().get(
|
|
570
524
|
url, headers=self._get_header(), params={"fqn": application_fqn}
|
|
571
525
|
)
|
|
572
|
-
|
|
573
|
-
return ApplicationFqnResponse.parse_obj(
|
|
526
|
+
response_data = request_handling(response)
|
|
527
|
+
return ApplicationFqnResponse.parse_obj(response_data)
|
|
574
528
|
|
|
575
529
|
@check_min_cli_version
|
|
576
530
|
def remove_application(self, application_id: str):
|
|
577
531
|
url = f"{self._api_server_url}/{VERSION_PREFIX}/app/{application_id}"
|
|
578
|
-
|
|
579
|
-
response = request_handling(
|
|
532
|
+
response = session_with_retries().delete(url, headers=self._get_header())
|
|
533
|
+
response = request_handling(response)
|
|
580
534
|
# TODO: Add pydantic here.
|
|
581
535
|
return response
|
|
582
536
|
|
|
583
537
|
@check_min_cli_version
|
|
584
538
|
def get_application_info(self, application_id: str) -> Application:
|
|
585
539
|
url = f"{self._api_server_url}/{VERSION_PREFIX}/app/{application_id}"
|
|
586
|
-
|
|
587
|
-
response = request_handling(
|
|
540
|
+
response = session_with_retries().get(url, headers=self._get_header())
|
|
541
|
+
response = request_handling(response)
|
|
588
542
|
return Application.parse_obj(response)
|
|
589
543
|
|
|
590
544
|
def list_job_runs(
|
|
@@ -602,9 +556,11 @@ class ServiceFoundryServiceClient:
|
|
|
602
556
|
params["offset"] = offset
|
|
603
557
|
if search_prefix:
|
|
604
558
|
params["searchPrefix"] = search_prefix
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
559
|
+
response = session_with_retries().get(
|
|
560
|
+
url, headers=self._get_header(), params=params
|
|
561
|
+
)
|
|
562
|
+
response_data = request_handling(response)
|
|
563
|
+
return parse_obj_as(List[JobRun], response_data["data"])
|
|
608
564
|
|
|
609
565
|
def get_job_run(
|
|
610
566
|
self,
|
|
@@ -612,9 +568,9 @@ class ServiceFoundryServiceClient:
|
|
|
612
568
|
job_run_name: str,
|
|
613
569
|
):
|
|
614
570
|
url = f"{self._api_server_url}/{VERSION_PREFIX}/jobs/{application_id}/runs/{job_run_name}"
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
return parse_obj_as(JobRun,
|
|
571
|
+
response = session_with_retries().get(url, headers=self._get_header())
|
|
572
|
+
response_data = request_handling(response)
|
|
573
|
+
return parse_obj_as(JobRun, response_data)
|
|
618
574
|
|
|
619
575
|
def trigger_job(
|
|
620
576
|
self,
|
|
@@ -631,14 +587,18 @@ class ServiceFoundryServiceClient:
|
|
|
631
587
|
body["input"]["command"] = command
|
|
632
588
|
if params:
|
|
633
589
|
body["input"]["params"] = params
|
|
634
|
-
|
|
635
|
-
|
|
590
|
+
response = session_with_retries().post(
|
|
591
|
+
url, json=body, headers=self._get_header()
|
|
592
|
+
)
|
|
593
|
+
response = request_handling(response)
|
|
636
594
|
return TriggerJobResult.parse_obj(response)
|
|
637
595
|
|
|
638
596
|
def trigger_workflow(self, application_id: str, inputs: Dict[str, Any]):
|
|
639
597
|
url = f"{self._api_server_url}/{VERSION_PREFIX}/workflow/{application_id}/executions"
|
|
640
|
-
|
|
641
|
-
|
|
598
|
+
response = session_with_retries().post(
|
|
599
|
+
url, json=inputs, headers=self._get_header()
|
|
600
|
+
)
|
|
601
|
+
response = request_handling(response)
|
|
642
602
|
return response
|
|
643
603
|
|
|
644
604
|
@check_min_cli_version
|
|
@@ -646,7 +606,7 @@ class ServiceFoundryServiceClient:
|
|
|
646
606
|
self, docker_registry_fqn: str, cluster_id: str
|
|
647
607
|
) -> DockerRegistryCredentials:
|
|
648
608
|
url = f"{self._api_server_url}/{VERSION_PREFIX}/docker-registry/creds"
|
|
649
|
-
|
|
609
|
+
response = session_with_retries().get(
|
|
650
610
|
url,
|
|
651
611
|
headers=self._get_header(),
|
|
652
612
|
params={
|
|
@@ -654,7 +614,7 @@ class ServiceFoundryServiceClient:
|
|
|
654
614
|
"clusterId": cluster_id,
|
|
655
615
|
},
|
|
656
616
|
)
|
|
657
|
-
response = request_handling(
|
|
617
|
+
response = request_handling(response)
|
|
658
618
|
return DockerRegistryCredentials.parse_obj(response)
|
|
659
619
|
|
|
660
620
|
@check_min_cli_version
|
|
@@ -662,7 +622,7 @@ class ServiceFoundryServiceClient:
|
|
|
662
622
|
self, docker_registry_fqn: str, workspace_fqn: str, application_name: str
|
|
663
623
|
) -> CreateDockerRepositoryResponse:
|
|
664
624
|
url = f"{self._api_server_url}/{VERSION_PREFIX}/docker-registry/create-repo"
|
|
665
|
-
|
|
625
|
+
response = session_with_retries().post(
|
|
666
626
|
url,
|
|
667
627
|
headers=self._get_header(),
|
|
668
628
|
data={
|
|
@@ -671,7 +631,7 @@ class ServiceFoundryServiceClient:
|
|
|
671
631
|
"applicationName": application_name,
|
|
672
632
|
},
|
|
673
633
|
)
|
|
674
|
-
response = request_handling(
|
|
634
|
+
response = request_handling(response)
|
|
675
635
|
return CreateDockerRepositoryResponse.parse_obj(response)
|
|
676
636
|
|
|
677
637
|
@check_min_cli_version
|
|
@@ -689,8 +649,10 @@ class ServiceFoundryServiceClient:
|
|
|
689
649
|
params["workspaceId"] = workspace_id
|
|
690
650
|
if application_name:
|
|
691
651
|
params["applicationName"] = application_name
|
|
692
|
-
|
|
693
|
-
|
|
652
|
+
response = session_with_retries().get(
|
|
653
|
+
url, params=params, headers=self._get_header()
|
|
654
|
+
)
|
|
655
|
+
response = request_handling(response)
|
|
694
656
|
return parse_obj_as(List[Application], response)
|
|
695
657
|
|
|
696
658
|
@check_min_cli_version
|
|
@@ -708,39 +670,38 @@ class ServiceFoundryServiceClient:
|
|
|
708
670
|
params["version"] = deployment_version
|
|
709
671
|
if deployment_id:
|
|
710
672
|
params["deploymentId"] = deployment_id
|
|
711
|
-
|
|
712
|
-
|
|
673
|
+
response = session_with_retries().get(
|
|
674
|
+
url, params=params, headers=self._get_header()
|
|
675
|
+
)
|
|
676
|
+
response = request_handling(response)
|
|
713
677
|
return parse_obj_as(List[Deployment], response)
|
|
714
678
|
|
|
715
679
|
@check_min_cli_version
|
|
716
|
-
def
|
|
717
|
-
url = f"{self._api_server_url}/{VERSION_PREFIX}/oauth/api-key/token"
|
|
718
|
-
data = {"apiKey": api_key}
|
|
719
|
-
res = requests.get(url, params=data)
|
|
720
|
-
res = request_handling(res)
|
|
721
|
-
return Token.parse_obj(res)
|
|
722
|
-
|
|
723
|
-
@check_min_cli_version
|
|
724
|
-
def apply(self, manifest: Dict[str, Any]) -> None:
|
|
680
|
+
def apply(self, manifest: Dict[str, Any]):
|
|
725
681
|
url = f"{self._api_server_url}/{VERSION_PREFIX}/apply"
|
|
726
682
|
body = {"manifest": manifest}
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
683
|
+
response = session_with_retries().put(
|
|
684
|
+
url, headers=self._get_header(), json=body
|
|
685
|
+
)
|
|
686
|
+
response_data = request_handling(response)
|
|
687
|
+
return response_data
|
|
730
688
|
|
|
731
689
|
def terminate_job_run(
|
|
732
690
|
self,
|
|
733
691
|
deployment_id: str,
|
|
734
692
|
job_run_name: str,
|
|
735
|
-
callback=None,
|
|
736
693
|
):
|
|
737
|
-
|
|
738
|
-
url = f"{self._api_server_url}/{VERSION_PREFIX}/jobs/terminate?deploymentId={deployment_id}&jobRunName={job_run_name}"
|
|
694
|
+
url = f"{self._api_server_url}/{VERSION_PREFIX}/jobs/terminate"
|
|
739
695
|
body = {
|
|
740
696
|
"deploymentId": deployment_id,
|
|
741
697
|
"jobRunName": job_run_name,
|
|
742
698
|
}
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
699
|
+
response = session_with_retries().post(
|
|
700
|
+
url,
|
|
701
|
+
# TODO (chiragjn): Check if this is supposed to be params or json
|
|
702
|
+
params=body,
|
|
703
|
+
json=body,
|
|
704
|
+
headers=self._get_header(),
|
|
705
|
+
)
|
|
706
|
+
response_data = request_handling(response)
|
|
707
|
+
return response_data
|
truefoundry/deploy/lib/const.py
CHANGED
|
@@ -1,43 +1,9 @@
|
|
|
1
|
-
from pathlib import Path
|
|
2
|
-
|
|
3
1
|
from truefoundry.deploy.io.rich_output_callback import RichOutputCallBack
|
|
4
2
|
|
|
5
|
-
DEFAULT_BASE_URL = "https://app.truefoundry.com"
|
|
6
|
-
API_SERVER_RELATIVE_PATH = "api/svc"
|
|
7
|
-
DEFAULT_API_SERVER = f"{DEFAULT_BASE_URL.rstrip('/')}/{API_SERVER_RELATIVE_PATH}"
|
|
8
|
-
DEFAULT_AUTH_UI = DEFAULT_BASE_URL
|
|
9
|
-
DEFAULT_AUTH_SERVER = (
|
|
10
|
-
"https://auth-server.tfy-ctl-euwe1-production.production.truefoundry.com"
|
|
11
|
-
)
|
|
12
|
-
DEFAULT_TENANT_NAME = "truefoundry"
|
|
13
|
-
DEFAULT_PROFILE_NAME = "default"
|
|
14
|
-
HOST_ENV_NAME = "TFY_HOST"
|
|
15
|
-
API_KEY_ENV_NAME = "TFY_API_KEY"
|
|
16
|
-
|
|
17
|
-
_SFY_CONFIG_DIR = Path.home() / ".truefoundry"
|
|
18
|
-
SFY_CONFIG_DIR = str(_SFY_CONFIG_DIR) # as a directory
|
|
19
|
-
CREDENTIAL_FILEPATH = _SFY_CONFIG_DIR / "credentials.json"
|
|
20
|
-
|
|
21
|
-
OLD_SFY_PROFILES_FILEPATH = _SFY_CONFIG_DIR / "profiles.json" # as a directory
|
|
22
|
-
OLD_SFY_SESSIONS_FILEPATH = _SFY_CONFIG_DIR / "sessions.json" # as a directory
|
|
23
|
-
OLD_SESSION_FILEPATH = str(
|
|
24
|
-
Path.home() / ".truefoundry"
|
|
25
|
-
) # as a filepath, to be removed in future versions
|
|
26
|
-
|
|
27
|
-
# Polling during login redirect
|
|
28
|
-
MAX_POLLING_RETRY = 100
|
|
29
|
-
POLLING_SLEEP_TIME_IN_SEC = 4
|
|
30
|
-
|
|
31
|
-
# Refresh access token cutoff
|
|
32
|
-
REFRESH_ACCESS_TOKEN_IN_SEC = 10 * 60
|
|
33
|
-
|
|
34
3
|
ENTITY_JSON_DATETIME_FORMAT = "%Y-%m-%dT%H:%M:%S.%fZ"
|
|
35
4
|
RICH_OUTPUT_CALLBACK = RichOutputCallBack()
|
|
36
5
|
|
|
37
|
-
VERSION_PREFIX = "v1"
|
|
38
|
-
|
|
39
6
|
SFY_DEBUG_ENV_KEY = "SFY_DEBUG"
|
|
40
|
-
SFY_INTERNAL_ENV_KEY = "SFY_INTERNAL"
|
|
41
|
-
|
|
42
7
|
TFY_DEBUG_ENV_KEY = "TFY_DEBUG"
|
|
8
|
+
SFY_INTERNAL_ENV_KEY = "SFY_INTERNAL"
|
|
43
9
|
TFY_INTERNAL_ENV_KEY = "TFY_INTERNAL"
|
|
@@ -1,19 +1,6 @@
|
|
|
1
1
|
from typing import Optional
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
class BadRequestException(Exception):
|
|
5
|
-
def __init__(self, status_code: int, message: Optional[str] = None):
|
|
6
|
-
super().__init__()
|
|
7
|
-
self.status_code = status_code
|
|
8
|
-
self.message = message
|
|
9
|
-
|
|
10
|
-
def __str__(self):
|
|
11
|
-
return self.message
|
|
12
|
-
|
|
13
|
-
def __repr__(self):
|
|
14
|
-
return self.message
|
|
15
|
-
|
|
16
|
-
|
|
17
4
|
class ConfigurationException(Exception):
|
|
18
5
|
def __init__(self, message: Optional[str] = None):
|
|
19
6
|
super().__init__()
|
|
@@ -21,6 +8,3 @@ class ConfigurationException(Exception):
|
|
|
21
8
|
|
|
22
9
|
def __str__(self):
|
|
23
10
|
return self.message
|
|
24
|
-
|
|
25
|
-
def __repr__(self):
|
|
26
|
-
return self.message
|