cosmotech-acceleration-library 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.
Files changed (141) hide show
  1. cosmotech/coal/__init__.py +8 -0
  2. cosmotech/coal/aws/__init__.py +23 -0
  3. cosmotech/coal/aws/s3.py +235 -0
  4. cosmotech/coal/azure/__init__.py +23 -0
  5. cosmotech/coal/azure/adx/__init__.py +26 -0
  6. cosmotech/coal/azure/adx/auth.py +125 -0
  7. cosmotech/coal/azure/adx/ingestion.py +329 -0
  8. cosmotech/coal/azure/adx/query.py +56 -0
  9. cosmotech/coal/azure/adx/runner.py +217 -0
  10. cosmotech/coal/azure/adx/store.py +255 -0
  11. cosmotech/coal/azure/adx/tables.py +118 -0
  12. cosmotech/coal/azure/adx/utils.py +71 -0
  13. cosmotech/coal/azure/blob.py +109 -0
  14. cosmotech/coal/azure/functions.py +72 -0
  15. cosmotech/coal/azure/storage.py +74 -0
  16. cosmotech/coal/cosmotech_api/__init__.py +36 -0
  17. cosmotech/coal/cosmotech_api/connection.py +96 -0
  18. cosmotech/coal/cosmotech_api/dataset/__init__.py +26 -0
  19. cosmotech/coal/cosmotech_api/dataset/converters.py +164 -0
  20. cosmotech/coal/cosmotech_api/dataset/download/__init__.py +19 -0
  21. cosmotech/coal/cosmotech_api/dataset/download/adt.py +119 -0
  22. cosmotech/coal/cosmotech_api/dataset/download/common.py +140 -0
  23. cosmotech/coal/cosmotech_api/dataset/download/file.py +216 -0
  24. cosmotech/coal/cosmotech_api/dataset/download/twingraph.py +188 -0
  25. cosmotech/coal/cosmotech_api/dataset/utils.py +132 -0
  26. cosmotech/coal/cosmotech_api/parameters.py +48 -0
  27. cosmotech/coal/cosmotech_api/run.py +25 -0
  28. cosmotech/coal/cosmotech_api/run_data.py +173 -0
  29. cosmotech/coal/cosmotech_api/run_template.py +108 -0
  30. cosmotech/coal/cosmotech_api/runner/__init__.py +28 -0
  31. cosmotech/coal/cosmotech_api/runner/data.py +38 -0
  32. cosmotech/coal/cosmotech_api/runner/datasets.py +364 -0
  33. cosmotech/coal/cosmotech_api/runner/download.py +146 -0
  34. cosmotech/coal/cosmotech_api/runner/metadata.py +42 -0
  35. cosmotech/coal/cosmotech_api/runner/parameters.py +157 -0
  36. cosmotech/coal/cosmotech_api/twin_data_layer.py +512 -0
  37. cosmotech/coal/cosmotech_api/workspace.py +127 -0
  38. cosmotech/coal/csm/__init__.py +6 -0
  39. cosmotech/coal/csm/engine/__init__.py +47 -0
  40. cosmotech/coal/postgresql/__init__.py +22 -0
  41. cosmotech/coal/postgresql/runner.py +93 -0
  42. cosmotech/coal/postgresql/store.py +98 -0
  43. cosmotech/coal/singlestore/__init__.py +17 -0
  44. cosmotech/coal/singlestore/store.py +100 -0
  45. cosmotech/coal/store/__init__.py +42 -0
  46. cosmotech/coal/store/csv.py +44 -0
  47. cosmotech/coal/store/native_python.py +25 -0
  48. cosmotech/coal/store/pandas.py +26 -0
  49. cosmotech/coal/store/pyarrow.py +23 -0
  50. cosmotech/coal/store/store.py +79 -0
  51. cosmotech/coal/utils/__init__.py +18 -0
  52. cosmotech/coal/utils/api.py +68 -0
  53. cosmotech/coal/utils/logger.py +10 -0
  54. cosmotech/coal/utils/postgresql.py +236 -0
  55. cosmotech/csm_data/__init__.py +6 -0
  56. cosmotech/csm_data/commands/__init__.py +6 -0
  57. cosmotech/csm_data/commands/adx_send_data.py +92 -0
  58. cosmotech/csm_data/commands/adx_send_runnerdata.py +119 -0
  59. cosmotech/csm_data/commands/api/__init__.py +6 -0
  60. cosmotech/csm_data/commands/api/api.py +50 -0
  61. cosmotech/csm_data/commands/api/postgres_send_runner_metadata.py +119 -0
  62. cosmotech/csm_data/commands/api/rds_load_csv.py +90 -0
  63. cosmotech/csm_data/commands/api/rds_send_csv.py +74 -0
  64. cosmotech/csm_data/commands/api/rds_send_store.py +74 -0
  65. cosmotech/csm_data/commands/api/run_load_data.py +120 -0
  66. cosmotech/csm_data/commands/api/runtemplate_load_handler.py +66 -0
  67. cosmotech/csm_data/commands/api/tdl_load_files.py +76 -0
  68. cosmotech/csm_data/commands/api/tdl_send_files.py +82 -0
  69. cosmotech/csm_data/commands/api/wsf_load_file.py +66 -0
  70. cosmotech/csm_data/commands/api/wsf_send_file.py +68 -0
  71. cosmotech/csm_data/commands/az_storage_upload.py +76 -0
  72. cosmotech/csm_data/commands/s3_bucket_delete.py +107 -0
  73. cosmotech/csm_data/commands/s3_bucket_download.py +118 -0
  74. cosmotech/csm_data/commands/s3_bucket_upload.py +128 -0
  75. cosmotech/csm_data/commands/store/__init__.py +6 -0
  76. cosmotech/csm_data/commands/store/dump_to_azure.py +120 -0
  77. cosmotech/csm_data/commands/store/dump_to_postgresql.py +107 -0
  78. cosmotech/csm_data/commands/store/dump_to_s3.py +169 -0
  79. cosmotech/csm_data/commands/store/list_tables.py +48 -0
  80. cosmotech/csm_data/commands/store/load_csv_folder.py +43 -0
  81. cosmotech/csm_data/commands/store/load_from_singlestore.py +96 -0
  82. cosmotech/csm_data/commands/store/reset.py +31 -0
  83. cosmotech/csm_data/commands/store/store.py +37 -0
  84. cosmotech/csm_data/main.py +57 -0
  85. cosmotech/csm_data/utils/__init__.py +6 -0
  86. cosmotech/csm_data/utils/click.py +18 -0
  87. cosmotech/csm_data/utils/decorators.py +75 -0
  88. cosmotech/orchestrator_plugins/csm-data/__init__.py +11 -0
  89. cosmotech/orchestrator_plugins/csm-data/templates/api/postgres_send_runner_metadata.json +40 -0
  90. cosmotech/orchestrator_plugins/csm-data/templates/api/rds_load_csv.json +27 -0
  91. cosmotech/orchestrator_plugins/csm-data/templates/api/rds_send_csv.json +27 -0
  92. cosmotech/orchestrator_plugins/csm-data/templates/api/rds_send_store.json +27 -0
  93. cosmotech/orchestrator_plugins/csm-data/templates/api/run_load_data.json +30 -0
  94. cosmotech/orchestrator_plugins/csm-data/templates/api/runtemplate_load_handler.json +27 -0
  95. cosmotech/orchestrator_plugins/csm-data/templates/api/tdl_load_files.json +32 -0
  96. cosmotech/orchestrator_plugins/csm-data/templates/api/tdl_send_files.json +27 -0
  97. cosmotech/orchestrator_plugins/csm-data/templates/api/try_api_connection.json +9 -0
  98. cosmotech/orchestrator_plugins/csm-data/templates/api/wsf_load_file.json +36 -0
  99. cosmotech/orchestrator_plugins/csm-data/templates/api/wsf_send_file.json +36 -0
  100. cosmotech/orchestrator_plugins/csm-data/templates/main/adx_send_runnerdata.json +29 -0
  101. cosmotech/orchestrator_plugins/csm-data/templates/main/az_storage_upload.json +25 -0
  102. cosmotech/orchestrator_plugins/csm-data/templates/main/s3_bucket_delete.json +31 -0
  103. cosmotech/orchestrator_plugins/csm-data/templates/main/s3_bucket_download.json +34 -0
  104. cosmotech/orchestrator_plugins/csm-data/templates/main/s3_bucket_upload.json +35 -0
  105. cosmotech/orchestrator_plugins/csm-data/templates/store/store_dump_to_azure.json +35 -0
  106. cosmotech/orchestrator_plugins/csm-data/templates/store/store_dump_to_postgresql.json +34 -0
  107. cosmotech/orchestrator_plugins/csm-data/templates/store/store_dump_to_s3.json +36 -0
  108. cosmotech/orchestrator_plugins/csm-data/templates/store/store_list_tables.json +15 -0
  109. cosmotech/orchestrator_plugins/csm-data/templates/store/store_load_csv_folder.json +18 -0
  110. cosmotech/orchestrator_plugins/csm-data/templates/store/store_load_from_singlestore.json +34 -0
  111. cosmotech/orchestrator_plugins/csm-data/templates/store/store_reset.json +15 -0
  112. cosmotech/translation/coal/__init__.py +6 -0
  113. cosmotech/translation/coal/en-US/coal/common/data_transfer.yml +6 -0
  114. cosmotech/translation/coal/en-US/coal/common/errors.yml +9 -0
  115. cosmotech/translation/coal/en-US/coal/common/file_operations.yml +6 -0
  116. cosmotech/translation/coal/en-US/coal/common/progress.yml +6 -0
  117. cosmotech/translation/coal/en-US/coal/common/timing.yml +5 -0
  118. cosmotech/translation/coal/en-US/coal/common/validation.yml +8 -0
  119. cosmotech/translation/coal/en-US/coal/cosmotech_api/connection.yml +10 -0
  120. cosmotech/translation/coal/en-US/coal/cosmotech_api/run_data.yml +2 -0
  121. cosmotech/translation/coal/en-US/coal/cosmotech_api/run_template.yml +8 -0
  122. cosmotech/translation/coal/en-US/coal/cosmotech_api/runner.yml +16 -0
  123. cosmotech/translation/coal/en-US/coal/cosmotech_api/solution.yml +5 -0
  124. cosmotech/translation/coal/en-US/coal/cosmotech_api/workspace.yml +7 -0
  125. cosmotech/translation/coal/en-US/coal/services/adx.yml +59 -0
  126. cosmotech/translation/coal/en-US/coal/services/api.yml +8 -0
  127. cosmotech/translation/coal/en-US/coal/services/azure_storage.yml +14 -0
  128. cosmotech/translation/coal/en-US/coal/services/database.yml +19 -0
  129. cosmotech/translation/coal/en-US/coal/services/dataset.yml +68 -0
  130. cosmotech/translation/coal/en-US/coal/services/postgresql.yml +28 -0
  131. cosmotech/translation/coal/en-US/coal/services/s3.yml +9 -0
  132. cosmotech/translation/coal/en-US/coal/solution.yml +3 -0
  133. cosmotech/translation/coal/en-US/coal/web.yml +2 -0
  134. cosmotech/translation/csm_data/__init__.py +6 -0
  135. cosmotech/translation/csm_data/en-US/csm-data.yml +434 -0
  136. cosmotech_acceleration_library-1.0.0.dist-info/METADATA +255 -0
  137. cosmotech_acceleration_library-1.0.0.dist-info/RECORD +141 -0
  138. cosmotech_acceleration_library-1.0.0.dist-info/WHEEL +5 -0
  139. cosmotech_acceleration_library-1.0.0.dist-info/entry_points.txt +2 -0
  140. cosmotech_acceleration_library-1.0.0.dist-info/licenses/LICENSE +17 -0
  141. cosmotech_acceleration_library-1.0.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,173 @@
