thestage 0.5.45__py3-none-any.whl → 0.5.47__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/.env +5 -0
- thestage/__init__.py +2 -1
- thestage/cli_command.py +56 -0
- thestage/cli_command_helper.py +51 -0
- thestage/config/config_storage.py +3 -0
- thestage/controllers/base_controller.py +19 -15
- thestage/controllers/config_controller.py +30 -38
- thestage/controllers/container_controller.py +43 -79
- thestage/controllers/instance_controller.py +23 -40
- thestage/controllers/project_controller.py +95 -184
- thestage/controllers/utils_controller.py +12 -8
- thestage/debug_tests.py +12 -0
- thestage/entities/container.py +0 -5
- thestage/entities/rented_instance.py +0 -5
- thestage/entities/self_hosted_instance.py +0 -2
- thestage/helpers/error_handler.py +14 -14
- thestage/helpers/exception_hook.py +14 -0
- thestage/helpers/logger/app_logger.py +3 -4
- thestage/main.py +25 -13
- thestage/services/abstract_service.py +0 -40
- thestage/services/app_config_service.py +7 -6
- thestage/services/clients/thestage_api/api_client.py +60 -74
- thestage/services/clients/thestage_api/core/api_client_core.py +92 -9
- thestage/services/clients/thestage_api/dtos/container_response.py +1 -1
- thestage/services/clients/thestage_api/dtos/enums/instance_rented_status.py +1 -0
- thestage/services/clients/thestage_api/dtos/enums/selfhosted_status.py +1 -1
- thestage/services/clients/thestage_api/dtos/inference_simulator_model_response.py +1 -1
- thestage/services/clients/thestage_api/dtos/inference_simulator_response.py +1 -1
- thestage/services/clients/thestage_api/dtos/instance_rented_response.py +1 -1
- thestage/services/clients/thestage_api/dtos/selfhosted_instance_response.py +1 -1
- thestage/services/clients/thestage_api/dtos/task_controller/task_status_localized_map_response.py +1 -1
- thestage/services/clients/thestage_api/dtos/validate_token_response.py +11 -0
- thestage/services/config_provider/config_provider.py +75 -47
- thestage/services/connect/connect_service.py +11 -22
- thestage/services/container/container_service.py +6 -23
- thestage/services/core_files/config_entity.py +7 -1
- thestage/services/filesystem_service.py +2 -2
- thestage/services/instance/instance_service.py +14 -28
- thestage/services/logging/logging_service.py +17 -45
- thestage/services/project/project_service.py +33 -72
- thestage/services/remote_server_service.py +3 -4
- thestage/services/service_factory.py +21 -27
- thestage/services/validation_service.py +14 -9
- {thestage-0.5.45.dist-info → thestage-0.5.47.dist-info}/METADATA +3 -4
- {thestage-0.5.45.dist-info → thestage-0.5.47.dist-info}/RECORD +48 -43
- {thestage-0.5.45.dist-info → thestage-0.5.47.dist-info}/WHEEL +1 -1
- thestage/exceptions/http_error_exception.py +0 -12
- thestage/services/clients/thestage_api/core/api_client_abstract.py +0 -91
- {thestage-0.5.45.dist-info → thestage-0.5.47.dist-info}/LICENSE.txt +0 -0
- {thestage-0.5.45.dist-info → thestage-0.5.47.dist-info}/entry_points.txt +0 -0
|
@@ -1,18 +1,13 @@
|
|
|
1
1
|
from pathlib import Path
|
|
2
2
|
from typing import Optional, List
|
|
3
3
|
|
|
4
|
-
from thestage.
|
|
5
|
-
|
|
6
|
-
from thestage.entities.rented_instance import RentedInstanceEntity
|
|
7
|
-
from thestage.entities.self_hosted_instance import SelfHostedInstanceEntity
|
|
4
|
+
from thestage.cli_command import CliCommand
|
|
5
|
+
from thestage.cli_command_helper import get_command_group_help_panel, get_command_metadata, check_command_permission
|
|
8
6
|
from thestage.helpers.logger.app_logger import app_logger
|
|
9
|
-
from thestage.services.clients.thestage_api.dtos.enums.selfhosted_status import SelfhostedBusinessStatus
|
|
10
|
-
from thestage.services.instance.mapper.instance_mapper import InstanceMapper
|
|
11
|
-
from thestage.services.instance.mapper.selfhosted_mapper import SelfHostedMapper
|
|
12
7
|
from thestage.services.instance.instance_service import InstanceService
|
|
13
8
|
from thestage.i18n.translation import __
|
|
14
9
|
from thestage.controllers.utils_controller import \
|
|
15
|
-
validate_config_and_get_service_factory
|
|
10
|
+
validate_config_and_get_service_factory, get_current_directory
|
|
16
11
|
|
|
17
12
|
import typer
|
|
18
13
|
|
|
@@ -22,11 +17,11 @@ app = typer.Typer(no_args_is_help=True, help=__("Manage server instances"))
|
|
|
22
17
|
rented = typer.Typer(no_args_is_help=True, help=__("Manage rented server instances"))
|
|
23
18
|
self_hosted = typer.Typer(no_args_is_help=True, help=__("Manage self-hosted instances"))
|
|
24
19
|
|
|
25
|
-
app.add_typer(rented, name="rented")
|
|
26
|
-
app.add_typer(self_hosted, name="self-hosted")
|
|
20
|
+
app.add_typer(rented, name="rented", rich_help_panel=get_command_group_help_panel())
|
|
21
|
+
app.add_typer(self_hosted, name="self-hosted", rich_help_panel=get_command_group_help_panel())
|
|
27
22
|
|
|
28
23
|
|
|
29
|
-
@rented.command(name="ls", help=__("List rented server instances"))
|
|
24
|
+
@rented.command(name="ls", help=__("List rented server instances"), **get_command_metadata(CliCommand.INSTANCE_RENTED_LS))
|
|
30
25
|
def rented_list(
|
|
31
26
|
row: int = typer.Option(
|
|
32
27
|
5,
|
|
@@ -50,16 +45,14 @@ def rented_list(
|
|
|
50
45
|
is_eager=False,
|
|
51
46
|
),
|
|
52
47
|
):
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
service_factory = validate_config_and_get_service_factory()
|
|
57
|
-
config = service_factory.get_config_provider().get_full_config()
|
|
48
|
+
command_name = CliCommand.INSTANCE_RENTED_LS
|
|
49
|
+
app_logger.info(f'Running {command_name} from {get_current_directory()}')
|
|
50
|
+
check_command_permission(command_name)
|
|
58
51
|
|
|
52
|
+
service_factory = validate_config_and_get_service_factory()
|
|
59
53
|
instance_service: InstanceService = service_factory.get_instance_service()
|
|
60
54
|
|
|
61
55
|
instance_service.print_rented_instance_list(
|
|
62
|
-
config=config,
|
|
63
56
|
statuses=statuses,
|
|
64
57
|
row=row,
|
|
65
58
|
page=page
|
|
@@ -69,7 +62,7 @@ def rented_list(
|
|
|
69
62
|
raise typer.Exit(0)
|
|
70
63
|
|
|
71
64
|
|
|
72
|
-
@rented.command(name="connect", no_args_is_help=True, help=__("Connect to rented server instance"))
|
|
65
|
+
@rented.command(name="connect", no_args_is_help=True, help=__("Connect to rented server instance"), **get_command_metadata(CliCommand.INSTANCE_RENTED_CONNECT))
|
|
73
66
|
def instance_connect(
|
|
74
67
|
instance_uid: Optional[str] = typer.Argument(
|
|
75
68
|
help=__("Rented server instance unique ID"),
|
|
@@ -82,10 +75,9 @@ def instance_connect(
|
|
|
82
75
|
is_eager=False,
|
|
83
76
|
)
|
|
84
77
|
):
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
app_logger.info(f'Connect to rented server instance')
|
|
78
|
+
command_name = CliCommand.INSTANCE_RENTED_CONNECT
|
|
79
|
+
app_logger.info(f'Running {command_name} from {get_current_directory()}')
|
|
80
|
+
check_command_permission(command_name)
|
|
89
81
|
|
|
90
82
|
if not instance_uid:
|
|
91
83
|
typer.echo(__('Rented server instance unique ID is required'))
|
|
@@ -96,13 +88,10 @@ def instance_connect(
|
|
|
96
88
|
raise typer.Exit(1)
|
|
97
89
|
|
|
98
90
|
service_factory = validate_config_and_get_service_factory()
|
|
99
|
-
config = service_factory.get_config_provider().get_full_config()
|
|
100
|
-
|
|
101
91
|
instance_service: InstanceService = service_factory.get_instance_service()
|
|
102
92
|
|
|
103
93
|
instance_service.connect_to_rented_instance(
|
|
104
94
|
instance_rented_slug=instance_uid,
|
|
105
|
-
config=config,
|
|
106
95
|
input_ssh_key_path=private_ssh_key_path
|
|
107
96
|
)
|
|
108
97
|
|
|
@@ -110,7 +99,7 @@ def instance_connect(
|
|
|
110
99
|
raise typer.Exit(0)
|
|
111
100
|
|
|
112
101
|
|
|
113
|
-
@self_hosted.command(name="ls", help=__("List self-hosted instances"))
|
|
102
|
+
@self_hosted.command(name="ls", help=__("List self-hosted instances"), **get_command_metadata(CliCommand.INSTANCE_SELF_HOSTED_LS))
|
|
114
103
|
def self_hosted_list(
|
|
115
104
|
row: int = typer.Option(
|
|
116
105
|
5,
|
|
@@ -134,16 +123,14 @@ def self_hosted_list(
|
|
|
134
123
|
is_eager=False,
|
|
135
124
|
),
|
|
136
125
|
):
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
service_factory = validate_config_and_get_service_factory()
|
|
141
|
-
config = service_factory.get_config_provider().get_full_config()
|
|
126
|
+
command_name = CliCommand.INSTANCE_SELF_HOSTED_LS
|
|
127
|
+
app_logger.info(f'Running {command_name} from {get_current_directory()}')
|
|
128
|
+
check_command_permission(command_name)
|
|
142
129
|
|
|
130
|
+
service_factory = validate_config_and_get_service_factory()
|
|
143
131
|
instance_service: InstanceService = service_factory.get_instance_service()
|
|
144
132
|
|
|
145
133
|
instance_service.print_self_hosted_instance_list(
|
|
146
|
-
config=config,
|
|
147
134
|
statuses=statuses,
|
|
148
135
|
row=row,
|
|
149
136
|
page=page
|
|
@@ -153,7 +140,7 @@ def self_hosted_list(
|
|
|
153
140
|
raise typer.Exit(0)
|
|
154
141
|
|
|
155
142
|
|
|
156
|
-
@self_hosted.command(name="connect", no_args_is_help=True, help=__("Connect to self-hosted instance"))
|
|
143
|
+
@self_hosted.command(name="connect", no_args_is_help=True, help=__("Connect to self-hosted instance"), **get_command_metadata(CliCommand.INSTANCE_SELF_HOSTED_CONNECT))
|
|
157
144
|
def self_hosted_connect(
|
|
158
145
|
instance_slug: Optional[str] = typer.Argument(help=__("Self-hosted instance unique ID"),),
|
|
159
146
|
username: Optional[str] = typer.Option(
|
|
@@ -171,10 +158,9 @@ def self_hosted_connect(
|
|
|
171
158
|
is_eager=False,
|
|
172
159
|
),
|
|
173
160
|
):
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
app_logger.info(f'Connect to self-hosted instance')
|
|
161
|
+
command_name = CliCommand.INSTANCE_SELF_HOSTED_CONNECT
|
|
162
|
+
app_logger.info(f'Running {command_name} from {get_current_directory()}')
|
|
163
|
+
check_command_permission(command_name)
|
|
178
164
|
|
|
179
165
|
if not instance_slug:
|
|
180
166
|
typer.echo(__('Self-hosted instance unique ID is required'))
|
|
@@ -185,14 +171,11 @@ def self_hosted_connect(
|
|
|
185
171
|
raise typer.Exit(1)
|
|
186
172
|
|
|
187
173
|
service_factory = validate_config_and_get_service_factory()
|
|
188
|
-
config = service_factory.get_config_provider().get_full_config()
|
|
189
|
-
|
|
190
174
|
instance_service: InstanceService = service_factory.get_instance_service()
|
|
191
175
|
|
|
192
176
|
instance_service.connect_to_selfhosted_instance(
|
|
193
177
|
selfhosted_instance_slug=instance_slug,
|
|
194
178
|
username=username,
|
|
195
|
-
config=config,
|
|
196
179
|
input_ssh_key_path=private_ssh_key_path
|
|
197
180
|
)
|
|
198
181
|
|