thestage 0.6.7__py3-none-any.whl → 0.7.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.
Files changed (202) hide show
  1. thestage/__init__.py +1 -1
  2. thestage/cli_command.py +3 -0
  3. thestage/cli_command_helper.py +2 -2
  4. thestage/config/__init__.py +1 -1
  5. thestage/{services → config/business}/app_config_service.py +3 -4
  6. thestage/{services/config_provider → config/business}/config_provider.py +6 -5
  7. thestage/config/{config_storage.py → business/config_storage.py} +1 -1
  8. thestage/{services → config/business}/validation_service.py +9 -10
  9. thestage/{controllers/config_controller.py → config/communication/config_command.py} +7 -7
  10. thestage/{services/connect → connect/business}/connect_service.py +22 -19
  11. thestage/{services → connect/business}/remote_server_service.py +4 -5
  12. thestage/connect/communication/connect_api_client.py +84 -0
  13. thestage/{services/clients/thestage_api/dtos/ssh_key_controller → connect/dto}/add_ssh_key_to_user_response.py +0 -1
  14. thestage/{services/clients/thestage_api/dtos/ssh_key_controller → connect/dto}/add_ssh_public_key_to_instance_response.py +1 -4
  15. thestage/{services/clients/thestage_api/dtos/base_controller → connect/dto}/connect_resolve_response.py +0 -1
  16. thestage/controllers/base_controller.py +2 -2
  17. thestage/debug_main.dist.py +16 -14
  18. thestage/{services/container → docker_container/business}/container_service.py +147 -22
  19. thestage/{services/container → docker_container/business}/mapper/container_mapper.py +3 -3
  20. thestage/docker_container/business/mapper/image_mapper.py +16 -0
  21. thestage/docker_container/communication/__init__.py +0 -0
  22. thestage/{controllers/container_controller.py → docker_container/communication/docker_command.py} +192 -29
  23. thestage/docker_container/communication/docker_container_api_client.py +139 -0
  24. thestage/docker_container/communication/image_command.py +40 -0
  25. thestage/docker_container/dto/__init__.py +0 -0
  26. thestage/docker_container/dto/container_action_request.py +11 -0
  27. thestage/{services/clients/thestage_api/dtos → docker_container/dto}/container_response.py +11 -4
  28. thestage/docker_container/dto/docker_container_create_request.py +28 -0
  29. thestage/docker_container/dto/docker_container_create_response.py +11 -0
  30. thestage/{services/clients/thestage_api/dtos/docker_container_controller → docker_container/dto}/docker_container_list_response.py +3 -5
  31. thestage/docker_container/dto/docker_image_list_request.py +11 -0
  32. thestage/docker_container/dto/docker_image_list_response.py +13 -0
  33. thestage/docker_container/dto/enum/__init__.py +0 -0
  34. thestage/docker_container/dto/image_entity.py +14 -0
  35. thestage/git/__init__.py +0 -0
  36. thestage/git/business/__init__.py +0 -0
  37. thestage/git/communication/__init__.py +0 -0
  38. thestage/{services/clients/git → git/communication}/git_client.py +4 -4
  39. thestage/global_dto/__init__.py +0 -0
  40. thestage/global_dto/enums/__init__.py +0 -0
  41. thestage/helpers/error_handler.py +4 -4
  42. thestage/helpers/logger/app_logger.py +1 -3
  43. thestage/i18n/en_GB/messages.po +14 -14
  44. thestage/inference_model/__init__.py +0 -0
  45. thestage/inference_model/business/__init__.py +0 -0
  46. thestage/inference_model/business/inference_model_service.py +281 -0
  47. thestage/inference_model/business/mapper/__init__.py +0 -0
  48. thestage/{services/project/mapper/project_inference_simulator_model_mapper.py → inference_model/business/mapper/inference_model_mapper.py} +5 -5
  49. thestage/inference_model/communication/__init__.py +0 -0
  50. thestage/inference_model/communication/inference_model_api_client.py +139 -0
  51. thestage/inference_model/communication/inference_model_command.py +246 -0
  52. thestage/inference_model/dto/__init__.py +0 -0
  53. thestage/{services/clients/thestage_api/dtos/inference_controller → inference_model/dto}/deploy_inference_model_to_instance_response.py +0 -1
  54. thestage/inference_model/dto/enum/__init__.py +0 -0
  55. thestage/{services/project/dto/inference_simulator_model_dto.py → inference_model/dto/inference_model.py} +1 -1
  56. thestage/{entities/project_inference_simulator_model.py → inference_model/dto/inference_model_entity.py} +1 -1
  57. thestage/{services/clients/thestage_api/dtos/inference_controller → inference_model/dto}/inference_simulator_model_list_for_project_response.py +2 -3
  58. 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
  59. 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
  60. thestage/inference_simulator/__init__.py +0 -0
  61. thestage/inference_simulator/business/__init__.py +0 -0
  62. thestage/inference_simulator/business/inference_simulator_service.py +338 -0
  63. thestage/inference_simulator/business/mapper/__init__.py +0 -0
  64. thestage/{services/project/mapper/project_inference_simulator_mapper.py → inference_simulator/business/mapper/inference_simulator_mapper.py} +5 -5
  65. thestage/inference_simulator/communication/__init__.py +0 -0
  66. thestage/inference_simulator/communication/inference_simulator_api_client.py +114 -0
  67. thestage/inference_simulator/communication/inference_simulator_command.py +347 -0
  68. thestage/inference_simulator/dto/__init__.py +0 -0
  69. thestage/inference_simulator/dto/enum/__init__.py +0 -0
  70. thestage/inference_simulator/dto/get_inference_simulator_response.py +12 -0
  71. thestage/{services/project/dto/inference_simulator_dto.py → inference_simulator/dto/inference_simulator.py} +1 -1
  72. thestage/{entities/project_inference_simulator.py → inference_simulator/dto/inference_simulator_entity.py} +1 -1
  73. thestage/{services/clients/thestage_api/dtos/inference_controller → inference_simulator/dto}/inference_simulator_list_response.py +2 -2
  74. thestage/{services/clients/thestage_api/dtos/project_controller/project_start_inference_simulator_request.py → inference_simulator/dto/start_inference_simulator_request.py} +1 -1
  75. thestage/inference_simulator/dto/start_inference_simulator_response.py +10 -0
  76. thestage/instance/__init__.py +0 -0
  77. thestage/instance/business/__init__.py +0 -0
  78. thestage/{services/instance → instance/business}/instance_service.py +26 -27
  79. thestage/instance/business/mapper/__init__.py +0 -0
  80. thestage/{services/instance/mapper/instance_mapper.py → instance/business/mapper/rented_instance_mapper.py} +3 -3
  81. thestage/{services/instance/mapper/selfhosted_mapper.py → instance/business/mapper/selfhosted_instance_mapper.py} +5 -7
  82. thestage/instance/communication/__init__.py +0 -0
  83. thestage/instance/communication/instance_api_client.py +150 -0
  84. thestage/{controllers/instance_controller.py → instance/communication/instance_command.py} +5 -5
  85. thestage/instance/dto/__init__.py +0 -0
  86. thestage/instance/dto/enum/__init__.py +0 -0
  87. thestage/{services/clients/thestage_api/dtos → instance/dto}/instance_detected_gpus.py +1 -2
  88. thestage/{services/clients/thestage_api/dtos → instance/dto}/instance_rented_response.py +2 -2
  89. thestage/{services/clients/thestage_api/dtos → instance/dto}/selfhosted_instance_response.py +2 -3
  90. thestage/logging/__init__.py +0 -0
  91. thestage/logging/business/__init__.py +0 -0
  92. thestage/{services/logging → logging/business}/logging_service.py +40 -28
  93. thestage/logging/communication/__init__.py +0 -0
  94. thestage/logging/communication/logging_api_client.py +63 -0
  95. thestage/logging/dto/__init__.py +0 -0
  96. thestage/{services/clients/thestage_api/dtos/logging_controller → logging/dto}/log_polling_response.py +2 -2
  97. thestage/{services/clients/thestage_api/dtos/logging_controller → logging/dto}/user_logs_query_response.py +2 -2
  98. thestage/main.py +54 -8
  99. thestage/project/__init__.py +0 -0
  100. thestage/project/business/__init__.py +0 -0
  101. thestage/project/business/project_service.py +480 -0
  102. thestage/project/communication/__init__.py +0 -0
  103. thestage/project/communication/project_api_client.py +46 -0
  104. thestage/project/communication/project_command.py +284 -0
  105. thestage/project/dto/__init__.py +0 -0
  106. thestage/services/clients/thestage_api/core/api_client_core.py +1 -1
  107. thestage/services/clients/thestage_api/dtos/entity_filter_request.py +1 -1
  108. thestage/services/clients/thestage_api/dtos/sftp_path_helper.py +1 -1
  109. thestage/services/filesystem_service.py +2 -2
  110. thestage/services/service_factory.py +130 -43
  111. thestage/task/__init__.py +0 -0
  112. thestage/task/business/__init__.py +0 -0
  113. thestage/task/business/mapper/__init__.py +0 -0
  114. thestage/{services/project/mapper/project_task_mapper.py → task/business/mapper/task_mapper.py} +5 -5
  115. thestage/task/business/task_service.py +307 -0
  116. thestage/task/communication/__init__.py +0 -0
  117. thestage/task/communication/task_api_client.py +122 -0
  118. thestage/task/communication/task_command.py +212 -0
  119. thestage/task/dto/__init__.py +0 -0
  120. thestage/task/dto/enum/__init__.py +0 -0
  121. thestage/{services/clients/thestage_api/dtos/task_controller/task_list_for_project_response.py → task/dto/list_for_project_response.py} +2 -2
  122. thestage/{services/clients/thestage_api/dtos/project_controller/project_run_task_request.py → task/dto/run_task_request.py} +1 -1
  123. thestage/task/dto/run_task_response.py +13 -0
  124. thestage/{services/task/dto/task_dto.py → task/dto/task.py} +1 -4
  125. thestage/{entities/project_task.py → task/dto/task_entity.py} +1 -1
  126. thestage/{services/clients/thestage_api/dtos/task_controller/task_view_response.py → task/dto/view_response.py} +2 -2
  127. {thestage-0.6.7.dist-info → thestage-0.7.0.dist-info}/METADATA +1 -1
  128. thestage-0.7.0.dist-info/RECORD +226 -0
  129. {thestage-0.6.7.dist-info → thestage-0.7.0.dist-info}/WHEEL +1 -1
  130. thestage/controllers/project_controller.py +0 -1056
  131. thestage/services/clients/thestage_api/api_client.py +0 -751
  132. thestage/services/clients/thestage_api/dtos/container_param_request.py +0 -11
  133. thestage/services/clients/thestage_api/dtos/inference_controller/get_inference_simulator_response.py +0 -13
  134. thestage/services/clients/thestage_api/dtos/project_controller/project_run_task_response.py +0 -13
  135. thestage/services/clients/thestage_api/dtos/project_controller/project_start_inference_simulator_response.py +0 -10
  136. thestage/services/clients/thestage_api/dtos/user_controller/user_profile.py +0 -12
  137. thestage/services/project/project_service.py +0 -1287
  138. thestage-0.6.7.dist-info/RECORD +0 -167
  139. /thestage/{entities → color_scheme}/__init__.py +0 -0
  140. /thestage/{entities/enums → config/business}/__init__.py +0 -0
  141. /thestage/{services/clients/git → config/communication}/__init__.py +0 -0
  142. /thestage/{services/clients/thestage_api/dtos/enums → config/dto}/__init__.py +0 -0
  143. /thestage/{services/core_files → config/dto}/config_entity.py +0 -0
  144. /thestage/{services/connect → config}/dto/remote_server_config.py +0 -0
  145. /thestage/{services/config_provider → connect}/__init__.py +0 -0
  146. /thestage/{services/container → connect/business}/__init__.py +0 -0
  147. /thestage/{services/container/mapper → connect/communication}/__init__.py +0 -0
  148. /thestage/{services/instance → connect/dto}/__init__.py +0 -0
  149. /thestage/{services/clients/thestage_api/dtos/ssh_key_controller → connect/dto}/add_ssh_key_to_user_request.py +0 -0
  150. /thestage/{services/clients/thestage_api/dtos/ssh_key_controller → connect/dto}/add_ssh_public_key_to_instance_request.py +0 -0
  151. /thestage/{services/clients/thestage_api/dtos/ssh_key_controller → connect/dto}/is_user_has_public_ssh_key_request.py +0 -0
  152. /thestage/{services/clients/thestage_api/dtos/ssh_key_controller → connect/dto}/is_user_has_public_ssh_key_response.py +0 -0
  153. /thestage/{services/instance/mapper → docker_container}/__init__.py +0 -0
  154. /thestage/{services/project → docker_container/business}/__init__.py +0 -0
  155. /thestage/{services/project → docker_container/business}/mapper/__init__.py +0 -0
  156. /thestage/{entities/container.py → docker_container/dto/container_entity.py} +0 -0
  157. /thestage/{services/clients/thestage_api/dtos/docker_container_controller → docker_container/dto}/docker_container_list_request.py +0 -0
  158. /thestage/{services/clients/thestage_api/dtos → docker_container/dto}/docker_container_mapping.py +0 -0
  159. /thestage/{services/clients/thestage_api/dtos/enums → docker_container/dto/enum}/container_pending_action.py +0 -0
  160. /thestage/{services/clients/thestage_api/dtos/enums → docker_container/dto/enum}/container_status.py +0 -0
  161. /thestage/{services/logging/exception → exceptions}/log_polling_exception.py +0 -0
  162. /thestage/git/{ProgressPrinter.py → business/ProgressPrinter.py} +0 -0
  163. /thestage/{entities → global_dto}/enums/order_direction_type.py +0 -0
  164. /thestage/{entities → global_dto}/enums/shell_type.py +0 -0
  165. /thestage/{entities → global_dto}/enums/tail_output_type.py +0 -0
  166. /thestage/{entities → global_dto}/enums/yes_no_response.py +0 -0
  167. /thestage/{entities → global_dto}/file_item.py +0 -0
  168. /thestage/{services/clients/thestage_api/dtos/inference_controller → inference_model/dto}/deploy_inference_model_to_instance_request.py +0 -0
  169. /thestage/{services/clients/thestage_api/dtos/inference_controller → inference_model/dto}/deploy_inference_model_to_sagemaker_request.py +0 -0
  170. /thestage/{services/clients/thestage_api/dtos/inference_controller → inference_model/dto}/deploy_inference_model_to_sagemaker_response.py +0 -0
  171. /thestage/{services/clients/thestage_api/dtos/enums → inference_model/dto/enum}/inference_model_status.py +0 -0
  172. /thestage/{services/clients/thestage_api/dtos/inference_controller → inference_model/dto}/inference_simulator_model_list_for_project_request.py +0 -0
  173. /thestage/{services/clients/thestage_api/dtos → inference_model/dto}/inference_simulator_model_response.py +0 -0
  174. /thestage/{services/clients/thestage_api/dtos/enums → inference_simulator/dto/enum}/inference_simulator_status.py +0 -0
  175. /thestage/{services/clients/thestage_api/dtos/inference_controller → inference_simulator/dto}/get_inference_simulator_request.py +0 -0
  176. /thestage/{services/clients/thestage_api/dtos/inference_controller → inference_simulator/dto}/inference_simulator_list_request.py +0 -0
  177. /thestage/{services/clients/thestage_api/dtos → inference_simulator/dto}/inference_simulator_response.py +0 -0
  178. /thestage/{services/clients/thestage_api/dtos/enums → instance/dto/enum}/cpu_type.py +0 -0
  179. /thestage/{services/clients/thestage_api/dtos/enums → instance/dto/enum}/gpu_name.py +0 -0
  180. /thestage/{services/clients/thestage_api/dtos/enums → instance/dto/enum}/instance_rented_status.py +0 -0
  181. /thestage/{services/clients/thestage_api/dtos/enums → instance/dto/enum}/provider_name.py +0 -0
  182. /thestage/{services/clients/thestage_api/dtos/enums → instance/dto/enum}/selfhosted_status.py +0 -0
  183. /thestage/{entities → instance/dto}/rented_instance.py +0 -0
  184. /thestage/{entities → instance/dto}/self_hosted_instance.py +0 -0
  185. /thestage/{services/logging → logging}/byte_print_style.py +0 -0
  186. /thestage/{services/clients/thestage_api/dtos/logging_controller → logging/dto}/docker_container_log_stream_request.py +0 -0
  187. /thestage/{services/logging → logging}/dto/log_message.py +0 -0
  188. /thestage/{services/clients/thestage_api/dtos/logging_controller → logging/dto}/log_polling_request.py +0 -0
  189. /thestage/{services/logging → logging}/dto/log_type.py +0 -0
  190. /thestage/{services/clients/thestage_api/dtos/logging_controller → logging/dto}/task_log_stream_request.py +0 -0
  191. /thestage/{services/clients/thestage_api/dtos/logging_controller → logging/dto}/user_logs_query_request.py +0 -0
  192. /thestage/{services/logging → logging}/logging_constants.py +0 -0
  193. /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
  194. /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
  195. /thestage/{services/project → project}/dto/project_config.py +0 -0
  196. /thestage/{services/clients/thestage_api/dtos → project/dto}/project_response.py +0 -0
  197. /thestage/{services/clients/thestage_api/dtos/enums → task/dto/enum}/task_execution_status.py +0 -0
  198. /thestage/{services/clients/thestage_api/dtos/enums → task/dto/enum}/task_status.py +0 -0
  199. /thestage/{services/clients/thestage_api/dtos/task_controller/task_list_for_project_request.py → task/dto/list_for_project_request.py} +0 -0
  200. /thestage/{services/clients/thestage_api/dtos/task_controller/task_status_localized_map_response.py → task/dto/status_localized_map_response.py} +0 -0
  201. {thestage-0.6.7.dist-info → thestage-0.7.0.dist-info}/entry_points.txt +0 -0
  202. {thestage-0.6.7.dist-info → thestage-0.7.0.dist-info}/licenses/LICENSE.txt +0 -0
