Py4HEAppE 1.0.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.
- __init__.py +1 -0
- py4heappe/__init__.py +1 -0
- py4heappe/cli/__init__.py +1 -0
- py4heappe/cli/auth.py +153 -0
- py4heappe/cli/command_template.py +370 -0
- py4heappe/cli/configuration.py +65 -0
- py4heappe/cli/information.py +163 -0
- py4heappe/cli/job_management.py +211 -0
- py4heappe/cli/report.py +173 -0
- py4heappe/core/__init__.py +167 -0
- py4heappe/core/api/__init__.py +12 -0
- py4heappe/core/api/cluster_information_api.py +308 -0
- py4heappe/core/api/data_transfer_api.py +405 -0
- py4heappe/core/api/file_transfer_api.py +498 -0
- py4heappe/core/api/job_management_api.py +866 -0
- py4heappe/core/api/job_reporting_api.py +692 -0
- py4heappe/core/api/management_api.py +2540 -0
- py4heappe/core/api/user_and_limitation_management_api.py +676 -0
- py4heappe/core/api_client.py +632 -0
- py4heappe/core/base/__init__.py +1 -0
- py4heappe/core/base/exceptions.py +41 -0
- py4heappe/core/base/logger.py +11 -0
- py4heappe/core/base/utils.py +43 -0
- py4heappe/core/configuration.py +247 -0
- py4heappe/core/models/__init__.py +155 -0
- py4heappe/core/models/adaptor_user.py +398 -0
- py4heappe/core/models/adaptor_user_group.py +268 -0
- py4heappe/core/models/adaptor_user_role.py +242 -0
- py4heappe/core/models/adaptor_user_role_ext.py +138 -0
- py4heappe/core/models/adaptor_user_role_type.py +95 -0
- py4heappe/core/models/adaptor_user_type.py +91 -0
- py4heappe/core/models/adaptor_user_user_group_role.py +320 -0
- py4heappe/core/models/allocated_nodes_ips_model.py +136 -0
- py4heappe/core/models/authenticate_lexis_token_model.py +110 -0
- py4heappe/core/models/authenticate_user_digital_signature_model.py +110 -0
- py4heappe/core/models/authenticate_user_open_id_model.py +110 -0
- py4heappe/core/models/authenticate_user_open_id_open_stack_model.py +136 -0
- py4heappe/core/models/authenticate_user_password_model.py +110 -0
- py4heappe/core/models/authentication_credentials.py +110 -0
- py4heappe/core/models/bad_request_result.py +110 -0
- py4heappe/core/models/cancel_job_model.py +136 -0
- py4heappe/core/models/cluster.py +478 -0
- py4heappe/core/models/cluster_authentication_credentials.py +375 -0
- py4heappe/core/models/cluster_authentication_credentials_auth_type.py +97 -0
- py4heappe/core/models/cluster_connection_protocol.py +91 -0
- py4heappe/core/models/cluster_detailed_report_ext.py +214 -0
- py4heappe/core/models/cluster_ext.py +188 -0
- py4heappe/core/models/cluster_init_report_ext.py +136 -0
- py4heappe/core/models/cluster_node_type.py +528 -0
- py4heappe/core/models/cluster_node_type_detailed_report_ext.py +240 -0
- py4heappe/core/models/cluster_node_type_ext.py +292 -0
- py4heappe/core/models/cluster_node_type_for_task_ext.py +188 -0
- py4heappe/core/models/cluster_node_type_report_ext.py +214 -0
- py4heappe/core/models/cluster_node_type_requested_group.py +136 -0
- py4heappe/core/models/cluster_node_type_resource_usage_ext.py +292 -0
- py4heappe/core/models/cluster_node_usage_ext.py +318 -0
- py4heappe/core/models/cluster_project.py +347 -0
- py4heappe/core/models/cluster_project_credential.py +294 -0
- py4heappe/core/models/cluster_proxy_connection.py +243 -0
- py4heappe/core/models/cluster_proxy_connection_ext.py +214 -0
- py4heappe/core/models/cluster_report_ext.py +215 -0
- py4heappe/core/models/command_template.py +557 -0
- py4heappe/core/models/command_template_ext.py +240 -0
- py4heappe/core/models/command_template_parameter.py +347 -0
- py4heappe/core/models/command_template_parameter_ext.py +136 -0
- py4heappe/core/models/command_template_parameter_value_ext.py +136 -0
- py4heappe/core/models/contact.py +269 -0
- py4heappe/core/models/copy_job_data_from_temp_model.py +162 -0
- py4heappe/core/models/copy_job_data_to_temp_model.py +162 -0
- py4heappe/core/models/create_command_inner_template_parameter_model.py +162 -0
- py4heappe/core/models/create_command_template_from_generic_model.py +292 -0
- py4heappe/core/models/create_command_template_model.py +318 -0
- py4heappe/core/models/create_command_template_parameter_model.py +214 -0
- py4heappe/core/models/create_job_by_project_model.py +136 -0
- py4heappe/core/models/create_project_assignment_to_cluster_model.py +188 -0
- py4heappe/core/models/create_project_model.py +318 -0
- py4heappe/core/models/create_secure_shell_key_model.py +162 -0
- py4heappe/core/models/create_secure_shell_key_model_obsolete.py +188 -0
- py4heappe/core/models/current_cluster_node_usage_model.py +136 -0
- py4heappe/core/models/current_info_for_job_model.py +136 -0
- py4heappe/core/models/data_transfer_method_ext.py +188 -0
- py4heappe/core/models/delete_job_model.py +136 -0
- py4heappe/core/models/deployment_type_ext.py +91 -0
- py4heappe/core/models/digital_signature_credentials_ext.py +162 -0
- py4heappe/core/models/download_file_from_cluster_model.py +162 -0
- py4heappe/core/models/download_parts_of_job_files_from_cluster_model.py +162 -0
- py4heappe/core/models/end_data_transfer_model.py +136 -0
- py4heappe/core/models/end_file_transfer_model.py +162 -0
- py4heappe/core/models/environment_variable_ext.py +136 -0
- py4heappe/core/models/extended_command_template_ext.py +370 -0
- py4heappe/core/models/extended_command_template_parameter_ext.py +188 -0
- py4heappe/core/models/extended_project_info_ext.py +318 -0
- py4heappe/core/models/file_information_ext.py +136 -0
- py4heappe/core/models/file_transfer_cipher_type.py +94 -0
- py4heappe/core/models/file_transfer_cipher_type_ext.py +93 -0
- py4heappe/core/models/file_transfer_key_credentials_ext.py +240 -0
- py4heappe/core/models/file_transfer_method.py +294 -0
- py4heappe/core/models/file_transfer_method_ext.py +240 -0
- py4heappe/core/models/file_transfer_protocol.py +91 -0
- py4heappe/core/models/file_transfer_protocol_ext.py +91 -0
- py4heappe/core/models/get_command_template_parameters_name_model.py +188 -0
- py4heappe/core/models/get_current_usage_and_limitations_for_current_user_model.py +110 -0
- py4heappe/core/models/get_data_transfer_method_model.py +188 -0
- py4heappe/core/models/get_file_transfer_method_model.py +136 -0
- py4heappe/core/models/http_get_to_job_node_model.py +241 -0
- py4heappe/core/models/http_header_ext.py +136 -0
- py4heappe/core/models/http_post_to_job_node_model.py +267 -0
- py4heappe/core/models/initialize_cluster_script_directory_model.py +162 -0
- py4heappe/core/models/instance_information_ext.py +344 -0
- py4heappe/core/models/job_detailed_report_ext.py +318 -0
- py4heappe/core/models/job_file_content_ext.py +214 -0
- py4heappe/core/models/job_report_ext.py +188 -0
- py4heappe/core/models/job_specification_by_project_ext.py +448 -0
- py4heappe/core/models/job_specification_ext.py +448 -0
- py4heappe/core/models/job_state_aggregation_report_ext.py +162 -0
- py4heappe/core/models/job_state_ext.py +96 -0
- py4heappe/core/models/lexis_credentials_ext.py +137 -0
- py4heappe/core/models/list_changed_files_for_job_model.py +136 -0
- py4heappe/core/models/list_jobs_for_current_user_model.py +110 -0
- py4heappe/core/models/modify_command_template_from_generic_model.py +292 -0
- py4heappe/core/models/modify_command_template_model.py +292 -0
- py4heappe/core/models/modify_command_template_parameter_model.py +214 -0
- py4heappe/core/models/modify_project_assignment_to_cluster_model.py +188 -0
- py4heappe/core/models/modify_project_model.py +292 -0
- py4heappe/core/models/node_used_cores_and_limitation_ext.py +110 -0
- py4heappe/core/models/open_id_credentials_ext.py +137 -0
- py4heappe/core/models/open_stack_application_credentials_ext.py +136 -0
- py4heappe/core/models/password_credentials_ext.py +136 -0
- py4heappe/core/models/problem_details.py +89 -0
- py4heappe/core/models/project.py +482 -0
- py4heappe/core/models/project_contact.py +215 -0
- py4heappe/core/models/project_detailed_report_ext.py +292 -0
- py4heappe/core/models/project_ext.py +266 -0
- py4heappe/core/models/project_for_task_ext.py +214 -0
- py4heappe/core/models/project_list_report_ext.py +214 -0
- py4heappe/core/models/project_reference_ext.py +137 -0
- py4heappe/core/models/project_report_ext.py +240 -0
- py4heappe/core/models/project_resource_usage_ext.py +266 -0
- py4heappe/core/models/proxy_type.py +91 -0
- py4heappe/core/models/proxy_type_ext.py +91 -0
- py4heappe/core/models/public_key_ext.py +188 -0
- py4heappe/core/models/recreate_secure_shell_key_model.py +214 -0
- py4heappe/core/models/regenerate_secure_shell_key_model.py +188 -0
- py4heappe/core/models/regenerate_secure_shell_key_model_obsolete.py +188 -0
- py4heappe/core/models/remove_command_template_model.py +136 -0
- py4heappe/core/models/remove_command_template_parameter_model.py +136 -0
- py4heappe/core/models/remove_project_assignment_to_cluster_model.py +162 -0
- py4heappe/core/models/remove_project_model.py +136 -0
- py4heappe/core/models/remove_secure_shell_key_model.py +162 -0
- py4heappe/core/models/remove_secure_shell_key_model_obsolete.py +162 -0
- py4heappe/core/models/resource_allocation_type_ext.py +91 -0
- py4heappe/core/models/resource_limitation_ext.py +136 -0
- py4heappe/core/models/resource_usage_ext.py +163 -0
- py4heappe/core/models/scheduler_type.py +92 -0
- py4heappe/core/models/ssh_key_user_credentials_model.py +136 -0
- py4heappe/core/models/submit_job_model.py +136 -0
- py4heappe/core/models/submitted_job_info_ext.py +318 -0
- py4heappe/core/models/submitted_task_info_ext.py +370 -0
- py4heappe/core/models/synchronizable_files_ext.py +92 -0
- py4heappe/core/models/task_detailed_report_ext.py +318 -0
- py4heappe/core/models/task_file_offset_ext.py +162 -0
- py4heappe/core/models/task_paralization_parameter_ext.py +162 -0
- py4heappe/core/models/task_priority_ext.py +97 -0
- py4heappe/core/models/task_report_ext.py +266 -0
- py4heappe/core/models/task_specification_ext.py +682 -0
- py4heappe/core/models/task_state_ext.py +95 -0
- py4heappe/core/models/test_cluster_access_for_account_model.py +162 -0
- py4heappe/core/models/test_cluster_access_for_account_model_obsolete.py +162 -0
- py4heappe/core/models/unauthorized_result.py +110 -0
- py4heappe/core/models/usage_type.py +90 -0
- py4heappe/core/models/usage_type_ext.py +90 -0
- py4heappe/core/models/user_group_detailed_report_ext.py +240 -0
- py4heappe/core/models/user_group_list_report_ext.py +240 -0
- py4heappe/core/models/user_group_report_ext.py +240 -0
- py4heappe/core/models/version_information_ext.py +162 -0
- py4heappe/core/rest.py +311 -0
- py4heappe-1.0.0.dist-info/METADATA +147 -0
- py4heappe-1.0.0.dist-info/RECORD +183 -0
- py4heappe-1.0.0.dist-info/WHEEL +5 -0
- py4heappe-1.0.0.dist-info/entry_points.txt +2 -0
- py4heappe-1.0.0.dist-info/licenses/LICENSE +20 -0
- py4heappe-1.0.0.dist-info/top_level.txt +3 -0
- py4heappe_cli.py +22 -0
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import json
|
|
2
|
+
import typer
|
|
3
|
+
|
|
4
|
+
import py4heappe.cli.configuration as configuration
|
|
5
|
+
import py4heappe.core.base.utils as utils
|
|
6
|
+
import py4heappe.core as heappeCore
|
|
7
|
+
|
|
8
|
+
from py4heappe.core.base import exceptions
|
|
9
|
+
from py4heappe.core import rest
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
app = typer.Typer(name="HEAppEInfoCLI", no_args_is_help=True, pretty_exceptions_short=True)
|
|
13
|
+
|
|
14
|
+
def get_hpc_project():
|
|
15
|
+
try:
|
|
16
|
+
utils.print_and_log("Fetching computational project …")
|
|
17
|
+
parameters = {
|
|
18
|
+
"_preload_content": False,
|
|
19
|
+
"SessionCode": utils.load_stored_session()
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
response = heappeCore.UserAndLimitationManagementApi(configuration.get_api_instance()).heappe_user_and_limitation_management_projects_for_current_user_get(**parameters)
|
|
23
|
+
project = next((f["Project"] for f in json.loads(response.data)if f["Project"]["AccountingString"] == configuration.get_project_from_configuration()), None)
|
|
24
|
+
|
|
25
|
+
if project is None:
|
|
26
|
+
raise exceptions.Py4HEAppEInternalException("The computational project does not exist.") from None
|
|
27
|
+
|
|
28
|
+
return project
|
|
29
|
+
|
|
30
|
+
except rest.ApiException as exception:
|
|
31
|
+
try:
|
|
32
|
+
response_data = json.loads(exception.body)
|
|
33
|
+
raise exceptions.Py4HEAppEAPIInternalException(response_data['title'], response_data['detail'], response_data['status']) from None
|
|
34
|
+
except json.JSONDecodeError:
|
|
35
|
+
raise exceptions.Py4HEAppEInternalException("Link to a HEAppE instance is not set or valid. Please check Conf Init option.") from None
|
|
36
|
+
|
|
37
|
+
except exceptions.Py4HEAppEInternalException as exception:
|
|
38
|
+
raise exceptions.Py4HEAppEInternalException(exception.message) from None
|
|
39
|
+
|
|
40
|
+
except Exception as exception:
|
|
41
|
+
raise exceptions.Py4HEAppEInternalException(f"Other exception: {str(exception)}") from None
|
|
42
|
+
|
|
43
|
+
@app.command(name="Version")
|
|
44
|
+
def get_api_version():
|
|
45
|
+
"""Version information"""
|
|
46
|
+
try:
|
|
47
|
+
utils.print_and_log("Fetching HEAppE API version information …")
|
|
48
|
+
parameters = {
|
|
49
|
+
"_preload_content": False,
|
|
50
|
+
"SessionCode": utils.load_stored_session()
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
response= heappeCore.ManagementApi(configuration.get_api_instance()).heappe_management_version_information_get(**parameters)
|
|
54
|
+
version: str = json.loads(response.data)["Version"]
|
|
55
|
+
utils.print_and_log(f"\nVersion of API: {version}")
|
|
56
|
+
|
|
57
|
+
except rest.ApiException as exception:
|
|
58
|
+
try:
|
|
59
|
+
response_data = json.loads(exception.body)
|
|
60
|
+
raise exceptions.Py4HEAppEAPIException(response_data['title'], response_data['detail'], response_data['status']) from None
|
|
61
|
+
except json.JSONDecodeError:
|
|
62
|
+
raise exceptions.Py4HEAppEException("Link to a HEAppE instance is not set or valid. Please check Conf Init option.") from None
|
|
63
|
+
|
|
64
|
+
except exceptions.Py4HEAppEInternalException as exception:
|
|
65
|
+
raise exceptions.Py4HEAppEException(exception.message) from None
|
|
66
|
+
|
|
67
|
+
except Exception as exception:
|
|
68
|
+
raise exceptions.Py4HEAppEInternalException(f"Other exception: {str(exception)}") from None
|
|
69
|
+
|
|
70
|
+
@app.command(name="ClusterInfo")
|
|
71
|
+
def get_cluster_information():
|
|
72
|
+
"""Cluster information"""
|
|
73
|
+
try:
|
|
74
|
+
utils.print_and_log("Fetching cluster information …")
|
|
75
|
+
parameters = {
|
|
76
|
+
"_preload_content": False
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
response= heappeCore.ClusterInformationApi(configuration.get_api_instance()).heappe_cluster_information_list_available_clusters_get(**parameters)
|
|
80
|
+
print(f"\nCluster information:\n{json.dumps(json.loads(response.data), indent = 3)}")
|
|
81
|
+
|
|
82
|
+
except rest.ApiException as exception:
|
|
83
|
+
try:
|
|
84
|
+
response_data = json.loads(exception.body)
|
|
85
|
+
raise exceptions.Py4HEAppEAPIException(response_data['title'], response_data['detail'], response_data['status']) from None
|
|
86
|
+
except json.JSONDecodeError:
|
|
87
|
+
raise exceptions.Py4HEAppEException("Link to a HEAppE instance is not set or valid. Please check Conf Init option.") from None
|
|
88
|
+
|
|
89
|
+
except exceptions.Py4HEAppEInternalException as exception:
|
|
90
|
+
raise exceptions.Py4HEAppEException(exception.message) from None
|
|
91
|
+
|
|
92
|
+
except Exception as exception:
|
|
93
|
+
raise exceptions.Py4HEAppEInternalException(f"Other exception: {str(exception)}") from None
|
|
94
|
+
|
|
95
|
+
@app.command("ListParamsFromGeneric")
|
|
96
|
+
def get_parameters_from_generic_cmd_template_script(id:int = typer.Option(..., help='Id (Command template)'),
|
|
97
|
+
userScriptPath:str = typer.Option(None, help='Path to executable file/script')):
|
|
98
|
+
"""List command template parameters from generic command template"""
|
|
99
|
+
try:
|
|
100
|
+
utils.print_and_log("Fetching command template parameters from generic command template …")
|
|
101
|
+
body = {
|
|
102
|
+
"_preload_content": False,
|
|
103
|
+
"body": {
|
|
104
|
+
"UserScriptPath": userScriptPath,
|
|
105
|
+
"CommandTemplateId": id,
|
|
106
|
+
"ProjectId": get_hpc_project()["Id"],
|
|
107
|
+
"SessionCode": utils.load_stored_session()
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
response = heappeCore.ClusterInformationApi(configuration.get_api_instance()).heappe_cluster_information_request_command_template_parameters_name_post(**body)
|
|
112
|
+
print(f"\nCommand template parameters:\n{json.dumps(json.loads(response.data), indent = 3)}")
|
|
113
|
+
|
|
114
|
+
except rest.ApiException as exception:
|
|
115
|
+
try:
|
|
116
|
+
response_data = json.loads(exception.body)
|
|
117
|
+
raise exceptions.Py4HEAppEAPIException(response_data['title'], response_data['detail'], response_data['status']) from None
|
|
118
|
+
except json.JSONDecodeError:
|
|
119
|
+
raise exceptions.Py4HEAppEException("Link to a HEAppE instance is not set or valid. Please check Conf Init option.") from None
|
|
120
|
+
|
|
121
|
+
except exceptions.Py4HEAppEAPIInternalException as exception:
|
|
122
|
+
raise exceptions.Py4HEAppEException(exception.message) from None
|
|
123
|
+
|
|
124
|
+
except exceptions.Py4HEAppEInternalException as exception:
|
|
125
|
+
raise exceptions.Py4HEAppEException(exception.message) from None
|
|
126
|
+
|
|
127
|
+
except Exception as exception:
|
|
128
|
+
raise exceptions.Py4HEAppEInternalException(f"Other exception: {str(exception)}") from None
|
|
129
|
+
|
|
130
|
+
@app.command(name="ClusterNodeUsage")
|
|
131
|
+
def get_cluster_node_usage(clusterNodeId :int = typer.Option(default=..., help='Id (Cluster node type)')):
|
|
132
|
+
"""Cluster node usage information"""
|
|
133
|
+
try:
|
|
134
|
+
utils.print_and_log("Fetching cluster information …")
|
|
135
|
+
parameters = {
|
|
136
|
+
"_preload_content": False,
|
|
137
|
+
"ClusterNodeId": clusterNodeId,
|
|
138
|
+
"ProjectId": get_hpc_project()["Id"],
|
|
139
|
+
"SessionCode": utils.load_stored_session(),
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
response= heappeCore.ClusterInformationApi(configuration.get_api_instance()).heappe_cluster_information_current_cluster_node_usage_get(**parameters)
|
|
143
|
+
print(f"\nCluster node type usage:\n{json.dumps(json.loads(response.data), indent = 3)}")
|
|
144
|
+
|
|
145
|
+
except rest.ApiException as exception:
|
|
146
|
+
try:
|
|
147
|
+
response_data = json.loads(exception.body)
|
|
148
|
+
raise exceptions.Py4HEAppEAPIException(response_data['title'], response_data['detail'], response_data['status']) from None
|
|
149
|
+
except json.JSONDecodeError:
|
|
150
|
+
raise exceptions.Py4HEAppEException("Link to a HEAppE instance is not set or valid. Please check Conf Init option.") from None
|
|
151
|
+
|
|
152
|
+
except exceptions.Py4HEAppEAPIInternalException as exception:
|
|
153
|
+
raise exceptions.Py4HEAppEException(exception.message) from None
|
|
154
|
+
|
|
155
|
+
except exceptions.Py4HEAppEInternalException as exception:
|
|
156
|
+
raise exceptions.Py4HEAppEException(exception.message) from None
|
|
157
|
+
|
|
158
|
+
except Exception as exception:
|
|
159
|
+
raise exceptions.Py4HEAppEInternalException(f"Other exception: {str(exception)}") from None
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
if __name__ == '__main__':
|
|
163
|
+
app()
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
# import json
|
|
2
|
+
# import typer
|
|
3
|
+
|
|
4
|
+
# import heappeac_v4.cli.configuration as configuration
|
|
5
|
+
# import heappeac_v4.cli.information as infoCLI
|
|
6
|
+
# import heappeac_v4.core.base.utils as utils
|
|
7
|
+
# import heappeac_v4.core as heappeCore
|
|
8
|
+
|
|
9
|
+
# from heappeac_v4.core.base import exceptions
|
|
10
|
+
# from heappeac_v4.core import rest
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
# app = typer.Typer(name="JobMgmtCLI", no_args_is_help=True, pretty_exceptions_show_locals=False)
|
|
14
|
+
|
|
15
|
+
# @app.command(name="Create")
|
|
16
|
+
# def create_job():
|
|
17
|
+
# """Create HPC job"""
|
|
18
|
+
# try:
|
|
19
|
+
# print("Creating HPC Job ...")
|
|
20
|
+
# projectId : int = infoCLI.get_hpc_project()["Id"]
|
|
21
|
+
# parameters = {
|
|
22
|
+
# "_preload_content": False,
|
|
23
|
+
# "ProjectId": projectId,
|
|
24
|
+
# "SessionCode": utils.load_stored_session()
|
|
25
|
+
# }
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
# except rest.ApiException as exception:
|
|
30
|
+
# response_data=json.loads(exception.body)
|
|
31
|
+
# raise exceptions.Py4HEAppEException(response_data['title'], response_data['detail'], response_data['status']) from None
|
|
32
|
+
|
|
33
|
+
# except Exception as exception:
|
|
34
|
+
# raise exceptions.Py4HEAppEException("Link to a HEAppE instance is not set or valid. Please check Conf Init option.") from None
|
|
35
|
+
|
|
36
|
+
# @app.command(name="Submit")
|
|
37
|
+
# def submit_job(id:int = typer.Option(..., help='Created HPC Job Info Identifier')):
|
|
38
|
+
# """Submit created HPC job"""
|
|
39
|
+
# try:
|
|
40
|
+
# print("Submitting HPC Job ...")
|
|
41
|
+
# body = {
|
|
42
|
+
# "_preload_content": False,
|
|
43
|
+
# "CreatedJobInfoId": id,
|
|
44
|
+
# "SessionCode": utils.load_stored_session()
|
|
45
|
+
# }
|
|
46
|
+
|
|
47
|
+
# _ = heappeCore.JobManagementApi(configuration.get_api_instance()).heappe_job_management_submit_job_put(**body)
|
|
48
|
+
# print("Job submitted successfully")
|
|
49
|
+
|
|
50
|
+
# except rest.ApiException as exception:
|
|
51
|
+
# response_data=json.loads(exception.body)
|
|
52
|
+
# raise exceptions.Py4HEAppEException(response_data['title'], response_data['detail'], response_data['status']) from None
|
|
53
|
+
|
|
54
|
+
# except Exception as exception:
|
|
55
|
+
# raise exceptions.Py4HEAppEException("Link to a HEAppE instance is not set or valid. Please check Conf Init option.") from None
|
|
56
|
+
|
|
57
|
+
# @app.command(name="Cancel")
|
|
58
|
+
# def cancel_job(id:int = typer.Option(..., help='Created HPC Job Info Identifier')):
|
|
59
|
+
# """Cancel Execution of HPC job"""
|
|
60
|
+
# try:
|
|
61
|
+
# print("Cancellation Execution of HPC Job ...")
|
|
62
|
+
# body = {
|
|
63
|
+
# "_preload_content": False,
|
|
64
|
+
# "CreatedJobInfoId": id,
|
|
65
|
+
# "SessionCode": utils.load_stored_session()
|
|
66
|
+
# }
|
|
67
|
+
|
|
68
|
+
# _ = heappeCore.JobManagementApi(configuration.get_api_instance()).heappe_job_management_cancel_job_put(**body)
|
|
69
|
+
# print("Job cancelled successfully")
|
|
70
|
+
|
|
71
|
+
# except rest.ApiException as exception:
|
|
72
|
+
# response_data=json.loads(exception.body)
|
|
73
|
+
# raise exceptions.Py4HEAppEException(response_data['title'], response_data['detail'], response_data['status']) from None
|
|
74
|
+
|
|
75
|
+
# except Exception as exception:
|
|
76
|
+
# raise exceptions.Py4HEAppEException("Link to a HEAppE instance is not set or valid. Please check Conf Init option.") from None
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
# @app.command(name="Remove")
|
|
80
|
+
# def remove_job(id:int = typer.Option(..., help='Created HPC Job Info Identifier')):
|
|
81
|
+
# """Remove HPC job"""
|
|
82
|
+
# try:
|
|
83
|
+
# print("Removing of HPC Job ...")
|
|
84
|
+
# body = {
|
|
85
|
+
# "_preload_content": False,
|
|
86
|
+
# "CreatedJobInfoId": id,
|
|
87
|
+
# "SessionCode": utils.load_stored_session()
|
|
88
|
+
# }
|
|
89
|
+
|
|
90
|
+
# _ = heappeCore.JobManagementApi(configuration.get_api_instance()).heappe_job_management_delete_job_delete(**body)
|
|
91
|
+
# print("Job removed successfully")
|
|
92
|
+
|
|
93
|
+
# except rest.ApiException as exception:
|
|
94
|
+
# response_data=json.loads(exception.body)
|
|
95
|
+
# raise exceptions.Py4HEAppEException(response_data['title'], response_data['detail'], response_data['status']) from None
|
|
96
|
+
|
|
97
|
+
# except Exception as exception:
|
|
98
|
+
# raise exceptions.Py4HEAppEException("Link to a HEAppE instance is not set or valid. Please check Conf Init option.") from None
|
|
99
|
+
|
|
100
|
+
# @app.command(name="ListJobs")
|
|
101
|
+
# def remove_job():
|
|
102
|
+
# """Remove HPC job"""
|
|
103
|
+
# try:
|
|
104
|
+
# print("Removing of HPC Job ...")
|
|
105
|
+
# parameters = {
|
|
106
|
+
# "_preload_content": False,
|
|
107
|
+
# "SessionCode": utils.load_stored_session()
|
|
108
|
+
# }
|
|
109
|
+
|
|
110
|
+
# response= heappeCore.JobManagementApi(configuration.get_api_instance()).heappe_job_management_list_jobs_for_current_user_get(**parameters)
|
|
111
|
+
# print(json.dumps(response.data, indent = 3))
|
|
112
|
+
|
|
113
|
+
# except rest.ApiException as exception:
|
|
114
|
+
# response_data=json.loads(exception.body)
|
|
115
|
+
# raise exceptions.Py4HEAppEException(response_data['title'], response_data['detail'], response_data['status']) from None
|
|
116
|
+
|
|
117
|
+
# except Exception as exception:
|
|
118
|
+
# raise exceptions.Py4HEAppEException("Link to a HEAppE instance is not set or valid. Please check Conf Init option.") from None
|
|
119
|
+
|
|
120
|
+
# @app.command(name="ListJobs")
|
|
121
|
+
# def remove_job(id:int = typer.Option(..., help='Created HPC Job Info Identifier')):
|
|
122
|
+
# """Remove HPC job"""
|
|
123
|
+
# try:
|
|
124
|
+
# print("Removing of HPC Job ...")
|
|
125
|
+
# parameters = {
|
|
126
|
+
# "_preload_content": False,
|
|
127
|
+
# "CreatedJobInfoId": id,
|
|
128
|
+
# "SessionCode": utils.load_stored_session()
|
|
129
|
+
# }
|
|
130
|
+
|
|
131
|
+
# response = heappeCore.JobManagementApi(configuration.get_api_instance()).heappe_job_management_current_info_for_job_get(**parameters)
|
|
132
|
+
# print(json.dumps(response.data, indent = 3))
|
|
133
|
+
|
|
134
|
+
# except rest.ApiException as exception:
|
|
135
|
+
# response_data=json.loads(exception.body)
|
|
136
|
+
# raise exceptions.Py4HEAppEException(response_data['title'], response_data['detail'], response_data['status']) from None
|
|
137
|
+
|
|
138
|
+
# except Exception as exception:
|
|
139
|
+
# raise exceptions.Py4HEAppEException("Link to a HEAppE instance is not set or valid. Please check Conf Init option.") from None
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
# @app.command(name="CopyDataToTemp")
|
|
143
|
+
# def copy_data_to_temp(id:int = typer.Option(..., help='Created HPC Job Info Identifier'),
|
|
144
|
+
# path:str = typer.Option(..., help='Path containing data to be copied')):
|
|
145
|
+
# """Copy Data to Temporary location"""
|
|
146
|
+
# try:
|
|
147
|
+
# print("Copying HPC Job Data to Temporary location ...")
|
|
148
|
+
# body = {
|
|
149
|
+
# "_preload_content": False,
|
|
150
|
+
# "CreatedJobInfoId": id,
|
|
151
|
+
# "Path": path,
|
|
152
|
+
# "SessionCode": utils.load_stored_session()
|
|
153
|
+
# }
|
|
154
|
+
|
|
155
|
+
# response = heappeCore.JobManagementApi(configuration.get_api_instance()).heappe_job_management_copy_job_data_to_temp_post(**body)
|
|
156
|
+
# print(f"Specific data was successfully copied to temporary location. Hash for usage the data is: {response.data}")
|
|
157
|
+
|
|
158
|
+
# except rest.ApiException as exception:
|
|
159
|
+
# response_data=json.loads(exception.body)
|
|
160
|
+
# raise exceptions.Py4HEAppEException(response_data['title'], response_data['detail'], response_data['status']) from None
|
|
161
|
+
|
|
162
|
+
# except Exception as exception:
|
|
163
|
+
# raise exceptions.Py4HEAppEException("Link to a HEAppE instance is not set or valid. Please check Conf Init option.") from None
|
|
164
|
+
|
|
165
|
+
# @app.command(name="CopyDataFromTemp")
|
|
166
|
+
# def copy_data_from_temp(id:int = typer.Option(..., help='Created HPC Job Info Identifier'),
|
|
167
|
+
# temporaryHash:str = typer.Option(..., help='Path containing data to be copied')):
|
|
168
|
+
# """Copy Data From Temporary location"""
|
|
169
|
+
# try:
|
|
170
|
+
# print("Copying HPC Job Data from Temporary location to Job Directory...")
|
|
171
|
+
# body = {
|
|
172
|
+
# "_preload_content": False,
|
|
173
|
+
# "CreatedJobInfoId": id,
|
|
174
|
+
# "TempSessionCode": temporaryHash,
|
|
175
|
+
# "SessionCode": utils.load_stored_session()
|
|
176
|
+
# }
|
|
177
|
+
|
|
178
|
+
# response = heappeCore.JobManagementApi(configuration.get_api_instance()).heappe_job_management_copy_job_data_from_temp_post(**body)
|
|
179
|
+
# print(f"{response.data}")
|
|
180
|
+
|
|
181
|
+
# except rest.ApiException as exception:
|
|
182
|
+
# response_data=json.loads(exception.body)
|
|
183
|
+
# raise exceptions.Py4HEAppEException(response_data['title'], response_data['detail'], response_data['status']) from None
|
|
184
|
+
|
|
185
|
+
# except Exception as exception:
|
|
186
|
+
# raise exceptions.Py4HEAppEException("Link to a HEAppE instance is not set or valid. Please check Conf Init option.") from None
|
|
187
|
+
|
|
188
|
+
# @app.command(name="GetAllocatedNodes")
|
|
189
|
+
# def get_allocated_nodes_ip(id:int = typer.Option(..., help='Created HPC Job Info Identifier')):
|
|
190
|
+
# """Get Allocated Nodes IP Addresses for the HPC Job"""
|
|
191
|
+
# try:
|
|
192
|
+
# print("Getting Allocated Nodes IP Addresses for the HPC Job ...")
|
|
193
|
+
# parameters = {
|
|
194
|
+
# "_preload_content": False,
|
|
195
|
+
# "CreatedJobInfoId": id,
|
|
196
|
+
# "SessionCode": utils.load_stored_session()
|
|
197
|
+
# }
|
|
198
|
+
|
|
199
|
+
# response = heappeCore.JobManagementApi(configuration.get_api_instance()).heappe_job_management_allocated_nodes_ips_get(**parameters)
|
|
200
|
+
# print(f"HPC Job {id} uses the following nodes: {response.data}")
|
|
201
|
+
|
|
202
|
+
# except rest.ApiException as exception:
|
|
203
|
+
# response_data=json.loads(exception.body)
|
|
204
|
+
# raise exceptions.Py4HEAppEException(response_data['title'], response_data['detail'], response_data['status']) from None
|
|
205
|
+
|
|
206
|
+
# except Exception as exception:
|
|
207
|
+
# raise exceptions.Py4HEAppEException("Link to a HEAppE instance is not set or valid. Please check Conf Init option.") from None
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
# if __name__ == '__main__':
|
|
211
|
+
# app()
|
py4heappe/cli/report.py
ADDED
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import json
|
|
2
|
+
import typer
|
|
3
|
+
|
|
4
|
+
import py4heappe.cli.configuration as configuration
|
|
5
|
+
import py4heappe.core.base.utils as utils
|
|
6
|
+
import py4heappe.core as heappeCore
|
|
7
|
+
|
|
8
|
+
from datetime import datetime
|
|
9
|
+
from py4heappe.core.base import exceptions
|
|
10
|
+
from py4heappe.core import rest
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
app = typer.Typer(name="ReportCLI", no_args_is_help=True, pretty_exceptions_show_locals=False)
|
|
14
|
+
|
|
15
|
+
@app.command(name="GroupList")
|
|
16
|
+
def list_groups():
|
|
17
|
+
"""List associated user groups"""
|
|
18
|
+
try:
|
|
19
|
+
utils.print_and_log("Listing groups where the user is assigned …")
|
|
20
|
+
parameters = {
|
|
21
|
+
"_preload_content": False,
|
|
22
|
+
"SessionCode": utils.load_stored_session()
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
response = heappeCore.JobReportingApi(configuration.get_api_instance()).heappe_job_reporting_list_adaptor_user_groups_get(**parameters)
|
|
26
|
+
print(f"\nAssociated user groups:\n{json.dumps(json.loads(response.data), indent = 3)}")
|
|
27
|
+
|
|
28
|
+
except rest.ApiException as exception:
|
|
29
|
+
try:
|
|
30
|
+
response_data = json.loads(exception.body)
|
|
31
|
+
raise exceptions.Py4HEAppEAPIException(response_data['title'], response_data['detail'], response_data['status']) from None
|
|
32
|
+
except json.JSONDecodeError:
|
|
33
|
+
raise exceptions.Py4HEAppEException("Link to a HEAppE instance is not set or valid. Please check Conf Init option.") from None
|
|
34
|
+
|
|
35
|
+
except exceptions.Py4HEAppEAPIInternalException as exception:
|
|
36
|
+
raise exceptions.Py4HEAppEException(exception.message) from None
|
|
37
|
+
|
|
38
|
+
except exceptions.Py4HEAppEInternalException as exception:
|
|
39
|
+
raise exceptions.Py4HEAppEException(exception.message) from None
|
|
40
|
+
|
|
41
|
+
except Exception as exception:
|
|
42
|
+
raise exceptions.Py4HEAppEInternalException(f"Other exception: {str(exception)}") from None
|
|
43
|
+
|
|
44
|
+
@app.command(name="UserUsage")
|
|
45
|
+
def get_user_report(userId:int = typer.Option(..., help='Id (User)'),
|
|
46
|
+
startDate:str = typer.Option(None, help='Start Date with time (Format: YYYY-MM-DDTHH:mm:ss)'),
|
|
47
|
+
endDate:str = typer.Option(None, help='End Date with time (Format:YYYY-MM-DDTHH:mm:ss)')):
|
|
48
|
+
"""Resource usage report for user"""
|
|
49
|
+
try:
|
|
50
|
+
utils.print_and_log("Fetching usage report for user …")
|
|
51
|
+
parameters = {
|
|
52
|
+
"_preload_content": False,
|
|
53
|
+
"UserId": userId,
|
|
54
|
+
"StartTime": startDate if startDate is not None else "2000-01-01T00:00:00Z",
|
|
55
|
+
"EndTime": endDate if endDate is not None else datetime.now().strftime("%Y-%m-%dT%H:%M:%SZ"),
|
|
56
|
+
"SessionCode": utils.load_stored_session()
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
response = heappeCore.JobReportingApi(configuration.get_api_instance()).heappe_job_reporting_user_resource_usage_report_get(**parameters)
|
|
60
|
+
print(f"\nUser usage report:\n{json.dumps(json.loads(response.data), indent = 3)}")
|
|
61
|
+
|
|
62
|
+
except rest.ApiException as exception:
|
|
63
|
+
try:
|
|
64
|
+
response_data = json.loads(exception.body)
|
|
65
|
+
raise exceptions.Py4HEAppEAPIException(response_data['title'], response_data['detail'], response_data['status']) from None
|
|
66
|
+
except json.JSONDecodeError:
|
|
67
|
+
raise exceptions.Py4HEAppEException("Link to a HEAppE instance is not set or valid. Please check Conf Init option.") from None
|
|
68
|
+
|
|
69
|
+
except exceptions.Py4HEAppEAPIInternalException as exception:
|
|
70
|
+
raise exceptions.Py4HEAppEException(exception.message) from None
|
|
71
|
+
|
|
72
|
+
except exceptions.Py4HEAppEInternalException as exception:
|
|
73
|
+
raise exceptions.Py4HEAppEException(exception.message) from None
|
|
74
|
+
|
|
75
|
+
except Exception as exception:
|
|
76
|
+
raise exceptions.Py4HEAppEInternalException(f"Other exception: {str(exception)}") from None
|
|
77
|
+
|
|
78
|
+
@app.command(name="GroupUsage")
|
|
79
|
+
def get_group_report(groupId:int = typer.Option(..., help='Id (User group)'),
|
|
80
|
+
startDate:str = typer.Option(None, help='Start Date with time (Format: YYYY-MM-DDTHH:mm:ss)'),
|
|
81
|
+
endDate:str = typer.Option(None, help='End Date with time (Format:YYYY-MM-DDTHH:mm:ss)')):
|
|
82
|
+
"""Resource usage report for user group"""
|
|
83
|
+
try:
|
|
84
|
+
utils.print_and_log("Fetching usage report for user group …")
|
|
85
|
+
parameters = {
|
|
86
|
+
"_preload_content": False,
|
|
87
|
+
"GroupId": groupId,
|
|
88
|
+
"StartTime": startDate if startDate is not None else "2000-01-01T00:00:00Z",
|
|
89
|
+
"EndTime": endDate if endDate is not None else datetime.now().strftime("%Y-%m-%dT%H:%M:%SZ"),
|
|
90
|
+
"SessionCode": utils.load_stored_session()
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
response = heappeCore.JobReportingApi(configuration.get_api_instance()).heappe_job_reporting_user_group_resource_usage_report_get(**parameters)
|
|
94
|
+
print(f"\nUser group usage report:\n{json.dumps(json.loads(response.data), indent = 3)}")
|
|
95
|
+
|
|
96
|
+
except rest.ApiException as exception:
|
|
97
|
+
try:
|
|
98
|
+
response_data = json.loads(exception.body)
|
|
99
|
+
raise exceptions.Py4HEAppEAPIException(response_data['title'], response_data['detail'], response_data['status']) from None
|
|
100
|
+
except json.JSONDecodeError:
|
|
101
|
+
raise exceptions.Py4HEAppEException("Link to a HEAppE instance is not set or valid. Please check Conf Init option.") from None
|
|
102
|
+
|
|
103
|
+
except exceptions.Py4HEAppEAPIInternalException as exception:
|
|
104
|
+
raise exceptions.Py4HEAppEException(exception.message) from None
|
|
105
|
+
|
|
106
|
+
except exceptions.Py4HEAppEInternalException as exception:
|
|
107
|
+
raise exceptions.Py4HEAppEException(exception.message) from None
|
|
108
|
+
|
|
109
|
+
except Exception as exception:
|
|
110
|
+
raise exceptions.Py4HEAppEInternalException(f"Other exception: {str(exception)}") from None
|
|
111
|
+
|
|
112
|
+
@app.command(name="GroupUsageDetailed")
|
|
113
|
+
def get_detailed_jobs_report():
|
|
114
|
+
"""Deailed resource usage report for user groups"""
|
|
115
|
+
try:
|
|
116
|
+
utils.print_and_log("Fetching detailed usage report for user groups …")
|
|
117
|
+
parameters = {
|
|
118
|
+
"_preload_content": False,
|
|
119
|
+
"SessionCode": utils.load_stored_session()
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
response = heappeCore.JobReportingApi(configuration.get_api_instance()).heappe_job_reporting_jobs_detailed_report_get(**parameters)
|
|
123
|
+
print(f"\nDetailed user groups usage report:\n{json.dumps(json.loads(response.data), indent = 3)}")
|
|
124
|
+
|
|
125
|
+
except rest.ApiException as exception:
|
|
126
|
+
try:
|
|
127
|
+
response_data = json.loads(exception.body)
|
|
128
|
+
raise exceptions.Py4HEAppEAPIException(response_data['title'], response_data['detail'], response_data['status']) from None
|
|
129
|
+
except json.JSONDecodeError:
|
|
130
|
+
raise exceptions.Py4HEAppEException("Link to a HEAppE instance is not set or valid. Please check Conf Init option.") from None
|
|
131
|
+
|
|
132
|
+
except exceptions.Py4HEAppEAPIInternalException as exception:
|
|
133
|
+
raise exceptions.Py4HEAppEException(exception.message) from None
|
|
134
|
+
|
|
135
|
+
except exceptions.Py4HEAppEInternalException as exception:
|
|
136
|
+
raise exceptions.Py4HEAppEException(exception.message) from None
|
|
137
|
+
|
|
138
|
+
except Exception as exception:
|
|
139
|
+
raise exceptions.Py4HEAppEInternalException(f"Other exception: {str(exception)}") from None
|
|
140
|
+
|
|
141
|
+
@app.command(name="JobUsage")
|
|
142
|
+
def get_detailed_job_report(id:int = typer.Option(..., help='Id (Job)')):
|
|
143
|
+
"""Resource usage report for job"""
|
|
144
|
+
try:
|
|
145
|
+
utils.print_and_log("Fetching job usage report …")
|
|
146
|
+
parameters = {
|
|
147
|
+
"_preload_content": False,
|
|
148
|
+
"JobId": id,
|
|
149
|
+
"SessionCode": utils.load_stored_session()
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
response = heappeCore.JobReportingApi(configuration.get_api_instance()).heappe_job_reporting_resource_usage_report_for_job_get(**parameters)
|
|
153
|
+
print(f"\nJob usage report: \n{json.dumps(json.loads(response.data), indent = 3)}")
|
|
154
|
+
|
|
155
|
+
except rest.ApiException as exception:
|
|
156
|
+
try:
|
|
157
|
+
response_data = json.loads(exception.body)
|
|
158
|
+
raise exceptions.Py4HEAppEAPIException(response_data['title'], response_data['detail'], response_data['status']) from None
|
|
159
|
+
except json.JSONDecodeError:
|
|
160
|
+
raise exceptions.Py4HEAppEException("Link to a HEAppE instance is not set or valid. Please check Conf Init option.") from None
|
|
161
|
+
|
|
162
|
+
except exceptions.Py4HEAppEAPIInternalException as exception:
|
|
163
|
+
raise exceptions.Py4HEAppEException(exception.message) from None
|
|
164
|
+
|
|
165
|
+
except exceptions.Py4HEAppEInternalException as exception:
|
|
166
|
+
raise exceptions.Py4HEAppEException(exception.message) from None
|
|
167
|
+
|
|
168
|
+
except Exception as exception:
|
|
169
|
+
raise exceptions.Py4HEAppEInternalException(f"Other exception: {str(exception)}") from None
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
if __name__ == '__main__':
|
|
173
|
+
app()
|