cosmotech-acceleration-library 1.0.1__py3-none-any.whl → 2.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 (97) hide show
  1. cosmotech/coal/__init__.py +1 -1
  2. cosmotech/coal/aws/__init__.py +1 -9
  3. cosmotech/coal/aws/s3.py +181 -214
  4. cosmotech/coal/azure/adx/auth.py +2 -2
  5. cosmotech/coal/azure/adx/runner.py +13 -14
  6. cosmotech/coal/azure/adx/store.py +5 -86
  7. cosmotech/coal/azure/adx/tables.py +2 -2
  8. cosmotech/coal/azure/blob.py +6 -6
  9. cosmotech/coal/azure/storage.py +3 -3
  10. cosmotech/coal/cosmotech_api/__init__.py +0 -24
  11. cosmotech/coal/cosmotech_api/apis/__init__.py +14 -0
  12. cosmotech/coal/cosmotech_api/apis/dataset.py +103 -0
  13. cosmotech/coal/cosmotech_api/apis/meta.py +25 -0
  14. cosmotech/coal/cosmotech_api/apis/organization.py +24 -0
  15. cosmotech/coal/cosmotech_api/apis/run.py +38 -0
  16. cosmotech/coal/cosmotech_api/apis/runner.py +71 -0
  17. cosmotech/coal/cosmotech_api/apis/solution.py +23 -0
  18. cosmotech/coal/cosmotech_api/apis/workspace.py +108 -0
  19. cosmotech/coal/cosmotech_api/objects/__init__.py +9 -0
  20. cosmotech/coal/cosmotech_api/objects/connection.py +125 -0
  21. cosmotech/coal/cosmotech_api/objects/parameters.py +127 -0
  22. cosmotech/coal/postgresql/runner.py +56 -36
  23. cosmotech/coal/postgresql/store.py +60 -14
  24. cosmotech/coal/postgresql/utils.py +254 -0
  25. cosmotech/coal/store/output/__init__.py +0 -0
  26. cosmotech/coal/store/output/aws_channel.py +73 -0
  27. cosmotech/coal/store/output/az_storage_channel.py +42 -0
  28. cosmotech/coal/store/output/channel_interface.py +23 -0
  29. cosmotech/coal/store/output/channel_spliter.py +55 -0
  30. cosmotech/coal/store/output/postgres_channel.py +40 -0
  31. cosmotech/coal/utils/configuration.py +169 -0
  32. cosmotech/coal/utils/decorator.py +22 -0
  33. cosmotech/csm_data/commands/api/api.py +6 -19
  34. cosmotech/csm_data/commands/api/postgres_send_runner_metadata.py +20 -16
  35. cosmotech/csm_data/commands/api/run_load_data.py +7 -46
  36. cosmotech/csm_data/commands/api/wsf_load_file.py +14 -15
  37. cosmotech/csm_data/commands/api/wsf_send_file.py +12 -13
  38. cosmotech/csm_data/commands/s3_bucket_delete.py +16 -15
  39. cosmotech/csm_data/commands/s3_bucket_download.py +16 -16
  40. cosmotech/csm_data/commands/s3_bucket_upload.py +16 -14
  41. cosmotech/csm_data/commands/store/dump_to_s3.py +18 -16
  42. cosmotech/csm_data/commands/store/output.py +35 -0
  43. cosmotech/csm_data/commands/store/store.py +3 -4
  44. cosmotech/translation/coal/en-US/coal/cosmotech_api/initialization.yml +8 -0
  45. cosmotech/translation/coal/en-US/coal/services/dataset.yml +4 -14
  46. cosmotech/translation/coal/en-US/coal/store/output/data_interface.yml +1 -0
  47. cosmotech/translation/coal/en-US/coal/store/output/split.yml +6 -0
  48. cosmotech/translation/coal/en-US/coal/utils/configuration.yml +2 -0
  49. cosmotech/translation/csm_data/en-US/csm_data/commands/store/output.yml +7 -0
  50. {cosmotech_acceleration_library-1.0.1.dist-info → cosmotech_acceleration_library-2.0.0.dist-info}/METADATA +8 -9
  51. {cosmotech_acceleration_library-1.0.1.dist-info → cosmotech_acceleration_library-2.0.0.dist-info}/RECORD +55 -71
  52. cosmotech/coal/azure/functions.py +0 -72
  53. cosmotech/coal/cosmotech_api/connection.py +0 -96
  54. cosmotech/coal/cosmotech_api/dataset/__init__.py +0 -26
  55. cosmotech/coal/cosmotech_api/dataset/converters.py +0 -164
  56. cosmotech/coal/cosmotech_api/dataset/download/__init__.py +0 -19
  57. cosmotech/coal/cosmotech_api/dataset/download/adt.py +0 -119
  58. cosmotech/coal/cosmotech_api/dataset/download/common.py +0 -140
  59. cosmotech/coal/cosmotech_api/dataset/download/file.py +0 -216
  60. cosmotech/coal/cosmotech_api/dataset/download/twingraph.py +0 -188
  61. cosmotech/coal/cosmotech_api/dataset/utils.py +0 -132
  62. cosmotech/coal/cosmotech_api/parameters.py +0 -48
  63. cosmotech/coal/cosmotech_api/run.py +0 -25
  64. cosmotech/coal/cosmotech_api/run_data.py +0 -173
  65. cosmotech/coal/cosmotech_api/run_template.py +0 -108
  66. cosmotech/coal/cosmotech_api/runner/__init__.py +0 -28
  67. cosmotech/coal/cosmotech_api/runner/data.py +0 -38
  68. cosmotech/coal/cosmotech_api/runner/datasets.py +0 -364
  69. cosmotech/coal/cosmotech_api/runner/download.py +0 -146
  70. cosmotech/coal/cosmotech_api/runner/metadata.py +0 -42
  71. cosmotech/coal/cosmotech_api/runner/parameters.py +0 -157
  72. cosmotech/coal/cosmotech_api/twin_data_layer.py +0 -512
  73. cosmotech/coal/cosmotech_api/workspace.py +0 -127
  74. cosmotech/coal/utils/api.py +0 -68
  75. cosmotech/coal/utils/postgresql.py +0 -236
  76. cosmotech/csm_data/commands/api/rds_load_csv.py +0 -90
  77. cosmotech/csm_data/commands/api/rds_send_csv.py +0 -74
  78. cosmotech/csm_data/commands/api/rds_send_store.py +0 -74
  79. cosmotech/csm_data/commands/api/runtemplate_load_handler.py +0 -66
  80. cosmotech/csm_data/commands/api/tdl_load_files.py +0 -76
  81. cosmotech/csm_data/commands/api/tdl_send_files.py +0 -82
  82. cosmotech/orchestrator_plugins/csm-data/templates/api/rds_load_csv.json +0 -27
  83. cosmotech/orchestrator_plugins/csm-data/templates/api/rds_send_csv.json +0 -27
  84. cosmotech/orchestrator_plugins/csm-data/templates/api/rds_send_store.json +0 -27
  85. cosmotech/orchestrator_plugins/csm-data/templates/api/runtemplate_load_handler.json +0 -27
  86. cosmotech/orchestrator_plugins/csm-data/templates/api/tdl_load_files.json +0 -32
  87. cosmotech/orchestrator_plugins/csm-data/templates/api/tdl_send_files.json +0 -27
  88. cosmotech/translation/coal/en-US/coal/cosmotech_api/run_data.yml +0 -2
  89. cosmotech/translation/csm_data/en-US/csm_data/commands/api/rds_load_csv.yml +0 -13
  90. cosmotech/translation/csm_data/en-US/csm_data/commands/api/rds_send_csv.yml +0 -12
  91. cosmotech/translation/csm_data/en-US/csm_data/commands/api/rds_send_store.yml +0 -12
  92. cosmotech/translation/csm_data/en-US/csm_data/commands/api/tdl_load_files.yml +0 -14
  93. cosmotech/translation/csm_data/en-US/csm_data/commands/api/tdl_send_files.yml +0 -18
  94. {cosmotech_acceleration_library-1.0.1.dist-info → cosmotech_acceleration_library-2.0.0.dist-info}/WHEEL +0 -0
  95. {cosmotech_acceleration_library-1.0.1.dist-info → cosmotech_acceleration_library-2.0.0.dist-info}/entry_points.txt +0 -0
  96. {cosmotech_acceleration_library-1.0.1.dist-info → cosmotech_acceleration_library-2.0.0.dist-info}/licenses/LICENSE +0 -0
  97. {cosmotech_acceleration_library-1.0.1.dist-info → cosmotech_acceleration_library-2.0.0.dist-info}/top_level.txt +0 -0