@@ -0,0 +1,139 @@
1
+ from typing import Optional, List, Dict
2
+
3
+ from thestage.config.business.config_provider import ConfigProvider
4
+ from thestage.docker_container.dto.docker_container_create_request import DockerContainerCreateRequest
5
+ from thestage.docker_container.dto.docker_container_create_response import DockerContainerCreateResult
6
+ from thestage.docker_container.dto.docker_image_list_request import DockerImageListRequest
7
+ from thestage.docker_container.dto.docker_image_list_response import DockerImageListResponse
8
+ from thestage.global_dto.enums.order_direction_type import OrderDirectionType
9
+ from thestage.services.clients.thestage_api.core.api_client_core import TheStageApiClientCore
10
+ from thestage.services.clients.thestage_api.dtos.base_response import TheStageBaseResponse
11
+ from thestage.services.clients.thestage_api.dtos.entity_filter_request import EntityFilterRequest
12
+ from thestage.services.clients.thestage_api.dtos.paginated_entity_list import PaginatedEntityList
13
+
14
+ from thestage.docker_container.dto.container_action_request import DockerContainerActionRequest
15
+ from thestage.docker_container.dto.container_response import (
16
+ DockerContainerDto,
17
+ DockerContainerViewResponse,
18
+ ContainerBusinessStatusMapperResponse, DockerImageDto
19
+ )
20
+ from thestage.docker_container.dto.docker_container_list_request import DockerContainerListRequest
21
+ from thestage.docker_container.dto.docker_container_list_response import DockerContainerListResponse
22
+
23
+
24
+ class DockerContainerApiClient(TheStageApiClientCore):
25
+ def __init__(self, config_provider: ConfigProvider):
26
+ super().__init__(url=config_provider.get_config().main.thestage_api_url)
27
+ self.__config_provider = config_provider
28
+
29
+ def get_container_list(
30
+ self,
31
+ project_public_id: Optional[str] = None,
32
+ project_slug: Optional[str] = None,
33
+ statuses: List[str] = [],
34
+ page: int = 1,
35
+ limit: int = 10,
36
+ ) -> PaginatedEntityList[DockerContainerDto]:
37
+ request = DockerContainerListRequest(
38
+ statuses=statuses,
39
+ projectPublicId=project_public_id,
40
+ projectSlug=project_slug,
41
+ entityFilterRequest=EntityFilterRequest(
42
+ orderByField="createdAt",
43
+ orderByDirection=OrderDirectionType.DESC,
44
+ page=page,
45
+ limit=limit,
46
+ ),
47
+ )
48
+
49
+ response = self._request(
50
+ method='POST',
51
+ url='/user-api/v2/docker-container/list',
52
+ data=request.model_dump(),
53
+ token=self.__config_provider.get_config().main.thestage_auth_token
54
+ )
55
+
56
+ result = DockerContainerListResponse.model_validate(response) if response else None
57
+ return result.paginatedList if result and result.is_success else None
58
+
59
+
60
+ def get_docker_image_list(
61
+ self,
62
+ page: int = 1,
63
+ limit: int = 10,
64
+ ) -> PaginatedEntityList[DockerImageDto]:
65
+ request = DockerImageListRequest(
66
+ entityFilterRequest=EntityFilterRequest(
67
+ orderByField="createdAt",
68
+ orderByDirection=OrderDirectionType.DESC,
69
+ page=page,
70
+ limit=limit,
71
+ ),
72
+ )
73
+ response = self._request(
74
+ method='POST',
75
+ url='/user-api/v1/docker-image/list',
76
+ data=request.model_dump(),
77
+ token=self.__config_provider.get_config().main.thestage_auth_token
78
+ )
79
+ result = DockerImageListResponse.model_validate(response) if response else None
80
+ return result.paginatedList if result and result.is_success else None
81
+
82
+
83
+ def get_container(
84
+ self,
85
+ container_slug: Optional[str] = None,
86
+ container_public_id: Optional[str] = None,
87
+ ) -> Optional[DockerContainerDto]:
88
+ data = {
89
+ "dockerContainerPublicId": container_public_id,
90
+ "dockerContainerSlug": container_slug,
91
+ }
92
+
93
+ response = self._request(
94
+ method='POST',
95
+ url='/user-api/v2/docker-container/view',
96
+ data=data,
97
+ token=self.__config_provider.get_config().main.thestage_auth_token,
98
+ )
99
+
100
+ return DockerContainerViewResponse.model_validate(response).docker_container if response else None
101
+
102
+
103
+ def create_container(self, request_param: DockerContainerCreateRequest) -> Optional[DockerContainerCreateResult]:
104
+ response = self._request(
105
+ method='POST',
106
+ url='/user-api/v1/docker-container/create',
107
+ data=request_param.model_dump(by_alias=True),
108
+ token=self.__config_provider.get_config().main.thestage_auth_token
109
+ )
110
+
111
+ return DockerContainerCreateResult.model_validate(response) if response else None
112
+
113
+
114
+ def container_action(
115
+ self,
116
+ request_param: DockerContainerActionRequest,
117
+ ) -> TheStageBaseResponse:
118
+
119
+ response = self._request(
120
+ method='POST',
121
+ url='/user-api/v2/docker-container/action',
122
+ data=request_param.model_dump(by_alias=True),
123
+ token=self.__config_provider.get_config().main.thestage_auth_token,
124
+ )
125
+
126
+ result = TheStageBaseResponse.model_validate(response) if response else None
127
+ return result
128
+
129
+
130
+ def get_container_business_status_map(self) -> Optional[Dict[str, str]]:
131
+ response = self._request(
132
+ method='POST',
133
+ url='/user-api/v1/docker-container/status-localized-mapping',
134
+ data=None,
135
+ token=self.__config_provider.get_config().main.thestage_auth_token,
136
+ )
137
+
138
+ data = ContainerBusinessStatusMapperResponse.model_validate(response) if response else None
139
+ return data.docker_container_status_map if data else None
@@ -0,0 +1,40 @@
1
+ import typer
2
+
3
+ from thestage.cli_command import CliCommand
4
+ from thestage.cli_command_helper import get_command_metadata, check_command_permission
5
+ from thestage.controllers.utils_controller import validate_config_and_get_service_factory
6
+ from thestage.docker_container.business.container_service import ContainerService
7
+ from thestage.i18n.translation import __
8
+
9
+ app = typer.Typer(no_args_is_help=True, help=__("Manage Docker images"))
10
+
11
+ @app.command(name='ls', help=__("List available docker images"), **get_command_metadata(CliCommand.CONTAINER_LS))
12
+ def list_available_images(
13
+ row: int = typer.Option(
14
+ 5,
15
+ '--row',
16
+ '-r',
17
+ help=__("Set number of rows displayed per page"),
18
+ is_eager=False,
19
+ ),
20
+ page: int = typer.Option(
21
+ 1,
22
+ '--page',
23
+ '-p',
24
+ help=__("Set starting page for displaying output"),
25
+ is_eager=False,
26
+ ),
27
+ ):
28
+ command_name = CliCommand.CONTAINER_IMAGE_LS
29
+ check_command_permission(command_name)
30
+
31
+ service_factory = validate_config_and_get_service_factory()
32
+ container_service: ContainerService = service_factory.get_container_service()
33
+
34
+ container_service.print_docker_image_list(
35
+ row=row,
36
+ page=page,
37
+ )
38
+
39
+ typer.echo(__("Images listing complete"))
40
+ raise typer.Exit(0)
File without changes
@@ -0,0 +1,11 @@
1
+ from typing import Optional
2
+
3
+ from pydantic import Field, BaseModel, ConfigDict
4
+
5
+ from thestage.docker_container.dto.enum.container_pending_action import DockerContainerAction
6
+
7
+ class DockerContainerActionRequest(BaseModel):
8
+ model_config = ConfigDict(use_enum_values=True)
9
+
10
+ dockerContainerPublicId: Optional[str] = Field(None, alias='dockerContainerPublicId')
11
+ action: DockerContainerAction = Field(None, alias='action')
@@ -2,11 +2,11 @@ from typing import Optional, List, Dict
2
2
 
