thestage 0.6.6__py3-none-any.whl → 0.6.8__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.
- thestage/__init__.py +1 -1
- thestage/cli_command_helper.py +2 -2
- thestage/config/__init__.py +1 -1
- thestage/{services → config/business}/app_config_service.py +3 -4
- thestage/{services/config_provider → config/business}/config_provider.py +6 -5
- thestage/config/{config_storage.py → business/config_storage.py} +1 -1
- thestage/{services → config/business}/validation_service.py +9 -10
- thestage/{controllers/config_controller.py → config/communication/config_command.py} +7 -7
- thestage/{services/connect → connect/business}/connect_service.py +25 -22
- thestage/{services → connect/business}/remote_server_service.py +4 -5
- thestage/connect/communication/connect_api_client.py +84 -0
- thestage/{services/clients/thestage_api/dtos/ssh_key_controller → connect/dto}/add_ssh_key_to_user_response.py +0 -1
- thestage/{services/clients/thestage_api/dtos/ssh_key_controller → connect/dto}/add_ssh_public_key_to_instance_response.py +1 -4
- thestage/{services/clients/thestage_api/dtos/base_controller → connect/dto}/connect_resolve_response.py +1 -1
- thestage/controllers/base_controller.py +2 -2
- thestage/debug_main.dist.py +16 -14
- thestage/{services/container → docker_container/business}/container_service.py +120 -40
- thestage/{services/container → docker_container/business}/mapper/container_mapper.py +3 -3
- thestage/docker_container/communication/__init__.py +0 -0
- thestage/{controllers/container_controller.py → docker_container/communication/docker_command.py} +27 -86
- thestage/docker_container/communication/docker_container_api_client.py +99 -0
- thestage/docker_container/dto/__init__.py +0 -0
- thestage/docker_container/dto/container_action_request.py +11 -0
- thestage/{services/clients/thestage_api/dtos → docker_container/dto}/container_response.py +4 -4
- thestage/{services/clients/thestage_api/dtos/docker_container_controller → docker_container/dto}/docker_container_list_response.py +3 -5
- thestage/docker_container/dto/enum/__init__.py +0 -0
- thestage/git/__init__.py +0 -0
- thestage/git/business/__init__.py +0 -0
- thestage/git/communication/__init__.py +0 -0
- thestage/{services/clients/git → git/communication}/git_client.py +5 -5
- thestage/global_dto/__init__.py +0 -0
- thestage/global_dto/enums/__init__.py +0 -0
- thestage/helpers/error_handler.py +5 -5
- thestage/helpers/logger/app_logger.py +1 -3
- thestage/i18n/en_GB/messages.po +14 -14
- thestage/inference_model/__init__.py +0 -0
- thestage/inference_model/business/__init__.py +0 -0
- thestage/inference_model/business/inference_model_service.py +281 -0
- thestage/inference_model/business/mapper/__init__.py +0 -0
- thestage/{services/project/mapper/project_inference_simulator_model_mapper.py → inference_model/business/mapper/inference_model_mapper.py} +5 -5
- thestage/inference_model/communication/__init__.py +0 -0
- thestage/inference_model/communication/inference_model_api_client.py +139 -0
- thestage/inference_model/communication/inference_model_command.py +246 -0
- thestage/inference_model/dto/__init__.py +0 -0
- thestage/{services/clients/thestage_api/dtos/inference_controller → inference_model/dto}/deploy_inference_model_to_instance_request.py +0 -2
- thestage/{services/clients/thestage_api/dtos/inference_controller → inference_model/dto}/deploy_inference_model_to_instance_response.py +2 -1
- thestage/inference_model/dto/enum/__init__.py +0 -0
- thestage/{services/project/dto/inference_simulator_model_dto.py → inference_model/dto/inference_model.py} +1 -1
- thestage/{entities/project_inference_simulator_model.py → inference_model/dto/inference_model_entity.py} +2 -2
- thestage/{services/clients/thestage_api/dtos/inference_controller → inference_model/dto}/inference_simulator_model_list_for_project_response.py +2 -3
- thestage/{services/clients/thestage_api/dtos/project_controller/project_push_inference_simulator_model_request.py → inference_model/dto/push_inference_simulator_model_request.py} +1 -1
- thestage/{services/clients/thestage_api/dtos/project_controller/project_push_inference_simulator_model_response.py → inference_model/dto/push_inference_simulator_model_response.py} +1 -1
- thestage/inference_simulator/__init__.py +0 -0
- thestage/inference_simulator/business/__init__.py +0 -0
- thestage/inference_simulator/business/inference_simulator_service.py +338 -0
- thestage/inference_simulator/business/mapper/__init__.py +0 -0
- thestage/{services/project/mapper/project_inference_simulator_mapper.py → inference_simulator/business/mapper/inference_simulator_mapper.py} +5 -5
- thestage/inference_simulator/communication/__init__.py +0 -0
- thestage/inference_simulator/communication/inference_simulator_api_client.py +114 -0
- thestage/inference_simulator/communication/inference_simulator_command.py +347 -0
- thestage/inference_simulator/dto/__init__.py +0 -0
- thestage/inference_simulator/dto/enum/__init__.py +0 -0
- thestage/{services/clients/thestage_api/dtos/inference_controller → inference_simulator/dto}/get_inference_simulator_request.py +1 -1
- thestage/inference_simulator/dto/get_inference_simulator_response.py +12 -0
- thestage/{services/project/dto/inference_simulator_dto.py → inference_simulator/dto/inference_simulator.py} +1 -1
- thestage/{entities/project_inference_simulator.py → inference_simulator/dto/inference_simulator_entity.py} +1 -1
- thestage/{services/clients/thestage_api/dtos/inference_controller → inference_simulator/dto}/inference_simulator_list_response.py +2 -2
- thestage/{services/clients/thestage_api/dtos/project_controller/project_start_inference_simulator_request.py → inference_simulator/dto/start_inference_simulator_request.py} +1 -1
- thestage/inference_simulator/dto/start_inference_simulator_response.py +10 -0
- thestage/instance/__init__.py +0 -0
- thestage/instance/business/__init__.py +0 -0
- thestage/{services/instance → instance/business}/instance_service.py +26 -27
- thestage/instance/business/mapper/__init__.py +0 -0
- thestage/{services/instance/mapper/instance_mapper.py → instance/business/mapper/rented_instance_mapper.py} +3 -3
- thestage/{services/instance/mapper/selfhosted_mapper.py → instance/business/mapper/selfhosted_instance_mapper.py} +5 -7
- thestage/instance/communication/__init__.py +0 -0
- thestage/instance/communication/instance_api_client.py +150 -0
- thestage/{controllers/instance_controller.py → instance/communication/instance_command.py} +9 -9
- thestage/instance/dto/__init__.py +0 -0
- thestage/instance/dto/enum/__init__.py +0 -0
- thestage/{services/clients/thestage_api/dtos → instance/dto}/instance_detected_gpus.py +1 -2
- thestage/{services/clients/thestage_api/dtos → instance/dto}/instance_rented_response.py +2 -2
- thestage/{services/clients/thestage_api/dtos → instance/dto}/selfhosted_instance_response.py +2 -3
- thestage/logging/__init__.py +0 -0
- thestage/logging/business/__init__.py +0 -0
- thestage/{services/logging → logging/business}/logging_service.py +45 -36
- thestage/logging/communication/__init__.py +0 -0
- thestage/logging/communication/logging_api_client.py +63 -0
- thestage/logging/dto/__init__.py +0 -0
- thestage/{services/clients/thestage_api/dtos/logging_controller → logging/dto}/log_polling_response.py +2 -2
- thestage/{services/clients/thestage_api/dtos/logging_controller → logging/dto}/user_logs_query_response.py +2 -2
- thestage/main.py +48 -9
- thestage/project/__init__.py +0 -0
- thestage/project/business/__init__.py +0 -0
- thestage/project/business/project_service.py +480 -0
- thestage/project/communication/__init__.py +0 -0
- thestage/project/communication/project_api_client.py +46 -0
- thestage/project/communication/project_command.py +284 -0
- thestage/project/dto/__init__.py +0 -0
- thestage/{services/project → project}/dto/project_config.py +1 -2
- thestage/services/clients/thestage_api/core/api_client_core.py +1 -1
- thestage/services/clients/thestage_api/dtos/entity_filter_request.py +1 -1
- thestage/services/clients/thestage_api/dtos/sftp_path_helper.py +1 -1
- thestage/services/filesystem_service.py +2 -2
- thestage/services/service_factory.py +130 -43
- thestage/task/__init__.py +0 -0
- thestage/task/business/__init__.py +0 -0
- thestage/task/business/mapper/__init__.py +0 -0
- thestage/{services/project/mapper/project_task_mapper.py → task/business/mapper/task_mapper.py} +5 -5
- thestage/task/business/task_service.py +304 -0
- thestage/task/communication/__init__.py +0 -0
- thestage/task/communication/task_api_client.py +122 -0
- thestage/task/communication/task_command.py +212 -0
- thestage/task/dto/__init__.py +0 -0
- thestage/task/dto/enum/__init__.py +0 -0
- thestage/{services/clients/thestage_api/dtos/task_controller/task_list_for_project_response.py → task/dto/list_for_project_response.py} +2 -2
- thestage/{services/clients/thestage_api/dtos/project_controller/project_run_task_request.py → task/dto/run_task_request.py} +1 -1
- thestage/task/dto/run_task_response.py +13 -0
- thestage/{services/task/dto/task_dto.py → task/dto/task.py} +1 -4
- thestage/{entities/project_task.py → task/dto/task_entity.py} +1 -1
- thestage/{services/clients/thestage_api/dtos/task_controller/task_view_response.py → task/dto/view_response.py} +2 -2
- {thestage-0.6.6.dist-info → thestage-0.6.8.dist-info}/METADATA +2 -1
- thestage-0.6.8.dist-info/RECORD +219 -0
- {thestage-0.6.6.dist-info → thestage-0.6.8.dist-info}/WHEEL +1 -1
- thestage/controllers/project_controller.py +0 -1058
- thestage/services/clients/thestage_api/api_client.py +0 -753
- thestage/services/clients/thestage_api/dtos/container_param_request.py +0 -11
- thestage/services/clients/thestage_api/dtos/inference_controller/get_inference_simulator_response.py +0 -13
- thestage/services/clients/thestage_api/dtos/project_controller/project_run_task_response.py +0 -10
- thestage/services/clients/thestage_api/dtos/project_controller/project_start_inference_simulator_response.py +0 -10
- thestage/services/clients/thestage_api/dtos/user_controller/user_profile.py +0 -12
- thestage/services/project/project_service.py +0 -1283
- thestage-0.6.6.dist-info/RECORD +0 -167
- /thestage/{entities → color_scheme}/__init__.py +0 -0
- /thestage/{entities/enums → config/business}/__init__.py +0 -0
- /thestage/{services/clients/git → config/communication}/__init__.py +0 -0
- /thestage/{services/clients/thestage_api/dtos/enums → config/dto}/__init__.py +0 -0
- /thestage/{services/core_files → config/dto}/config_entity.py +0 -0
- /thestage/{services/connect → config}/dto/remote_server_config.py +0 -0
- /thestage/{services/config_provider → connect}/__init__.py +0 -0
- /thestage/{services/container → connect/business}/__init__.py +0 -0
- /thestage/{services/container/mapper → connect/communication}/__init__.py +0 -0
- /thestage/{services/instance → connect/dto}/__init__.py +0 -0
- /thestage/{services/clients/thestage_api/dtos/ssh_key_controller → connect/dto}/add_ssh_key_to_user_request.py +0 -0
- /thestage/{services/clients/thestage_api/dtos/ssh_key_controller → connect/dto}/add_ssh_public_key_to_instance_request.py +0 -0
- /thestage/{services/clients/thestage_api/dtos/ssh_key_controller → connect/dto}/is_user_has_public_ssh_key_request.py +0 -0
- /thestage/{services/clients/thestage_api/dtos/ssh_key_controller → connect/dto}/is_user_has_public_ssh_key_response.py +0 -0
- /thestage/{services/instance/mapper → docker_container}/__init__.py +0 -0
- /thestage/{services/project → docker_container/business}/__init__.py +0 -0
- /thestage/{services/project → docker_container/business}/mapper/__init__.py +0 -0
- /thestage/{entities/container.py → docker_container/dto/container_entity.py} +0 -0
- /thestage/{services/clients/thestage_api/dtos/docker_container_controller → docker_container/dto}/docker_container_list_request.py +0 -0
- /thestage/{services/clients/thestage_api/dtos → docker_container/dto}/docker_container_mapping.py +0 -0
- /thestage/{services/clients/thestage_api/dtos/enums → docker_container/dto/enum}/container_pending_action.py +0 -0
- /thestage/{services/clients/thestage_api/dtos/enums → docker_container/dto/enum}/container_status.py +0 -0
- /thestage/{services/logging/exception → exceptions}/log_polling_exception.py +0 -0
- /thestage/git/{ProgressPrinter.py → business/ProgressPrinter.py} +0 -0
- /thestage/{entities → global_dto}/enums/order_direction_type.py +0 -0
- /thestage/{entities → global_dto}/enums/shell_type.py +0 -0
- /thestage/{entities → global_dto}/enums/tail_output_type.py +0 -0
- /thestage/{entities → global_dto}/enums/yes_no_response.py +0 -0
- /thestage/{entities → global_dto}/file_item.py +0 -0
- /thestage/{services/clients/thestage_api/dtos/inference_controller → inference_model/dto}/deploy_inference_model_to_sagemaker_request.py +0 -0
- /thestage/{services/clients/thestage_api/dtos/inference_controller → inference_model/dto}/deploy_inference_model_to_sagemaker_response.py +0 -0
- /thestage/{services/clients/thestage_api/dtos/enums → inference_model/dto/enum}/inference_model_status.py +0 -0
- /thestage/{services/clients/thestage_api/dtos/inference_controller → inference_model/dto}/inference_simulator_model_list_for_project_request.py +0 -0
- /thestage/{services/clients/thestage_api/dtos → inference_model/dto}/inference_simulator_model_response.py +0 -0
- /thestage/{services/clients/thestage_api/dtos/enums → inference_simulator/dto/enum}/inference_simulator_status.py +0 -0
- /thestage/{services/clients/thestage_api/dtos/inference_controller → inference_simulator/dto}/inference_simulator_list_request.py +0 -0
- /thestage/{services/clients/thestage_api/dtos → inference_simulator/dto}/inference_simulator_response.py +0 -0
- /thestage/{services/clients/thestage_api/dtos/enums → instance/dto/enum}/cpu_type.py +0 -0
- /thestage/{services/clients/thestage_api/dtos/enums → instance/dto/enum}/gpu_name.py +0 -0
- /thestage/{services/clients/thestage_api/dtos/enums → instance/dto/enum}/instance_rented_status.py +0 -0
- /thestage/{services/clients/thestage_api/dtos/enums → instance/dto/enum}/provider_name.py +0 -0
- /thestage/{services/clients/thestage_api/dtos/enums → instance/dto/enum}/selfhosted_status.py +0 -0
- /thestage/{entities → instance/dto}/rented_instance.py +0 -0
- /thestage/{entities → instance/dto}/self_hosted_instance.py +0 -0
- /thestage/{services/logging → logging}/byte_print_style.py +0 -0
- /thestage/{services/clients/thestage_api/dtos/logging_controller → logging/dto}/docker_container_log_stream_request.py +0 -0
- /thestage/{services/logging → logging}/dto/log_message.py +0 -0
- /thestage/{services/clients/thestage_api/dtos/logging_controller → logging/dto}/log_polling_request.py +0 -0
- /thestage/{services/logging → logging}/dto/log_type.py +0 -0
- /thestage/{services/clients/thestage_api/dtos/logging_controller → logging/dto}/task_log_stream_request.py +0 -0
- /thestage/{services/clients/thestage_api/dtos/logging_controller → logging/dto}/user_logs_query_request.py +0 -0
- /thestage/{services/logging → logging}/logging_constants.py +0 -0
- /thestage/{services/clients/thestage_api/dtos/project_controller/project_get_deploy_ssh_key_request.py → project/dto/get_deploy_ssh_key_request.py} +0 -0
- /thestage/{services/clients/thestage_api/dtos/project_controller/project_get_deploy_ssh_key_response.py → project/dto/get_deploy_ssh_key_response.py} +0 -0
- /thestage/{services/clients/thestage_api/dtos → project/dto}/project_response.py +0 -0
- /thestage/{services/clients/thestage_api/dtos/enums → task/dto/enum}/task_execution_status.py +0 -0
- /thestage/{services/clients/thestage_api/dtos/enums → task/dto/enum}/task_status.py +0 -0
- /thestage/{services/clients/thestage_api/dtos/task_controller/task_list_for_project_request.py → task/dto/list_for_project_request.py} +0 -0
- /thestage/{services/clients/thestage_api/dtos/task_controller/task_status_localized_map_response.py → task/dto/status_localized_map_response.py} +0 -0
- {thestage-0.6.6.dist-info → thestage-0.6.8.dist-info}/entry_points.txt +0 -0
- {thestage-0.6.6.dist-info → thestage-0.6.8.dist-info}/licenses/LICENSE.txt +0 -0
|
@@ -1,37 +1,36 @@
|
|
|
1
1
|
from pathlib import Path
|
|
2
|
-
from typing import List, Optional
|
|
2
|
+
from typing import List, Optional
|
|
3
3
|
|
|
4
4
|
import typer
|
|
5
5
|
|
|
6
|
-
from thestage.
|
|
7
|
-
from thestage.
|
|
6
|
+
from thestage.instance.communication.instance_api_client import InstanceApiClient
|
|
7
|
+
from thestage.instance.dto.rented_instance import RentedInstanceEntity
|
|
8
|
+
from thestage.instance.dto.self_hosted_instance import SelfHostedInstanceEntity
|
|
8
9
|
from thestage.i18n.translation import __
|
|
9
|
-
from thestage.
|
|
10
|
-
from thestage.
|
|
10
|
+
from thestage.instance.dto.enum.selfhosted_status import SelfhostedBusinessStatus
|
|
11
|
+
from thestage.instance.dto.enum.instance_rented_status import InstanceRentedBusinessStatus
|
|
11
12
|
from thestage.services.abstract_service import AbstractService
|
|
12
13
|
from thestage.helpers.error_handler import error_handler
|
|
13
|
-
from thestage.
|
|
14
|
-
from thestage.services.clients.thestage_api.dtos.instance_rented_response import InstanceRentedDto
|
|
14
|
+
from thestage.instance.dto.instance_rented_response import InstanceRentedDto
|
|
15
15
|
from thestage.services.clients.thestage_api.dtos.paginated_entity_list import PaginatedEntityList
|
|
16
|
-
from thestage.
|
|
17
|
-
from thestage.
|
|
18
|
-
from thestage.
|
|
19
|
-
from thestage.
|
|
20
|
-
from thestage.
|
|
16
|
+
from thestage.instance.dto.selfhosted_instance_response import SelfHostedInstanceDto
|
|
17
|
+
from thestage.config.business.config_provider import ConfigProvider
|
|
18
|
+
from thestage.instance.business.mapper.rented_instance_mapper import RentedInstanceMapper
|
|
19
|
+
from thestage.instance.business.mapper.selfhosted_instance_mapper import SelfHostedInstanceMapper
|
|
20
|
+
from thestage.connect.business.remote_server_service import RemoteServerService
|
|
21
21
|
|
|
22
22
|
|
|
23
23
|
class InstanceService(AbstractService):
|
|
24
|
-
|
|
25
|
-
__thestage_api_client: TheStageApiClient = None
|
|
24
|
+
__instance_api_client: InstanceApiClient = None
|
|
26
25
|
__config_provider: ConfigProvider = None
|
|
27
26
|
|
|
28
27
|
def __init__(
|
|
29
28
|
self,
|
|
30
|
-
|
|
29
|
+
instance_api_client: InstanceApiClient,
|
|
31
30
|
config_provider: ConfigProvider,
|
|
32
31
|
remote_server_service: RemoteServerService,
|
|
33
32
|
):
|
|
34
|
-
self.
|
|
33
|
+
self.__instance_api_client = instance_api_client
|
|
35
34
|
self.__remote_server_service = remote_server_service
|
|
36
35
|
self.__config_provider = config_provider
|
|
37
36
|
|
|
@@ -54,7 +53,7 @@ class InstanceService(AbstractService):
|
|
|
54
53
|
InstanceRentedBusinessStatus.TERMINATING.name,
|
|
55
54
|
InstanceRentedBusinessStatus.RENTAL_ERROR.name,
|
|
56
55
|
]:
|
|
57
|
-
typer.echo(__('Cannot connect to rented server instance: renting
|
|
56
|
+
typer.echo(__('Cannot connect to rented server instance: renting failed'))
|
|
58
57
|
raise typer.Exit(1)
|
|
59
58
|
elif instance.frontend_status.status_key in [
|
|
60
59
|
InstanceRentedBusinessStatus.STOPPED.name,
|
|
@@ -105,7 +104,7 @@ class InstanceService(AbstractService):
|
|
|
105
104
|
instance_rented_slug: Optional[str],
|
|
106
105
|
input_ssh_key_path: Optional[str]
|
|
107
106
|
):
|
|
108
|
-
instance = self.
|
|
107
|
+
instance = self.__instance_api_client.get_rented_instance(
|
|
109
108
|
instance_public_id=instance_rented_public_id,
|
|
110
109
|
instance_slug=instance_rented_slug,
|
|
111
110
|
)
|
|
@@ -119,7 +118,7 @@ class InstanceService(AbstractService):
|
|
|
119
118
|
if not input_ssh_key_path:
|
|
120
119
|
ssh_path_from_config = self.__config_provider.get_valid_private_key_path_by_ip_address(instance.ip_address)
|
|
121
120
|
if ssh_path_from_config:
|
|
122
|
-
typer.echo(f"Using configured
|
|
121
|
+
typer.echo(f"Using configured SSH key for this instance: {ssh_path_from_config}")
|
|
123
122
|
|
|
124
123
|
if not input_ssh_key_path and not ssh_path_from_config:
|
|
125
124
|
typer.echo('Using SSH agent to connect to server instance')
|
|
@@ -149,7 +148,7 @@ class InstanceService(AbstractService):
|
|
|
149
148
|
username = 'root'
|
|
150
149
|
typer.echo(__("No remote server username provided, using 'root' as username"))
|
|
151
150
|
|
|
152
|
-
instance = self.
|
|
151
|
+
instance = self.__instance_api_client.get_selfhosted_instance(
|
|
153
152
|
instance_public_id=selfhosted_instance_public_id,
|
|
154
153
|
instance_slug=selfhosted_instance_slug,
|
|
155
154
|
)
|
|
@@ -163,7 +162,7 @@ class InstanceService(AbstractService):
|
|
|
163
162
|
if not input_ssh_key_path:
|
|
164
163
|
ssh_path_from_config = self.__config_provider.get_valid_private_key_path_by_ip_address(instance.ip_address)
|
|
165
164
|
if ssh_path_from_config:
|
|
166
|
-
typer.echo(f"Using configured
|
|
165
|
+
typer.echo(f"Using configured SSH key for this instance: {ssh_path_from_config}")
|
|
167
166
|
|
|
168
167
|
if not input_ssh_key_path and not ssh_path_from_config:
|
|
169
168
|
typer.echo('Using SSH agent to connect to server instance')
|
|
@@ -187,7 +186,7 @@ class InstanceService(AbstractService):
|
|
|
187
186
|
row: int = 5,
|
|
188
187
|
page: int = 1,
|
|
189
188
|
) -> PaginatedEntityList[InstanceRentedDto]:
|
|
190
|
-
data = self.
|
|
189
|
+
data = self.__instance_api_client.get_rented_instance_list(
|
|
191
190
|
statuses=statuses,
|
|
192
191
|
page=page,
|
|
193
192
|
limit=row,
|
|
@@ -202,7 +201,7 @@ class InstanceService(AbstractService):
|
|
|
202
201
|
row: int = 5,
|
|
203
202
|
page: int = 1,
|
|
204
203
|
) -> PaginatedEntityList[SelfHostedInstanceDto]:
|
|
205
|
-
data = self.
|
|
204
|
+
data = self.__instance_api_client.get_selfhosted_instance_list(
|
|
206
205
|
statuses=statuses,
|
|
207
206
|
page=page,
|
|
208
207
|
limit=row,
|
|
@@ -212,7 +211,7 @@ class InstanceService(AbstractService):
|
|
|
212
211
|
|
|
213
212
|
@error_handler()
|
|
214
213
|
def print_self_hosted_instance_list(self, statuses, row, page):
|
|
215
|
-
selfhosted_instance_status_map = self.
|
|
214
|
+
selfhosted_instance_status_map = self.__instance_api_client.get_selfhosted_business_status_map()
|
|
216
215
|
|
|
217
216
|
if not statuses:
|
|
218
217
|
statuses = ({key: selfhosted_instance_status_map[key] for key in [
|
|
@@ -245,7 +244,7 @@ class InstanceService(AbstractService):
|
|
|
245
244
|
func_special_params={
|
|
246
245
|
'statuses': backend_statuses,
|
|
247
246
|
},
|
|
248
|
-
mapper=
|
|
247
|
+
mapper=SelfHostedInstanceMapper(),
|
|
249
248
|
headers=list(map(lambda x: x.alias, SelfHostedInstanceEntity.model_fields.values())),
|
|
250
249
|
row=row,
|
|
251
250
|
page=page,
|
|
@@ -255,7 +254,7 @@ class InstanceService(AbstractService):
|
|
|
255
254
|
|
|
256
255
|
@error_handler()
|
|
257
256
|
def print_rented_instance_list(self, statuses, row, page):
|
|
258
|
-
instance_rented_status_map = self.
|
|
257
|
+
instance_rented_status_map = self.__instance_api_client.get_rented_business_status_map()
|
|
259
258
|
|
|
260
259
|
if not statuses:
|
|
261
260
|
statuses = ({key: instance_rented_status_map[key] for key in [
|
|
@@ -289,7 +288,7 @@ class InstanceService(AbstractService):
|
|
|
289
288
|
func_special_params={
|
|
290
289
|
'statuses': backend_statuses,
|
|
291
290
|
},
|
|
292
|
-
mapper=
|
|
291
|
+
mapper=RentedInstanceMapper(),
|
|
293
292
|
headers=list(map(lambda x: x.alias, RentedInstanceEntity.model_fields.values())),
|
|
294
293
|
row=row,
|
|
295
294
|
page=page,
|
|
File without changes
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
from typing import Optional
|
|
2
2
|
|
|
3
|
-
from thestage.
|
|
4
|
-
from thestage.
|
|
3
|
+
from thestage.instance.dto.rented_instance import RentedInstanceEntity
|
|
4
|
+
from thestage.instance.dto.instance_rented_response import InstanceRentedDto
|
|
5
5
|
from thestage.services.abstract_mapper import AbstractMapper
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
class
|
|
8
|
+
class RentedInstanceMapper(AbstractMapper):
|
|
9
9
|
|
|
10
10
|
def build_entity(self, item: InstanceRentedDto) -> Optional[RentedInstanceEntity]:
|
|
11
11
|
if not item:
|
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
from
|
|
2
|
-
from typing import Optional, Any, Tuple
|
|
1
|
+
from typing import Optional
|
|
3
2
|
|
|
4
|
-
from thestage.
|
|
5
|
-
from thestage.
|
|
6
|
-
from thestage.
|
|
7
|
-
from thestage.services.clients.thestage_api.dtos.selfhosted_instance_response import SelfHostedInstanceDto
|
|
3
|
+
from thestage.instance.dto.self_hosted_instance import SelfHostedInstanceEntity
|
|
4
|
+
from thestage.instance.dto.enum.gpu_name import InstanceGpuType
|
|
5
|
+
from thestage.instance.dto.selfhosted_instance_response import SelfHostedInstanceDto
|
|
8
6
|
from thestage.services.abstract_mapper import AbstractMapper
|
|
9
7
|
|
|
10
8
|
|
|
11
|
-
class
|
|
9
|
+
class SelfHostedInstanceMapper(AbstractMapper):
|
|
12
10
|
|
|
13
11
|
def build_entity(self, item: SelfHostedInstanceDto) -> Optional[SelfHostedInstanceEntity]:
|
|
14
12
|
if not item:
|
|
File without changes
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
from typing import Optional, List, Dict
|
|
2
|
+
|
|
3
|
+
from thestage.config.business.config_provider import ConfigProvider
|
|
4
|
+
from thestage.services.clients.thestage_api.core.api_client_core import TheStageApiClientCore
|
|
5
|
+
from thestage.services.clients.thestage_api.dtos.paginated_entity_list import PaginatedEntityList
|
|
6
|
+
|
|
7
|
+
from thestage.instance.dto.instance_rented_response import (
|
|
8
|
+
InstanceRentedListResponse,
|
|
9
|
+
InstanceRentedDto,
|
|
10
|
+
InstanceRentedItemResponse,
|
|
11
|
+
InstanceRentedBusinessStatusMapperResponse
|
|
12
|
+
)
|
|
13
|
+
from thestage.instance.dto.selfhosted_instance_response import (
|
|
14
|
+
SelfHostedInstanceListResponse,
|
|
15
|
+
SelfHostedInstanceDto,
|
|
16
|
+
SelfHostedRentedItemResponse,
|
|
17
|
+
SelfHostedRentedRentedBusinessStatusMapperResponse
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class InstanceApiClient(TheStageApiClientCore):
|
|
22
|
+
def __init__(self, config_provider: ConfigProvider):
|
|
23
|
+
super().__init__(url=config_provider.get_config().main.thestage_api_url)
|
|
24
|
+
self.__config_provider = config_provider
|
|
25
|
+
|
|
26
|
+
def get_rented_instance_list(
|
|
27
|
+
self,
|
|
28
|
+
statuses: List[str],
|
|
29
|
+
page: int = 1,
|
|
30
|
+
limit: int = 10,
|
|
31
|
+
) -> PaginatedEntityList[InstanceRentedDto]:
|
|
32
|
+
data = {
|
|
33
|
+
#"statuses": [item.value for item in statuses],
|
|
34
|
+
"entityFilterRequest": {
|
|
35
|
+
"orderByField": "createdAt",
|
|
36
|
+
"orderByDirection": "DESC",
|
|
37
|
+
"page": page,
|
|
38
|
+
"limit": limit
|
|
39
|
+
},
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if statuses:
|
|
43
|
+
data['businessStatuses'] = statuses
|
|
44
|
+
|
|
45
|
+
response = self._request(
|
|
46
|
+
method='POST',
|
|
47
|
+
url='/user-api/v3/instance-rented/list',
|
|
48
|
+
data=data,
|
|
49
|
+
token=self.__config_provider.get_config().main.thestage_auth_token,
|
|
50
|
+
)
|
|
51
|
+
|
|
52
|
+
result = InstanceRentedListResponse.model_validate(response) if response else None
|
|
53
|
+
return result.paginated_list if result and result.paginated_list else ([], None)
|
|
54
|
+
|
|
55
|
+
def get_rented_business_status_map(self) -> Optional[Dict[str, str]]:
|
|
56
|
+
response = self._request(
|
|
57
|
+
method='POST',
|
|
58
|
+
url='/user-api/v2/instance-rented/business-status-localized-map',
|
|
59
|
+
data=None,
|
|
60
|
+
token=self.__config_provider.get_config().main.thestage_auth_token,
|
|
61
|
+
)
|
|
62
|
+
|
|
63
|
+
data = InstanceRentedBusinessStatusMapperResponse.model_validate(response) if response else None
|
|
64
|
+
|
|
65
|
+
return data.instance_rented_business_status_map if data else None
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
def get_rented_instance(
|
|
70
|
+
self,
|
|
71
|
+
instance_public_id: Optional[str] = None,
|
|
72
|
+
instance_slug: Optional[str] = None,
|
|
73
|
+
) -> Optional[InstanceRentedDto]:
|
|
74
|
+
if not instance_slug and not instance_public_id:
|
|
75
|
+
return None
|
|
76
|
+
|
|
77
|
+
data = {
|
|
78
|
+
"instanceRentedPublicId": instance_public_id,
|
|
79
|
+
"instanceRentedSlug": instance_slug,
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
response = self._request(
|
|
83
|
+
method='POST',
|
|
84
|
+
url='/user-api/v3/instance-rented/view',
|
|
85
|
+
data=data,
|
|
86
|
+
token=self.__config_provider.get_config().main.thestage_auth_token,
|
|
87
|
+
)
|
|
88
|
+
|
|
89
|
+
return InstanceRentedItemResponse.model_validate(response).instance_rented if response else None
|
|
90
|
+
|
|
91
|
+
def get_selfhosted_instance(
|
|
92
|
+
self,
|
|
93
|
+
instance_public_id: Optional[str] = None,
|
|
94
|
+
instance_slug: Optional[str] = None,
|
|
95
|
+
) -> Optional[SelfHostedInstanceDto]:
|
|
96
|
+
if not instance_slug and not instance_public_id:
|
|
97
|
+
return None
|
|
98
|
+
|
|
99
|
+
data = {
|
|
100
|
+
"selfhostedInstancePublicId": instance_public_id,
|
|
101
|
+
"selfhostedInstanceSlug": instance_slug,
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
response = self._request(
|
|
105
|
+
method='POST',
|
|
106
|
+
url='/user-api/v3/self-hosted-instance/view',
|
|
107
|
+
data=data,
|
|
108
|
+
token=self.__config_provider.get_config().main.thestage_auth_token,
|
|
109
|
+
)
|
|
110
|
+
|
|
111
|
+
return SelfHostedRentedItemResponse.model_validate(response).selfhosted_instance if response else None
|
|
112
|
+
|
|
113
|
+
def get_selfhosted_instance_list(
|
|
114
|
+
self,
|
|
115
|
+
statuses: List[str],
|
|
116
|
+
page: int = 1,
|
|
117
|
+
limit: int = 10,
|
|
118
|
+
) -> PaginatedEntityList[SelfHostedInstanceDto]:
|
|
119
|
+
data = {
|
|
120
|
+
"entityFilterRequest": {
|
|
121
|
+
"orderByField": "createdAt",
|
|
122
|
+
"orderByDirection": "DESC",
|
|
123
|
+
"page": page,
|
|
124
|
+
"limit": limit
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
if statuses:
|
|
129
|
+
data['businessStatuses'] = statuses
|
|
130
|
+
|
|
131
|
+
response = self._request(
|
|
132
|
+
method='POST',
|
|
133
|
+
url='/user-api/v3/self-hosted-instance/list',
|
|
134
|
+
data=data,
|
|
135
|
+
token=self.__config_provider.get_config().main.thestage_auth_token,
|
|
136
|
+
)
|
|
137
|
+
|
|
138
|
+
result = SelfHostedInstanceListResponse.model_validate(response) if response else None
|
|
139
|
+
return result.paginated_list if result and result.paginated_list else ([], None)
|
|
140
|
+
|
|
141
|
+
def get_selfhosted_business_status_map(self) -> Optional[Dict[str, str]]:
|
|
142
|
+
response = self._request(
|
|
143
|
+
method='POST',
|
|
144
|
+
url='/user-api/v2/self-hosted-instance/business-status-localized-map',
|
|
145
|
+
data=None,
|
|
146
|
+
token=self.__config_provider.get_config().main.thestage_auth_token,
|
|
147
|
+
)
|
|
148
|
+
|
|
149
|
+
data = SelfHostedRentedRentedBusinessStatusMapperResponse.model_validate(response) if response else None
|
|
150
|
+
return data.selfhosted_instance_business_status_map if data else None
|
|
@@ -4,7 +4,7 @@ from typing import Optional, List
|
|
|
4
4
|
from thestage.cli_command import CliCommand
|
|
5
5
|
from thestage.cli_command_helper import get_command_group_help_panel, get_command_metadata, check_command_permission
|
|
6
6
|
from thestage.helpers.logger.app_logger import app_logger
|
|
7
|
-
from thestage.
|
|
7
|
+
from thestage.instance.business.instance_service import InstanceService
|
|
8
8
|
from thestage.i18n.translation import __
|
|
9
9
|
from thestage.controllers.utils_controller import \
|
|
10
10
|
validate_config_and_get_service_factory, get_current_directory
|
|
@@ -66,14 +66,14 @@ def rented_list(
|
|
|
66
66
|
def instance_connect(
|
|
67
67
|
public_id: Optional[str] = typer.Option(
|
|
68
68
|
None,
|
|
69
|
-
'--id',
|
|
69
|
+
'--rented-instance-id',
|
|
70
70
|
'-rid',
|
|
71
71
|
help="Rented instance ID",
|
|
72
72
|
is_eager=False,
|
|
73
73
|
),
|
|
74
74
|
slug: Optional[str] = typer.Option(
|
|
75
75
|
None,
|
|
76
|
-
'--name',
|
|
76
|
+
'--rented-instance-name',
|
|
77
77
|
'-rn',
|
|
78
78
|
help="Rented instance name",
|
|
79
79
|
is_eager=False,
|
|
@@ -91,7 +91,7 @@ def instance_connect(
|
|
|
91
91
|
check_command_permission(command_name)
|
|
92
92
|
|
|
93
93
|
if sum(v is not None for v in [public_id, slug]) != 1:
|
|
94
|
-
typer.echo("
|
|
94
|
+
typer.echo("Provide a single identifier for rented instance - ID or name.")
|
|
95
95
|
raise typer.Exit(1)
|
|
96
96
|
|
|
97
97
|
if private_ssh_key_path and not Path(private_ssh_key_path).is_file():
|
|
@@ -107,7 +107,7 @@ def instance_connect(
|
|
|
107
107
|
input_ssh_key_path=private_ssh_key_path
|
|
108
108
|
)
|
|
109
109
|
|
|
110
|
-
app_logger.info(f'
|
|
110
|
+
app_logger.info(f'Connection to rented instance closed')
|
|
111
111
|
raise typer.Exit(0)
|
|
112
112
|
|
|
113
113
|
|
|
@@ -156,14 +156,14 @@ def self_hosted_list(
|
|
|
156
156
|
def self_hosted_connect(
|
|
157
157
|
public_id: Optional[str] = typer.Option(
|
|
158
158
|
None,
|
|
159
|
-
'--id',
|
|
159
|
+
'--self-hosted-instance-id',
|
|
160
160
|
'-sid',
|
|
161
161
|
help="Self-hosted instance ID",
|
|
162
162
|
is_eager=False,
|
|
163
163
|
),
|
|
164
164
|
slug: Optional[str] = typer.Option(
|
|
165
165
|
None,
|
|
166
|
-
'--name',
|
|
166
|
+
'--self-hosted-instance-name',
|
|
167
167
|
'-sn',
|
|
168
168
|
help="Self-hosted instance name",
|
|
169
169
|
is_eager=False,
|
|
@@ -188,7 +188,7 @@ def self_hosted_connect(
|
|
|
188
188
|
check_command_permission(command_name)
|
|
189
189
|
|
|
190
190
|
if sum(v is not None for v in [public_id, slug]) != 1:
|
|
191
|
-
typer.echo("
|
|
191
|
+
typer.echo("Provide a single identifier for self-hosted instance - ID or name.")
|
|
192
192
|
raise typer.Exit(1)
|
|
193
193
|
|
|
194
194
|
if private_ssh_key_path and not Path(private_ssh_key_path).is_file():
|
|
@@ -205,5 +205,5 @@ def self_hosted_connect(
|
|
|
205
205
|
input_ssh_key_path=private_ssh_key_path
|
|
206
206
|
)
|
|
207
207
|
|
|
208
|
-
app_logger.info(f'
|
|
208
|
+
app_logger.info(f'Connection to self-hosted instance closed')
|
|
209
209
|
raise typer.Exit(0)
|
|
File without changes
|
|
File without changes
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
|
|
2
1
|
from typing import Optional, List
|
|
3
2
|
|
|
4
3
|
from pydantic import Field, BaseModel, ConfigDict
|
|
5
4
|
|
|
6
|
-
from thestage.
|
|
5
|
+
from thestage.instance.dto.enum.gpu_name import InstanceGpuType
|
|
7
6
|
|
|
8
7
|
|
|
9
8
|
class InstanceDaemonGpuDto(BaseModel):
|
|
@@ -5,8 +5,8 @@ from pydantic import Field, BaseModel, ConfigDict
|
|
|
5
5
|
from thestage.services.clients.thestage_api.dtos.frontend_status import FrontendStatusDto
|
|
6
6
|
from thestage.services.clients.thestage_api.dtos.base_response import TheStageBasePaginatedResponse
|
|
7
7
|
from thestage.services.clients.thestage_api.dtos.paginated_entity_list import PaginatedEntityList
|
|
8
|
-
from thestage.
|
|
9
|
-
from thestage.
|
|
8
|
+
from thestage.instance.dto.enum.gpu_name import InstanceGpuType
|
|
9
|
+
from thestage.instance.dto.enum.cpu_type import InstanceCpuType
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
class InstanceRentedDto(BaseModel):
|
thestage/{services/clients/thestage_api/dtos → instance/dto}/selfhosted_instance_response.py
RENAMED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
from datetime import datetime
|
|
2
1
|
from typing import Optional, Dict
|
|
3
2
|
|
|
4
3
|
from pydantic import Field, BaseModel, ConfigDict
|
|
@@ -6,8 +5,8 @@ from pydantic import Field, BaseModel, ConfigDict
|
|
|
6
5
|
from thestage.services.clients.thestage_api.dtos.base_response import TheStageBasePaginatedResponse
|
|
7
6
|
from thestage.services.clients.thestage_api.dtos.frontend_status import FrontendStatusDto
|
|
8
7
|
from thestage.services.clients.thestage_api.dtos.paginated_entity_list import PaginatedEntityList
|
|
9
|
-
from thestage.
|
|
10
|
-
from thestage.
|
|
8
|
+
from thestage.instance.dto.instance_detected_gpus import InstanceDetectedGpusDto
|
|
9
|
+
from thestage.instance.dto.enum.cpu_type import InstanceCpuType
|
|
11
10
|
|
|
12
11
|
|
|
13
12
|
class SelfHostedInstanceDto(BaseModel):
|
|
File without changes
|
|
File without changes
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import asyncio
|
|
2
2
|
from _signal import SIGINT
|
|
3
|
-
from asyncio import CancelledError,
|
|
3
|
+
from asyncio import CancelledError, StreamWriter
|
|
4
4
|
from datetime import datetime
|
|
5
5
|
from typing import Optional, Dict
|
|
6
6
|
|
|
@@ -8,43 +8,55 @@ import aioconsole
|
|
|
8
8
|
import typer
|
|
9
9
|
from httpx import ReadTimeout, ConnectError, ConnectTimeout
|
|
10
10
|
|
|
11
|
+
from thestage.docker_container.communication.docker_container_api_client import DockerContainerApiClient
|
|
11
12
|
from thestage.helpers.logger.app_logger import app_logger
|
|
12
|
-
from thestage.
|
|
13
|
-
from thestage.
|
|
14
|
-
from thestage.
|
|
15
|
-
from thestage.
|
|
13
|
+
from thestage.docker_container.dto.enum.container_status import DockerContainerStatus
|
|
14
|
+
from thestage.inference_simulator.communication.inference_simulator_api_client import InferenceSimulatorApiClient
|
|
15
|
+
from thestage.inference_simulator.dto.enum.inference_simulator_status import InferenceSimulatorStatus
|
|
16
|
+
from thestage.logging.communication.logging_api_client import LoggingApiClient
|
|
17
|
+
from thestage.task.communication.task_api_client import TaskApiClient
|
|
18
|
+
from thestage.task.dto.enum.task_status import TaskStatus
|
|
19
|
+
from thestage.inference_simulator.dto.get_inference_simulator_response import \
|
|
16
20
|
GetInferenceSimulatorResponse
|
|
17
|
-
from thestage.
|
|
18
|
-
from thestage.
|
|
19
|
-
from thestage.
|
|
20
|
-
from thestage.
|
|
21
|
+
from thestage.task.dto.view_response import TaskViewResponse
|
|
22
|
+
from thestage.logging.byte_print_style import BytePrintStyle
|
|
23
|
+
from thestage.logging.dto.log_message import LogMessage
|
|
24
|
+
from thestage.logging.dto.log_type import LogType
|
|
21
25
|
from thestage.i18n.translation import __
|
|
22
|
-
from thestage.
|
|
23
|
-
from thestage.services.clients.thestage_api.dtos.container_response import DockerContainerDto
|
|
26
|
+
from thestage.docker_container.dto.container_response import DockerContainerDto
|
|
24
27
|
from thestage.helpers.error_handler import error_handler
|
|
25
|
-
from thestage.services.clients.thestage_api.api_client import TheStageApiClient
|
|
26
28
|
from rich import print
|
|
27
29
|
|
|
28
|
-
from thestage.
|
|
29
|
-
from thestage.
|
|
30
|
+
from thestage.exceptions.log_polling_exception import LogPollingException
|
|
31
|
+
from thestage.logging.logging_constants import LOG_MESSAGE_CODE_TASK_FINISHED, \
|
|
30
32
|
LOG_MESSAGE_CODE_INFERENCE_SIMULATOR_FAILED
|
|
31
33
|
|
|
32
34
|
is_logs_streaming = False
|
|
33
35
|
|
|
34
36
|
|
|
35
37
|
class LoggingService:
|
|
36
|
-
|
|
38
|
+
__logging_api_client: LoggingApiClient = None
|
|
39
|
+
__task_api_client: TaskApiClient = None
|
|
40
|
+
__inference_simulator_api_client: InferenceSimulatorApiClient = None
|
|
41
|
+
__docker_container_api_client: DockerContainerApiClient = None
|
|
37
42
|
|
|
38
43
|
def __init__(
|
|
39
44
|
self,
|
|
40
|
-
|
|
45
|
+
logging_api_client: LoggingApiClient,
|
|
46
|
+
docker_container_api_client: DockerContainerApiClient,
|
|
47
|
+
task_api_client: TaskApiClient,
|
|
48
|
+
inference_simulator_api_client: InferenceSimulatorApiClient,
|
|
49
|
+
|
|
41
50
|
):
|
|
42
|
-
self.
|
|
51
|
+
self.__logging_api_client = logging_api_client
|
|
52
|
+
self.__docker_container_api_client = docker_container_api_client
|
|
53
|
+
self.__task_api_client = task_api_client
|
|
54
|
+
self.__inference_simulator_api_client = inference_simulator_api_client
|
|
43
55
|
|
|
44
56
|
|
|
45
57
|
@error_handler()
|
|
46
58
|
def print_last_task_logs(self, task_public_id: str, logs_number: Optional[int]):
|
|
47
|
-
logs = self.
|
|
59
|
+
logs = self.__logging_api_client.query_user_logs(
|
|
48
60
|
task_public_id=task_public_id,
|
|
49
61
|
limit=logs_number
|
|
50
62
|
)
|
|
@@ -54,7 +66,7 @@ class LoggingService:
|
|
|
54
66
|
|
|
55
67
|
@error_handler()
|
|
56
68
|
def print_last_inference_simulator_logs(self, inference_simulator_public_id: str, logs_number: Optional[int]):
|
|
57
|
-
logs = self.
|
|
69
|
+
logs = self.__logging_api_client.query_user_logs(
|
|
58
70
|
inference_simulator_public_id=inference_simulator_public_id,
|
|
59
71
|
limit=logs_number
|
|
60
72
|
)
|
|
@@ -64,7 +76,7 @@ class LoggingService:
|
|
|
64
76
|
|
|
65
77
|
@error_handler()
|
|
66
78
|
def print_last_container_logs(self, container_public_id: Optional[str], container_slug: Optional[str], logs_number: Optional[int]):
|
|
67
|
-
container: Optional[DockerContainerDto] = self.
|
|
79
|
+
container: Optional[DockerContainerDto] = self.__docker_container_api_client.get_container(
|
|
68
80
|
container_public_id=container_public_id,
|
|
69
81
|
container_slug=container_slug,
|
|
70
82
|
)
|
|
@@ -73,7 +85,7 @@ class LoggingService:
|
|
|
73
85
|
typer.echo("Container was not found")
|
|
74
86
|
raise typer.Exit(1)
|
|
75
87
|
|
|
76
|
-
logs = self.
|
|
88
|
+
logs = self.__logging_api_client.query_user_logs(
|
|
77
89
|
container_public_id=container.public_id,
|
|
78
90
|
limit=logs_number
|
|
79
91
|
)
|
|
@@ -90,9 +102,9 @@ class LoggingService:
|
|
|
90
102
|
|
|
91
103
|
@error_handler()
|
|
92
104
|
async def __stream_task_logs_with_controls_async(self, task_public_id: str):
|
|
93
|
-
task_view_response: Optional[TaskViewResponse] = self.
|
|
105
|
+
task_view_response: Optional[TaskViewResponse] = self.__task_api_client.get_task(task_public_id=task_public_id,)
|
|
94
106
|
|
|
95
|
-
task_status_map: Dict[str, str] = self.
|
|
107
|
+
task_status_map: Dict[str, str] = self.__task_api_client.get_task_localized_status_map()
|
|
96
108
|
|
|
97
109
|
task = task_view_response.task
|
|
98
110
|
|
|
@@ -128,7 +140,7 @@ class LoggingService:
|
|
|
128
140
|
print_logs_task.cancel()
|
|
129
141
|
if not input_task.result(): # result is only expected if ctrl+D triggered EOFError
|
|
130
142
|
typer.echo(f"\rTask {task_public_id} will be canceled")
|
|
131
|
-
self.
|
|
143
|
+
self.__task_api_client.cancel_task(
|
|
132
144
|
task_public_id=task.public_id,
|
|
133
145
|
)
|
|
134
146
|
|
|
@@ -143,12 +155,12 @@ class LoggingService:
|
|
|
143
155
|
|
|
144
156
|
@error_handler()
|
|
145
157
|
async def __stream_inference_simulator_logs_with_controls_async(self, public_id: Optional[str], slug: Optional[str]):
|
|
146
|
-
get_inference_simulator_response: Optional[GetInferenceSimulatorResponse] = self.
|
|
158
|
+
get_inference_simulator_response: Optional[GetInferenceSimulatorResponse] = self.__inference_simulator_api_client.get_inference_simulator(
|
|
147
159
|
public_id=public_id,
|
|
148
160
|
slug=slug,
|
|
149
161
|
)
|
|
150
162
|
|
|
151
|
-
inference_simulator_status_map: Dict[str, str] = self.
|
|
163
|
+
inference_simulator_status_map: Dict[str, str] = self.__inference_simulator_api_client.get_inference_simulator_business_status_map()
|
|
152
164
|
|
|
153
165
|
inference_simulator = get_inference_simulator_response.inferenceSimulator
|
|
154
166
|
|
|
@@ -162,15 +174,10 @@ class LoggingService:
|
|
|
162
174
|
}))
|
|
163
175
|
raise typer.Exit(1)
|
|
164
176
|
else:
|
|
165
|
-
typer.echo(
|
|
177
|
+
typer.echo("Inference simulator was not found")
|
|
166
178
|
raise typer.Exit(1)
|
|
167
179
|
|
|
168
|
-
typer.echo(
|
|
169
|
-
f"Log stream for inference simulator %slug% started",
|
|
170
|
-
{
|
|
171
|
-
'slug': str(inference_simulator.slug),
|
|
172
|
-
}
|
|
173
|
-
))
|
|
180
|
+
typer.echo(f"Log stream for inference simulator '{inference_simulator.public_id}' started")
|
|
174
181
|
|
|
175
182
|
typer.echo(__("CTRL+D to disconnect from log stream."))
|
|
176
183
|
|
|
@@ -184,7 +191,8 @@ class LoggingService:
|
|
|
184
191
|
|
|
185
192
|
if input_task in done:
|
|
186
193
|
print_task_or_inference_simulator_logs.cancel()
|
|
187
|
-
|
|
194
|
+
inference_logs_cmd_id = f"-isn {slug}" if slug else f"-isid {public_id}"
|
|
195
|
+
typer.echo(f"Disconnected from log stream. You can try to reconnect with 'thestage project inference-simulator logs {inference_logs_cmd_id}'")
|
|
188
196
|
|
|
189
197
|
|
|
190
198
|
@error_handler()
|
|
@@ -199,7 +207,7 @@ class LoggingService:
|
|
|
199
207
|
|
|
200
208
|
@error_handler()
|
|
201
209
|
async def __stream_container_logs_with_controls_async(self, container_public_id: Optional[str], container_slug: Optional[str]):
|
|
202
|
-
container: Optional[DockerContainerDto] = self.
|
|
210
|
+
container: Optional[DockerContainerDto] = self.__docker_container_api_client.get_container(
|
|
203
211
|
container_public_id=container_public_id,
|
|
204
212
|
container_slug=container_slug,
|
|
205
213
|
)
|
|
@@ -268,7 +276,7 @@ class LoggingService:
|
|
|
268
276
|
# stream_to_logs_diff = datetime.utcnow() - last_log_timestamp_parsed
|
|
269
277
|
# print_nonblocking(f'TDIFF {stream_to_logs_diff.total_seconds()}', writer)
|
|
270
278
|
try:
|
|
271
|
-
logs_response = await self.
|
|
279
|
+
logs_response = await self.__logging_api_client.poll_logs_httpx(
|
|
272
280
|
task_public_id=task_public_id,
|
|
273
281
|
inference_simulator_public_id=inference_simulator_public_id,
|
|
274
282
|
docker_container_public_id=docker_container_public_id,
|
|
@@ -285,6 +293,7 @@ class LoggingService:
|
|
|
285
293
|
consecutive_error_count = 0
|
|
286
294
|
errors_started_at = None
|
|
287
295
|
log_wait_remaining_limit = 0 # no log delays after reconnect
|
|
296
|
+
print_nonblocking("Reconnected to log stream", writer, BytePrintStyle.GREEN)
|
|
288
297
|
|
|
289
298
|
last_iteration_log_timestamp = logs_response.lastLogTimestamp
|
|
290
299
|
last_log_id = logs_response.lastLogId
|