1
+ # Copyright (C) - 2023 - 2025 - Cosmo Tech
2
+ # This document and all information contained herein is the exclusive property -
3
+ # including all intellectual property rights pertaining thereto - of Cosmo Tech.
4
+ # Any use, reproduction, translation, broadcasting, transmission, distribution,
5
+ # etc., to any person is prohibited unless it has been previously and
6
+ # specifically authorized by written means by Cosmo Tech.
7
+
8
+ """
9
+ Run Data Service operations module.
10
+
11
+ This module provides functions for interacting with the Run Data Service,
12
+ including sending and loading data.
13
+ """
14
+
15
+ import json
16
+ import pathlib
17
+ from csv import DictReader, DictWriter
18
+ from typing import Dict, List, Any, Optional, Set
19
+
20
+ from cosmotech_api import SendRunDataRequest, RunDataQuery
21
+ from cosmotech_api.api.run_api import RunApi
22
+
23
+ from cosmotech.coal.cosmotech_api.connection import get_api_client
24
+ from cosmotech.coal.store.store import Store
25
+ from cosmotech.coal.store.native_python import convert_table_as_pylist
26
+ from cosmotech.coal.utils.logger import LOGGER
27
+ from cosmotech.orchestrator.utils.translate import T
28
+
29
+
30
+ def send_csv_to_run_data(
31
+ source_folder: str,
32
+ organization_id: str,
33
+ workspace_id: str,
34
+ runner_id: str,
35
+ run_id: str,
36
+ ) -> None:
37
+ """
38
+ Send CSV files to the Run Data Service.
39
+
40
+ Args:
41
+ source_folder: Folder containing CSV files
42
+ organization_id: Organization ID
43
+ workspace_id: Workspace ID
44
+ runner_id: Runner ID
45
+ run_id: Run ID
46
+ """
47
+ source_dir = pathlib.Path(source_folder)
48
+
49
+ if not source_dir.exists():
50
+ LOGGER.error(T("coal.common.file_operations.not_found").format(source_folder=source_dir))
51
+ raise FileNotFoundError(f"{source_dir} does not exist")
52
+
53
+ with get_api_client()[0] as api_client:
54
+ api_run = RunApi(api_client)
55
+ for csv_path in source_dir.glob("*.csv"):
56
+ with open(csv_path) as _f:
57
+ dr = DictReader(_f)
58
+ table_name = csv_path.name.replace(".csv", "")
59
+ LOGGER.info(T("coal.cosmotech_api.run_data.sending_to_table").format(table_name=f"CD_{table_name}"))
60
+ LOGGER.debug(T("coal.services.database.column_list").format(columns=dr.fieldnames))
61
+ data = []
62
+
63
+ for row in dr:
64
+ n_row = dict()
65
+ for k, v in row.items():
66
+ if isinstance(v, str):
67
+ try:
68
+ n_row[k] = json.loads(v)
69
+ except json.decoder.JSONDecodeError:
70
+ n_row[k] = v
71
+ else:
72
+ n_row[k] = v
73
+ data.append(n_row)
74
+
75
+ LOGGER.info(T("coal.services.database.row_count").format(count=len(data)))
76
+ api_run.send_run_data(
77
+ organization_id,
78
+ workspace_id,
79
+ runner_id,
80
+ run_id,
81
+ SendRunDataRequest(id=table_name, data=data),
82
+ )
83
+
84
+
85
+ def send_store_to_run_data(
86
+ store_folder: str,
87
+ organization_id: str,
88
+ workspace_id: str,
89
+ runner_id: str,
90
+ run_id: str,
91
+ ) -> None:
92
+ """
93
+ Send store data to the Run Data Service.
94
+
95
+ Args:
96
+ store_folder: Folder containing the store
97
+ organization_id: Organization ID
98
+ workspace_id: Workspace ID
99
+ runner_id: Runner ID
100
+ run_id: Run ID
101
+ """
102
+ source_dir = pathlib.Path(store_folder)
103
+
104
+ if not source_dir.exists():
105
+ LOGGER.error(T("coal.common.file_operations.not_found").format(source_folder=source_dir))
106
+ raise FileNotFoundError(f"{source_dir} does not exist")
107
+
108
+ with get_api_client()[0] as api_client:
109
+ api_run = RunApi(api_client)
110
+ _s = Store()
111
+ for table_name in _s.list_tables():
112
+ LOGGER.info(T("coal.cosmotech_api.run_data.sending_to_table").format(table_name=f"CD_{table_name}"))
113
+ data = convert_table_as_pylist(table_name)
114
+ if not len(data):
115
+ LOGGER.info(T("coal.services.database.no_rows"))
116
+ continue
117
+ fieldnames = _s.get_table_schema(table_name).names
118
+ for row in data:
119
+ for field in fieldnames:
120
+ if row[field] is None:
121
+ del row[field]
122
+ LOGGER.debug(T("coal.services.database.column_list").format(columns=fieldnames))
123
+ LOGGER.info(T("coal.services.database.row_count").format(count=len(data)))
124
+ api_run.send_run_data(
125
+ organization_id,
126
+ workspace_id,
127
+ runner_id,
128
+ run_id,
129
+ SendRunDataRequest(id=table_name, data=data),
130
+ )
131
+
132
+
133
+ def load_csv_from_run_data(
134
+ target_folder: str,
135
+ organization_id: str,
136
+ workspace_id: str,
137
+ runner_id: str,
138
+ run_id: str,
139
+ file_name: str = "results",
140
+ query: str = "SELECT table_name FROM information_schema.tables WHERE table_schema='public'",
141
+ ) -> None:
142
+ """
143
+ Load data from the Run Data Service and save it as a CSV file.
144
+
145
+ Args:
146
+ target_folder: Folder to save the CSV file to
147
+ organization_id: Organization ID
148
+ workspace_id: Workspace ID
149
+ runner_id: Runner ID
150
+ run_id: Run ID
151
+ file_name: Name of the CSV file to create
152
+ query: SQL query to execute
153
+ """
154
+ target_dir = pathlib.Path(target_folder)
155
+ target_dir.mkdir(parents=True, exist_ok=True)
156
+
157
+ with get_api_client()[0] as api_client:
158
+ api_run = RunApi(api_client)
159
+ query_result = api_run.query_run_data(
160
+ organization_id, workspace_id, runner_id, run_id, RunDataQuery(query=query)
161
+ )
162
+ if query_result.result:
163
+ LOGGER.info(T("coal.services.database.query_results").format(count=len(query_result.result)))
164
+ with open(target_dir / (file_name + ".csv"), "w") as _f:
165
+ headers = set()
166
+ for r in query_result.result:
167
+ headers = headers | set(r.keys())
168
+ dw = DictWriter(_f, fieldnames=sorted(headers))
169
+ dw.writeheader()
170
+ dw.writerows(query_result.result)
171
+ LOGGER.info(T("coal.services.database.saved_results").format(file=f"{target_dir / file_name}.csv"))
172
+ else:
173
+ LOGGER.info(T("coal.services.database.no_results"))
@@ -0,0 +1,108 @@
1
+ # Copyright (C) - 2023 - 2025 - Cosmo Tech
2
+ # This document and all information contained herein is the exclusive property -
3
+ # including all intellectual property rights pertaining thereto - of Cosmo Tech.
4
+ # Any use, reproduction, translation, broadcasting, transmission, distribution,
5
+ # etc., to any person is prohibited unless it has been previously and
6
+ # specifically authorized by written means by Cosmo Tech.
7
+
8
+ """
9
+ Run Template operations module.
10
+
11
+ This module provides functions for interacting with Run Templates,
12
+ including downloading and extracting handlers.
13
+ """
14
+
15
+ import pathlib
16
+ from io import BytesIO
17
+ from zipfile import BadZipfile, ZipFile
18
+ from typing import List
19
+
20
+ from cosmotech_api.api.solution_api import SolutionApi
21
+ from cosmotech_api.api.workspace_api import Workspace, WorkspaceApi
22
+ from cosmotech_api.exceptions import ServiceException
23
+
24
+ from cosmotech.coal.cosmotech_api.connection import get_api_client
25
+ from cosmotech.coal.utils.logger import LOGGER
26
+ from cosmotech.orchestrator.utils.translate import T
27
+
28
+
29
+ def load_run_template_handlers(
30
+ organization_id: str,
31
+ workspace_id: str,
32
+ run_template_id: str,
33
+ handler_list: str,
34
+ ) -> bool:
35
+ """
36
+ Download and extract run template handlers.
37
+
38
+ Args:
39
+ organization_id: Organization ID
40
+ workspace_id: Workspace ID
41
+ run_template_id: Run Template ID
42
+ handler_list: Comma-separated list of handlers to download
43
+
44
+ Returns:
45
+ True if all handlers were downloaded successfully, False otherwise
46
+
47
+ Raises:
48
+ ValueError: If the workspace or solution is not found
49
+ """
50
+ has_errors = False
51
+ with get_api_client()[0] as api_client:
52
+ api_w = WorkspaceApi(api_client)
53
+
54
+ LOGGER.info(T("coal.cosmotech_api.run_template.loading_solution"))
55
+ try:
56
+ r_data: Workspace = api_w.find_workspace_by_id(organization_id=organization_id, workspace_id=workspace_id)
57
+ except ServiceException as e:
58
+ LOGGER.error(
59
+ T("coal.cosmotech_api.workspace.not_found").format(
60
+ workspace_id=workspace_id, organization_id=organization_id
61
+ )
62
+ )
63
+ LOGGER.debug(T("coal.cosmotech_api.run_template.error_details").format(details=e.body))
64
+ raise ValueError(f"Workspace {workspace_id} not found in organization {organization_id}")
65
+ solution_id = r_data.solution.solution_id
66
+
67
+ api_sol = SolutionApi(api_client)
68
+ handler_list = handler_list.replace("handle-parameters", "parameters_handler")
69
+ root_path = pathlib.Path("../csm_orc_port")
70
+ template_path = root_path / run_template_id
71
+ for handler_id in handler_list.split(","):
72
+ handler_path: pathlib.Path = template_path / handler_id
73
+ LOGGER.info(
74
+ T("coal.cosmotech_api.run_template.querying_handler").format(
75
+ handler=handler_id, template=run_template_id
76
+ )
77
+ )
78
+ try:
79
+ rt_data = api_sol.download_run_template_handler(
80
+ organization_id=organization_id,
81
+ solution_id=solution_id,
82
+ run_template_id=run_template_id,
83
+ handler_id=handler_id,
84
+ )
85
+ except ServiceException as e:
86
+ LOGGER.error(
87
+ T("coal.cosmotech_api.run_template.handler_not_found").format(
88
+ handler=handler_id,
89
+ template=run_template_id,
90
+ solution=solution_id,
91
+ )
92
+ )
93
+ LOGGER.debug(T("coal.cosmotech_api.run_template.error_details").format(details=e.body))
94
+ has_errors = True
95
+ continue
96
+ LOGGER.info(T("coal.cosmotech_api.run_template.extracting_handler").format(path=handler_path.absolute()))
97
+ handler_path.mkdir(parents=True, exist_ok=True)
98
+
99
+ try:
100
+ with ZipFile(BytesIO(rt_data)) as _zip:
101
+ _zip.extractall(handler_path)
102
+ except BadZipfile:
103
+ LOGGER.error(T("coal.cosmotech_api.run_template.handler_not_zip").format(handler=handler_id))
104
+ has_errors = True
105
+ if has_errors:
106
+ LOGGER.error(T("coal.cosmotech_api.run_template.run_issues"))
107
+ return False
108
+ return True
@@ -0,0 +1,28 @@
1
+ # Copyright (C) - 2023 - 2025 - Cosmo Tech
2
+ # This document and all information contained herein is the exclusive property -
3
+ # including all intellectual property rights pertaining thereto - of Cosmo Tech.
4
+ # Any use, reproduction, translation, broadcasting, transmission, distribution,
5
+ # etc., to any person is prohibited unless it has been previously and
6
+ # specifically authorized by written means by Cosmo Tech.
7
+
8
+ """
9
+ Runner and Run data handling module.
10
+ """
11
+
12
+ # Re-export functions from submodules
13
+ from cosmotech.coal.cosmotech_api.runner.data import get_runner_data
14
+ from cosmotech.coal.cosmotech_api.runner.parameters import (
15
+ get_runner_parameters,
16
+ format_parameters_list,
17
+ write_parameters,
18
+ write_parameters_to_json,
19
+ write_parameters_to_csv,
20
+ )
21
+ from cosmotech.coal.cosmotech_api.runner.datasets import (
22
+ get_dataset_ids_from_runner,
23
+ download_dataset,
24
+ download_datasets,
25
+ dataset_to_file,
26
+ )
27
+ from cosmotech.coal.cosmotech_api.runner.download import download_runner_data
28
+ from cosmotech.coal.cosmotech_api.runner.metadata import get_runner_metadata
@@ -0,0 +1,38 @@
1
+ # Copyright (C) - 2023 - 2025 - Cosmo Tech
2
+ # This document and all information contained herein is the exclusive property -
3
+ # including all intellectual property rights pertaining thereto - of Cosmo Tech.
4
+ # Any use, reproduction, translation, broadcasting, transmission, distribution,
5
+ # etc., to any person is prohibited unless it has been previously and
6
+ # specifically authorized by written means by Cosmo Tech.
7
+
8
+ """
9
+ Core runner data retrieval functions.
10
+ """
11
+
12
+ from cosmotech_api.api.runner_api import RunnerApi
13
+ from cosmotech.coal.cosmotech_api.connection import get_api_client
14
+ from cosmotech.coal.utils.logger import LOGGER
15
+ from cosmotech.orchestrator.utils.translate import T
16
+
17
+
18
+ def get_runner_data(organization_id: str, workspace_id: str, runner_id: str):
19
+ """
20
+ Get runner data from the API.
21
+
22
+ Args:
23
+ organization_id: The ID of the organization
24
+ workspace_id: The ID of the workspace
25
+ runner_id: The ID of the runner
26
+
27
+ Returns:
28
+ Runner data object
29
+ """
30
+ LOGGER.info(T("coal.cosmotech_api.runner.loading_data"))
31
+ with get_api_client()[0] as api_client:
32
+ api_instance = RunnerApi(api_client)
33
+ runner_data = api_instance.get_runner(
34
+ organization_id=organization_id,
35
+ workspace_id=workspace_id,
36
+ runner_id=runner_id,
37
+ )
38
+ return runner_data