3
3
  from pydantic import Field, BaseModel, ConfigDict
4
4
 
5
- from thestage.services.clients.thestage_api.dtos.docker_container_mapping import DockerContainerMappingDto
5
+ from thestage.docker_container.dto.docker_container_mapping import DockerContainerMappingDto
6
6
  from thestage.services.clients.thestage_api.dtos.frontend_status import FrontendStatusDto
7
- from thestage.services.clients.thestage_api.dtos.instance_rented_response import InstanceRentedDto
8
- from thestage.services.clients.thestage_api.dtos.project_response import ProjectDto
9
- from thestage.services.clients.thestage_api.dtos.selfhosted_instance_response import SelfHostedInstanceDto
7
+ from thestage.instance.dto.instance_rented_response import InstanceRentedDto
8
+ from thestage.project.dto.project_response import ProjectDto
9
+ from thestage.instance.dto.selfhosted_instance_response import SelfHostedInstanceDto
10
10
  from thestage.services.clients.thestage_api.dtos.base_response import TheStageBaseResponse, TheStageBasePaginatedResponse
11
11
  from thestage.services.clients.thestage_api.dtos.pagination_data import PaginationData
12
12
 
@@ -45,3 +45,10 @@ class ContainerBusinessStatusMapperResponse(TheStageBasePaginatedResponse):
45
45
  model_config = ConfigDict(use_enum_values=True)