@@ -1,132 +0,0 @@
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
- from typing import Dict, List, Any
9
-
10
- from cosmotech.coal.utils.logger import LOGGER
11
- from cosmotech.orchestrator.utils.translate import T
12
-
13
-
14
- def get_content_from_twin_graph_data(
15
- nodes: List[Dict], relationships: List[Dict], restore_names: bool = False
16
- ) -> Dict[str, List[Dict]]:
17
- """
18
- Extract content from twin graph data.
19
-
20
- When restore_names is True, the "id" value inside the "properties" field in the cypher query response is used
21
- instead of the numerical id found in the "id" field. When restore_names is set to False, this function
22
- keeps the previous behavior implemented when adding support for twingraph in v2 (default: False)
23
-
24
- Example with a sample of cypher response:
25
- [{
26
- n: {
27
- id: "50" <-- this id is used if restore_names is False
28
- label: "Customer"
29
- properties: {
30
- Satisfaction: 0
31
- SurroundingSatisfaction: 0
32
- Thirsty: false
33
- id: "Lars_Coret" <-- this id is used if restore_names is True
34
- }
35
- type: "NODE"
36
- }
37
- }]
38
-
39
- Args:
40
- nodes: List of node data from cypher query
41
- relationships: List of relationship data from cypher query
42
- restore_names: Whether to use property ID instead of node ID
43
-
44
- Returns:
45
- Dict mapping entity types to lists of entities
46
- """
47
- LOGGER.debug(
48
- T("coal.services.dataset.processing_graph_data").format(
49
- nodes_count=len(nodes),
50
- relationships_count=len(relationships),
51
- restore_names=restore_names,
52
- )
53
- )
54
-
55
- content = dict()
56
- # build keys
57
- for item in relationships:
58
- content[item["src"]["label"]] = list()
59
- content[item["dest"]["label"]] = list()
60
- content[item["rel"]["label"]] = list()
61
-
62
- # Process nodes
63
- for item in nodes:
64
- label = item["n"]["label"]
65
- props = item["n"]["properties"].copy() # Create a copy to avoid modifying the original
66
- if not restore_names:
67
- props.update({"id": item["n"]["id"]})
68
- content.setdefault(label, list())
69
- content[label].append(props)
70
-
71
- # Process relationships
72
- for item in relationships:
73
- src = item["src"]
74
- dest = item["dest"]
75
- rel = item["rel"]
76
- props = rel["properties"].copy() # Create a copy to avoid modifying the original
77
- content[rel["label"]].append(
78
- {
79
- "id": rel["id"],
80
- "source": src["properties"]["id"] if restore_names else src["id"],
81
- "target": dest["properties"]["id"] if restore_names else dest["id"],
82
- **props,
83
- }
84
- )
85
-
86
- # Log the number of entities by type
87
- for entity_type, entities in content.items():
88
- LOGGER.debug(T("coal.services.dataset.entity_count").format(entity_type=entity_type, count=len(entities)))
89
-
90
- return content
91
-
92
-
93
- def sheet_to_header(sheet_content: List[Dict]) -> List[str]:
94
- """
95
- Extract header fields from sheet content.
96
-
97
- Args:
98
- sheet_content: List of dictionaries representing sheet rows
99
-
100
- Returns:
101
- List of field names with id, source, and target fields first if present
102
- """
103
- LOGGER.debug(T("coal.services.dataset.extracting_headers").format(rows=len(sheet_content)))
104
-
105
- fieldnames = []
106
- has_src = False
107
- has_id = False
108
-
109
- for r in sheet_content:
110
- for k in r.keys():
111
- if k not in fieldnames:
112
- if k in ["source", "target"]:
113
- has_src = True
114
- elif k == "id":
115
- has_id = True
116
- else:
117
- fieldnames.append(k)
118
-
119
- # Ensure source/target and id fields come first
120
- if has_src:
121
- fieldnames = ["source", "target"] + fieldnames
122
- if has_id:
123
- fieldnames = ["id"] + fieldnames
124
-
125
- LOGGER.debug(
126
- T("coal.services.dataset.headers_extracted").format(
127
- count=len(fieldnames),
128
- fields=", ".join(fieldnames[:5]) + ("..." if len(fieldnames) > 5 else ""),
129
- )
130
- )
131
-
132
- return fieldnames
@@ -1,48 +0,0 @@
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
- Parameter handling functions.
10
-
11
- This module provides functions for handling parameters in solution templates.
12
- """
13
-
14
- import json
15
- import os
16
- import pathlib
17
- from csv import DictWriter
18
- from typing import List, Dict, Any
19
-
20
- from cosmotech.coal.utils.logger import LOGGER
21
- from cosmotech.orchestrator.utils.translate import T
22
-
23
-
24
- def write_parameters(
25
- parameter_folder: str, parameters: List[Dict[str, Any]], write_csv: bool, write_json: bool
26
- ) -> None:
27
- """
28
- Write parameters to CSV and/or JSON files.
29
-
30
- Args:
31
- parameter_folder: The folder to write the parameters to
32
- parameters: The parameters to write
33
- write_csv: Whether to write the parameters to a CSV file
34
- write_json: Whether to write the parameters to a JSON file
35
- """
36
- if write_csv:
37
- tmp_parameter_file = os.path.join(parameter_folder, "parameters.csv")
38
- LOGGER.info(T("coal.cosmotech_api.runner.generating_file").format(file=tmp_parameter_file))
39
- with open(tmp_parameter_file, "w") as _file:
40
- _w = DictWriter(_file, fieldnames=["parameterId", "value", "varType", "isInherited"])
41
- _w.writeheader()
42
- _w.writerows(parameters)
43
-
44
- if write_json:
45
- tmp_parameter_file = os.path.join(parameter_folder, "parameters.json")
46
- LOGGER.info(T("coal.cosmotech_api.runner.generating_file").format(file=tmp_parameter_file))
47
- with open(tmp_parameter_file, "w") as _file:
48
- json.dump(parameters, _file, indent=2)
@@ -1,25 +0,0 @@
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
- from typing import Any
8
- from typing import Optional
9
-
10
- import cosmotech_api
11
-
12
-
13
- def get_run_metadata(
14
- api_client: cosmotech_api.api_client.ApiClient,
15
- organization_id: str,
16
- workspace_id: str,
17
- runner_id: str,
18
- run_id: str,
19
- include: Optional[list[str]] = None,
20
- exclude: Optional[list[str]] = None,
21
- ) -> dict[str, Any]:
22
- run_api = cosmotech_api.RunApi(api_client)
23
-
24
- run: cosmotech_api.Run = run_api.get_run(organization_id, workspace_id, runner_id, run_id)
25
- return run.model_dump(by_alias=True, exclude_none=True, include=include, exclude=exclude, mode="json")
@@ -1,173 +0,0 @@
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"))
@@ -1,108 +0,0 @@
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
@@ -1,28 +0,0 @@
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
@@ -1,38 +0,0 @@
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