46
46
 
47
47
  docker_container_status_map: Dict[str, str] = Field(default={}, alias='dockerContainerStatusMap')
48
+
49
+ class DockerImageDto(BaseModel):
50
+ model_config = ConfigDict(use_enum_values=True)
51
+
52
+ id: Optional[int] = Field(None, alias='id')
53
+ image: Optional[str] = Field(None, alias='image')
54
+ tag: Optional[str] = Field(None, alias='tag')
@@ -0,0 +1,28 @@
1
+ from typing import Optional, Dict
2
+
3
+ from pydantic import BaseModel, Field, ConfigDict
4
+
5
+
6
+ class DockerContainerMappings(BaseModel):
7
+ model_config = ConfigDict(populate_by_name=True)
8
+
9
+ directory_mappings: Dict[str, str] = Field(default_factory=dict, alias='directoryMappings')
10
+ port_mappings: Dict[str, str] = Field(default_factory=dict, alias='portMappings')
11
+
12
+
13
+ class DockerContainerCreateRequest(BaseModel):
14
+ model_config = ConfigDict(populate_by_name=True)
15
+
16
+ instance_rented_public_id: Optional[str] = Field(None, alias='instanceRentedPublicId')
17
+ instance_rented_slug: Optional[str] = Field(None, alias='instanceRentedSlug')
18
+ selfhosted_instance_public_id: Optional[str] = Field(None, alias='selfhostedInstancePublicId')
19
+ selfhosted_instance_slug: Optional[str] = Field(None, alias='selfhostedInstanceSlug')
20
+ project_public_id: Optional[str] = Field(..., alias='projectPublicId')
21
+ project_slug: Optional[str] = Field(..., alias='projectSlug')
22
+ container_slug: str = Field(..., alias='containerSlug')
23
+ docker_image_id: int = Field(..., alias='dockerImageId')
24
+ assigned_cpus: Optional[int] = Field(None, alias='assignedCpus')
25
+ is_unlimited_cpus: bool = Field(False, alias='isUnlimitedCpus')
26
+ assigned_gpus: Optional[int] = Field(None, alias='assignedGpus')
27
+ is_unlimited_gpus: bool = Field(False, alias='isUnlimitedGpus')
28
+ mappings: DockerContainerMappings = Field(default_factory=DockerContainerMappings, alias='mappings')
@@ -0,0 +1,11 @@
1
+ from typing import Optional
2
+
3
+ from pydantic import Field, ConfigDict
4
+
5
+ from thestage.services.clients.thestage_api.dtos.base_response import TheStageBaseResponse
6
+
7
+
8
+ class DockerContainerCreateResult(TheStageBaseResponse):
9
+ model_config = ConfigDict(populate_by_name=True)
10
+
11
+ docker_container_public_id: Optional[str] = Field(None, alias='dockerContainerPublicId')
@@ -1,11 +1,9 @@
1
- from typing import List, Optional
2
-
3
- from pydantic import Field, ConfigDict, BaseModel
1
+ from pydantic import Field, ConfigDict
4
2
 
5
3
  from thestage.services.clients.thestage_api.dtos.base_response import TheStageBaseResponse
6
- from thestage.services.clients.thestage_api.dtos.container_response import DockerContainerDto
4
+ from thestage.docker_container.dto.container_response import DockerContainerDto
7
5
  from thestage.services.clients.thestage_api.dtos.paginated_entity_list import PaginatedEntityList
8
- from thestage.services.clients.thestage_api.dtos.pagination_data import PaginationData
6
+
9
7
 
10
8
  class DockerContainerListResponse(TheStageBaseResponse):
11
9
  model_config = ConfigDict(use_enum_values=True)
@@ -0,0 +1,11 @@
1
+ from typing import Optional, List
2
+
3
+ from pydantic import Field, ConfigDict, BaseModel
4
+
5
+ from thestage.services.clients.thestage_api.dtos.entity_filter_request import EntityFilterRequest
6
+
7
+
8
+ class DockerImageListRequest(BaseModel):
9
+ model_config = ConfigDict(use_enum_values=True)
10
+
11
+ entityFilterRequest: EntityFilterRequest = Field(None, alias='entityFilterRequest')
@@ -0,0 +1,13 @@
1
+ from typing import List, Optional
2
+
3
+ from pydantic import Field, ConfigDict
4
+
5
+ from thestage.docker_container.dto.container_response import DockerImageDto
6
+ from thestage.services.clients.thestage_api.dtos.base_response import TheStageBaseResponse
7
+ from thestage.services.clients.thestage_api.dtos.paginated_entity_list import PaginatedEntityList
8
+
9
+
10
+ class DockerImageListResponse(TheStageBaseResponse):
11
+ model_config = ConfigDict(use_enum_values=True)
12
+
13
+ paginatedList: PaginatedEntityList[DockerImageDto] = Field(None, alias='paginatedList')
File without changes
@@ -0,0 +1,14 @@
1
+ from typing import Optional
2
+
3
+ from pydantic import BaseModel, ConfigDict, Field
4
+
5
+
6
+ class DockerImageEntity(BaseModel):
7
+
8
+ model_config = ConfigDict(
9
+ populate_by_name=True,
10
+ use_enum_values=True,
11
+ )
12
+
13
+ image: Optional[str] = Field(None, alias='IMAGE')
14
+ tag: Optional[str] = Field(None, alias='TAG')
File without changes
File without changes
File without changes
@@ -12,9 +12,9 @@ from gitdb.exc import BadName
12
12
  from rich import print
13
13
 
14
14
  from thestage.color_scheme.color_scheme import ColorScheme
15
- from thestage.config import THESTAGE_CONFIG_DIR
15
+ from thestage.config.env_base import THESTAGE_CONFIG_DIR
16
16
  from thestage.exceptions.git_access_exception import GitAccessException
17
- from thestage.git.ProgressPrinter import ProgressPrinter
17
+ from thestage.git.business.ProgressPrinter import ProgressPrinter
18
18
  from thestage.services.filesystem_service import FileSystemService
19
19
 
20
20
 
@@ -33,7 +33,7 @@ class GitLocalClient:
33
33
  ):
34
34
  self.__file_system_service = file_system_service
35
35
 
36
- # todo delete this fuckery
36
+ # todo delete this
37
37
  def __get_repo(self, path: str) -> Repo:
38
38
  return git.Repo(path)
39
39
 
@@ -392,7 +392,7 @@ class GitLocalClient:
392
392
  repo.git.reset('--hard', f'origin/{repo.active_branch.name}')
393
393
  typer.echo(f'Branch "{repo.active_branch.name}" is now synced to its remote counterpart')
394
394
  else:
395
- typer.echo('simple branch reset is not implemented')
395
+ typer.echo('Simple branch reset is not implemented')
396
396
 
397
397
  # refers to a "headless commit" where something was committed while in detached head state and head is pointing at that commit
398
398
  def is_head_committed_in_headless_state(self, path: str) -> bool:
File without changes
File without changes
@@ -7,7 +7,7 @@ from click.exceptions import Exit, Abort
7
7
  from git import GitCommandError
8
8
  from paramiko.ssh_exception import PasswordRequiredException
9
9
 
10
- from thestage.config import THESTAGE_API_URL
10
+ from thestage.config.env_base import THESTAGE_API_URL
11
11
  from thestage.exceptions.file_system_exception import FileSystemException
12
12
  from thestage.exceptions.remote_server_exception import RemoteServerException
13
13
  from thestage.i18n.translation import __
@@ -26,7 +26,7 @@ def error_handler() -> Callable:
26
26
  result = f(*args, **kwargs)
27
27
  return result
28
28
  except AuthException as e1:
29
- typer.echo(__('Authentication failed: update API token'))
29
+ typer.echo(__('Authentication failed: update access token'))
30
30
  app_logger.error(f'{traceback.format_exc()}')
31
31
  raise typer.Exit(1)
32
32
  except BusinessLogicException as e2:
@@ -98,7 +98,7 @@ def error_handler() -> Callable:
98
98
  raise typer.Exit(1)
99
99
  except PasswordRequiredException as e11:
100
100
  # technically we can use encrypted keys but dealing with passwords is big bs
101
- typer.echo("Provided key requires password. Please use non-encrypted key.")
101
+ typer.echo("Provided key requires password. Use non-encrypted key.")
102
102
  app_logger.error(f'{traceback.format_exc()}')
103
103
  raise typer.Exit(1)
104
104
  except Exception as e100:
@@ -107,7 +107,7 @@ def error_handler() -> Callable:
107
107
  else:
108
108
  typer.echo(__('Undefined error occurred'))
109
109
  # typer.echo(e100.__class__.__name__)
110
- # print(traceback.format_exc())
110
+ print(traceback.format_exc())
111
111
  # TODO send all exceptions to backend?
112
112
  app_logger.error(f'{traceback.format_exc()}')
113
113
  raise typer.Exit(1)
@@ -3,10 +3,8 @@ import platform
3
3
  from logging.handlers import RotatingFileHandler
4
4
  from pathlib import Path
5
5
  from thestage import __app_name__, __version__
6
+ from thestage.config.env_base import THESTAGE_CONFIG_DIR, THESTAGE_LOGGING_FILE
6
7
 
7
- from thestage.config import THESTAGE_CONFIG_DIR
8
-
9
- from thestage.config import THESTAGE_LOGGING_FILE
10
8
  from thestage.exceptions.file_system_exception import FileSystemException
11
9
 
12
10
 
@@ -161,7 +161,7 @@ msgstr "Add URL to your own repository"
161
161
 
162
162
  # Branch: feature/add_new_method_for_containers
163
163
  #: tsr/controllers/sketch_controller.py
164
- msgid "This folder is not empty, we can not clone here"
164
+ msgid "This folder is not empty, we cannot clone here"
165
165
  msgstr "Cannot clone: the folder is not empty"
166
166
 
167
167
  # Branch: feature/add_new_method_for_containers
@@ -362,7 +362,7 @@ msgstr "Task title is required: please type or select to auto-generate"
362
362
 
363
363
  # Branch: feature/add_new_method_for_containers
364
364
  #: tsr/services/sketch/sketch_service.py
365
- msgid "Task title can not be empty"
365
+ msgid "Task title cannot be empty"
366
366
  msgstr "Task title is required"
367
367
 
368
368
  # Branch: feature/add_new_method_for_containers
@@ -427,7 +427,7 @@ msgstr "Incorrect slug specified: sketch not found"
427
427
 
428
428
  # Branch: feature/add_new_method_for_containers
429
429
  #: tsr/services/sketch/sketch_service.py
430
- msgid "You have local repo with remote, we can not work with this"
430
+ msgid "You have local repo with remote, we cannot work with this"
431
431
  msgstr "Your local repository is linked to a remote: this configuration is not supported for the current operation"
432
432
 
433
433
  # Branch: feature/add_new_method_for_containers
@@ -442,12 +442,12 @@ msgstr "Your local repo has been modified and is not empty, please create an emp
442
442
 
443
443
  # Branch: feature/add_new_method_for_containers
444
444
  #: tsr/services/sketch/sketch_service.py
445
- msgid "We can not add remote, something wrong"
445
+ msgid "We cannot add remote, something wrong"
446
446
  msgstr "Cannot add remote, something wrong"
447
447
 
448
448
  # Branch: feature/add_new_method_for_containers
449
449
  #: tsr/services/sketch/sketch_service.py
450
- msgid "You have local repo, we can not work with this"
450
+ msgid "You have local repo, we cannot work with this"
451
451
  msgstr "Local repository in use: not supported for current operation"
452
452
 
453
453
  # Branch: feature/add_new_method_for_containers
@@ -517,12 +517,12 @@ msgstr "Path not found"
517
517
 
518
518
  # Branch: feature/add_new_method_for_containers
519
519
  #: tsr/services/filesystem_service.py
520
- msgid "We can not make dir"
520
+ msgid "We cannot make dir"
521
521
  msgstr "Failed to create directory"
522
522
 
523
523
  # Branch: feature/add_new_method_for_containers
524
524
  #: tsr/services/filesystem_service.py
525
- msgid "We can not make file"
525
+ msgid "We cannot make file"
526
526
  msgstr "Failed to create file"
527
527
 
528
528
  # Branch: feature/add_new_method_for_containers
@@ -692,12 +692,12 @@ msgstr "Cannot connect to rented or self-hosted instance"
692
692
 
693
693
  # Branch: feature/add_new_method_for_containers
694
694
  #: tsr/services/container/container_service.py
695
- msgid "Container name not present, can not connect to container"
695
+ msgid "Container name not present, cannot connect to container"
696
696
  msgstr "Cannot connect to container: please specify container slug"
697
697
 
698
698
  # Branch: feature/add_new_method_for_containers
699
699
  #: tsr/services/container/container_service.py
700
- msgid "We can not get shell on container (bash, shell), please use standard shell"
700
+ msgid "We cannot get shell on container (bash, shell), please use standard shell"
701
701
  msgstr "Unable to access the requested shell (bash, shell) in the container: please use the default shell available in the container"
702
702
 
703
703
  # Branch: feature/add_new_method_for_containers
@@ -722,7 +722,7 @@ msgstr "Specify username to connect to server instance"
722
722
 
723
723
  # Branch: feature/add_new_method_for_containers
724
724
  #: tsr/services/container/container_service.py
725
- msgid "Container is running, can not start working server"
725
+ msgid "Container is running, cannot start working server"
726
726
  msgstr "Container is running: cannot start running container"
727
727
 
728
728
  # Branch: feature/add_new_method_for_containers
@@ -797,7 +797,7 @@ msgstr "Server instance slug not found"
797
797
 
798
798
  # Branch: feature/add_new_method_for_containers
799
799
  #: tsr/services/sketch/sketch_service.py
800
- msgid "Slug can not be empty"
800
+ msgid "Slug cannot be empty"
801
801
  msgstr "Specify slug"
802
802
 
803
803
  # Branch: main
@@ -928,17 +928,17 @@ msgstr ""
928
928
 
929
929
  # Branch: main
930
930
  #: tsr/services/container/container_service.py
931
- msgid "Error, can not find mapping folders"
931
+ msgid "Error, cannot find mapping folders"
932
932
  msgstr ""
933
933
 
934
934
  # Branch: main
935
935
  #: tsr/services/container/container_service.py
936
- msgid "Error, can not find mapping for /public folder"
936
+ msgid "Error, cannot find mapping for /public folder"
937
937
  msgstr ""
938
938
 
939
939
  # Branch: main
940
940
  #: tsr/services/remote_server_service.py
941
- msgid "Can not find mapping folders"
941
+ msgid "cannot find mapping folders"
942
942
  msgstr ""
943
943
 
944
944
  # Branch: main
File without changes
File without changes