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,434 @@
1
+ commands:
2
+ main:
3
+ description: |
4
+ Cosmo Tech Data Interface
5
+
6
+ Command toolkit providing quick implementation of data connections to use inside the Cosmo Tech Platform
7
+
8
+ api:
9
+ description: |
10
+ Cosmo Tech API helper command
11
+
12
+ This command will inform you of which connection is available to use for the Cosmo Tech API
13
+
14
+ If no connection is available, will list all possible set of parameters and return an error code,
15
+
16
+ You can use this command in a csm-orc template to make sure that API connection is available.
17
+
18
+ tdl_send_files:
19
+ description: |
20
+ Reads a folder CSVs and send those to the Cosmo Tech API as a Dataset
21
+
22
+ CSVs must follow a given format:
23
+ - Nodes files must have an id column
24
+ - Relationship files must have id, src and dest columns
25
+
26
+ Non-existing relationship (aka dest or src does not point to existing node) won't trigger an error,
27
+ the relationship will not be created instead.
28
+
29
+ Requires a valid connection to the API to send the data
30
+
31
+ parameters:
32
+ api_url: The URI to a Cosmo Tech API instance
33
+ organization_id: An organization id for the Cosmo Tech API
34
+ workspace_id: A workspace id for the Cosmo Tech API
35
+ runner_id: A runner id for the Cosmo Tech API
36
+ dir: Path to the directory containing csvs to send
37
+ clear: Flag to clear the target dataset first (if set to True will clear the dataset before sending anything, irreversibly)
38
+
39
+ tdl_load_files:
40
+ description: |
41
+ Query a twingraph and loads all the data from it
42
+
43
+ Will create 1 csv file per node type / relationship type
44
+
45
+ The twingraph must have been populated using the "tdl-send-files" command for this to work correctly
46
+
47
+ Requires a valid connection to the API to send the data
48
+
49
+ parameters:
50
+ organization_id: An organization id for the Cosmo Tech API
51
+ workspace_id: A workspace id for the Cosmo Tech API
52
+ runner_id: A runner id for the Cosmo Tech API
53
+ dir: Path to the directory to write the results to
54
+
55
+ runtemplate_load_handler:
56
+ description: |
57
+ Uses environment variables to download cloud based Template steps
58
+
59
+ parameters:
60
+ organization_id: The id of an organization in the cosmotech api
61
+ workspace_id: The id of a solution in the cosmotech api
62
+ run-template_id: The name of the run template in the cosmotech api
63
+ handler_list: A list of handlers to download (comma separated)
64
+
65
+ run_load_data:
66
+ description: |
67
+ Download a runner data from the Cosmo Tech API
68
+ Requires a valid Azure connection either with:
69
+ - The AZ cli command: az login
70
+ - A triplet of env var AZURE_TENANT_ID, AZURE_CLIENT_ID, AZURE_CLIENT_SECRET
71
+
72
+ parameters:
73
+ organization_id: The id of an organization in the cosmotech api
74
+ workspace_id: The id of a workspace in the cosmotech api
75
+ runner_id: The id of a runner in the cosmotech api
76
+ parameters_absolute_path: A local folder to store the parameters content
77
+
78
+
79
+ rds_load_csv:
80
+ description: |
81
+ Load data from a runner's RDS database into a CSV file.
82
+
83
+ Executes a SQL query against the runner's RDS database and saves the results to a CSV file.
84
+ By default, it will list all tables in the public schema if no specific query is provided.
85
+ parameters:
86
+ target_folder: The folder where the csv will be written
87
+ organization_id: An organization id for the Cosmo Tech API
88
+ workspace_id: A workspace id for the Cosmo Tech API
89
+ runner_id: A runner id for the Cosmo Tech API
90
+ run_id: A run id for the Cosmo Tech API
91
+ file_name: A file name to write the query results
92
+ query: SQL query to execute (defaults to listing all tables in public schema)
93
+
94
+ rds_send_csv:
95
+ description: |
96
+ Send CSV files to a runner's RDS database.
97
+
98
+ Takes all CSV files from a source folder and sends their content to the runner's RDS database.
99
+ Each CSV file will be sent to a table named after the file (without the .csv extension).
100
+ The table name will be prefixed with "CD_" in the database.
101
+ parameters:
102
+ source_folder: The folder containing csvs to send
103
+ organization_id: An organization id for the Cosmo Tech API
104
+ workspace_id: A workspace id for the Cosmo Tech API
105
+ runner_id: A runner id for the Cosmo Tech API
106
+ run_id: A run id for the Cosmo Tech API
107
+
108
+ rds_send_store:
109
+ description: |
110
+ Send data from a store to a runner's RDS database.
111
+
112
+ Takes all tables from a store and sends their content to the runner's RDS database.
113
+ Each table will be sent to a table with the same name, prefixed with "CD_" in the database.
114
+ Null values in rows will be removed before sending.
115
+ parameters:
116
+ store_folder: The folder containing the store files
117
+ organization_id: An organization id for the Cosmo Tech API
118
+ workspace_id: A workspace id for the Cosmo Tech API
119
+ runner_id: A runner id for the Cosmo Tech API
120
+ run_id: A run id for the Cosmo Tech API
121
+
122
+ wsf_load_file:
123
+ description: |
124
+ Download files from a workspace.
125
+
126
+ Downloads files from a specified path in a workspace to a local target folder.
127
+ If the workspace path ends with '/', it will be treated as a folder and all files within will be downloaded.
128
+ parameters:
129
+ organization_id: An organization id for the Cosmo Tech API
130
+ workspace_id: A workspace id for the Cosmo Tech API
131
+ workspace_path: Path inside the workspace to load (end with '/' for a folder)
132
+ target_folder: Folder in which to send the downloaded file
133
+
134
+ wsf_send_file:
135
+ description: |
136
+ Upload a file to a workspace.
137
+
138
+ Uploads a local file to a specified path in a workspace.
139
+ If the workspace path ends with '/', the file will be uploaded to that folder with its original name.
140
+ Otherwise, the file will be uploaded with the name specified in the workspace path.
141
+ parameters:
142
+ organization_id: An organization id for the Cosmo Tech API
143
+ workspace_id: A workspace id for the Cosmo Tech API
144
+ file_path: Path to the file to send as a workspace file
145
+ workspace_path: Path inside the workspace to store the file (end with '/' for a folder)
146
+ overwrite: Flag to overwrite the target file if it exists
147
+
148
+ postgres_send_runner_metadata:
149
+ description: |
150
+ Send runner metadata to a PostgreSQL database.
151
+
152
+ Creates or updates a table in PostgreSQL with runner metadata including id, name, last run id, and run template id.
153
+ The table will be created if it doesn't exist, and existing records will be updated based on the runner id.
154
+ parameters:
155
+ organization_id: An organization id for the Cosmo Tech API
156
+ workspace_id: A workspace id for the Cosmo Tech API
157
+ runner_id: A runner id for the Cosmo Tech API
158
+ table_prefix: Prefix to add to the table name
159
+ postgres_host: PostgreSQL host URI
160
+ postgres_port: PostgreSQL database port
161
+ postgres_db: PostgreSQL database name
162
+ postgres_schema: PostgreSQL schema name
163
+ postgres_user: PostgreSQL connection user name
164
+ postgres_password: PostgreSQL connection password
165
+
166
+ store:
167
+ description: |
168
+ CoAL Data Store command group
169
+
170
+ This group of commands will give you helper commands to interact with the datastore
171
+
172
+ list_tables:
173
+ description: |
174
+ Running this command will list the existing tables in your datastore
175
+ parameters:
176
+ store_folder: The folder containing the store files
177
+ schema: Display the schema of the tables
178
+
179
+ reset:
180
+ description: |
181
+ Running this command will reset the state of your store
182
+ parameters:
183
+ store_folder: The folder containing the store files
184
+
185
+ load_csv_folder:
186
+ description: |
187
+ Running this command will find all csvs in the given folder and put them in the store
188
+ parameters:
189
+ store_folder: The folder containing the store files
190
+ csv_folder: The folder containing the csv files to store
191
+
192
+ load_from_singlestore:
193
+ description: |
194
+ Load data from SingleStore tables into the store.
195
+ Will download everything from a given SingleStore database following some configuration into the store.
196
+
197
+ Make use of the singlestoredb to access to SingleStore
198
+
199
+ More information is available on this page:
200
+ [https://docs.singlestore.com/cloud/developer-resources/connect-with-application-development-tools/connect-with-python/connect-using-the-singlestore-python-client/]
201
+ parameters:
202
+ singlestore_host: SingleStore instance URI
203
+ singlestore_port: SingleStore port
204
+ singlestore_db: SingleStore database name
205
+ singlestore_user: SingleStore connection user name
206
+ singlestore_password: SingleStore connection password
207
+ singlestore_tables: SingleStore table names to fetched (separated by comma)
208
+ store_folder: The folder containing the store files
209
+
210
+ dump_to_postgresql:
211
+ description: |
212
+ Running this command will dump your store to a given postgresql database
213
+
214
+ Tables names from the store will be prepended with table-prefix in target database
215
+
216
+ The postgresql user must have USAGE granted on the schema for this script to work due to the use of the command COPY FROM STDIN
217
+
218
+ You can simply give him that grant by running the command:
219
+ GRANT USAGE ON SCHEMA <schema> TO <username>
220
+ parameters:
221
+ store_folder: The folder containing the store files
222
+ table_prefix: Prefix to add to the table name
223
+ postgres_host: PostgreSQL host URI
224
+ postgres_port: PostgreSQL database port
225
+ postgres_db: PostgreSQL database name
226
+ postgres_schema: PostgreSQL schema name
227
+ postgres_user: PostgreSQL connection user name
228
+ postgres_password: PostgreSQL connection password
229
+ replace: Append data on existing tables
230
+
231
+ dump_to_azure:
232
+ description: |
233
+ Dump a datastore to a Azure storage account.
234
+
235
+ Will upload everything from a given data store to a Azure storage container.
236
+
237
+ 3 modes currently exists:
238
+ - sqlite: will dump the data store underlying database as is
239
+ - csv: will convert every table of the datastore to csv and send them as separate files
240
+ - parquet: will convert every table of the datastore to parquet and send them as separate files
241
+
242
+ Make use of the azure.storage.blob library to access the container
243
+
244
+ More information is available on this page:
245
+ [https://learn.microsoft.com/en-us/azure/storage/blobs/storage-quickstart-blobs-python?tabs=managed-identity%2Croles-azure-portal%2Csign-in-azure-cli&pivots=blob-storage-quickstart-scratch]
246
+ parameters:
247
+ store_folder: The folder containing the store files
248
+ output_type: Choose the type of file output to use (sqlite, csv, parquet)
249
+ account_name: The account name on Azure to upload to
250
+ container_name: The container name on Azure to upload to
251
+ prefix: A prefix by which all uploaded files should start with in the container
252
+ tenant_id: Tenant Identity used to connect to Azure storage system
253
+ client_id: Client Identity used to connect to Azure storage system
254
+ client_secret: Client Secret tied to the ID used to connect to Azure storage system
255
+
256
+ dump_to_s3:
257
+ description: |
258
+ Dump a datastore to a S3
259
+
260
+ Will upload everything from a given data store to a S3 bucket.
261
+
262
+ 3 modes currently exists:
263
+ - sqlite: will dump the data store underlying database as is
264
+ - csv: will convert every table of the datastore to csv and send them as separate files
265
+ - parquet: will convert every table of the datastore to parquet and send them as separate files
266
+
267
+ Giving a prefix will add it to every upload (finishing the prefix with a "/" will allow to upload in a folder inside the bucket)
268
+
269
+ Make use of the boto3 library to access the bucket
270
+
271
+ More information is available on this page:
272
+ [https://boto3.amazonaws.com/v1/documentation/api/latest/guide/configuration.html]
273
+ parameters:
274
+ store_folder: The folder containing the store files
275
+ output_type: Choose the type of file output to use (sqlite, csv, parquet)
276
+ bucket_name: The bucket on S3 to upload to
277
+ prefix: A prefix by which all uploaded files should start with in the bucket
278
+ use_ssl: Use SSL to secure connection to S3
279
+ s3_url: URL to connect to the S3 system
280
+ access_id: Identity used to connect to the S3 system
281
+ secret_key: Secret tied to the ID used to connect to the S3 system
282
+ ssl_cert_bundle: Path to an alternate CA Bundle to validate SSL connections
283
+
284
+ storage:
285
+ s3_bucket_upload:
286
+ description: |
287
+ Upload a folder to a S3 Bucket
288
+
289
+ Will upload everything from a given folder to a S3 bucket. If a single file is passed only it will be uploaded, and recursive will be ignored
290
+
291
+ Giving a prefix will add it to every upload (finishing the prefix with a "/" will allow to upload in a folder inside the bucket)
292
+
293
+ Make use of the boto3 library to access the bucket
294
+
295
+ More information is available on this page:
296
+ [https://boto3.amazonaws.com/v1/documentation/api/latest/guide/configuration.html]
297
+ parameters:
298
+ source_folder: The folder/file to upload to the target bucket
299
+ recursive: Recursively send the content of every folder inside the starting folder to the bucket
300
+ bucket_name: The bucket on S3 to upload to
301
+ prefix: A prefix by which all uploaded files should start with in the bucket
302
+ use_ssl: Use SSL to secure connection to S3
303
+ s3_url: URL to connect to the S3 system
304
+ access_id: Identity used to connect to the S3 system
305
+ secret_key: Secret tied to the ID used to connect to the S3 system
306
+ ssl_cert_bundle: Path to an alternate CA Bundle to validate SSL connections
307
+
308
+ s3_bucket_download:
309
+ description: |
310
+ Download S3 bucket content to a given folder
311
+
312
+ Will download everything in the bucket unless a prefix is set, then only file following the given prefix will be downloaded
313
+
314
+ Make use of the boto3 library to access the bucket
315
+
316
+ More information is available on this page:
317
+ [https://boto3.amazonaws.com/v1/documentation/api/latest/guide/configuration.html]
318
+ parameters:
319
+ target_folder: The folder in which to download the bucket content
320
+ bucket_name: The bucket on S3 to download
321
+ prefix_filter: A prefix by which all downloaded files should start in the bucket
322
+ use_ssl: Use SSL to secure connection to S3
323
+ s3_url: URL to connect to the S3 system
324
+ access_id: Identity used to connect to the S3 system
325
+ secret_key: Secret tied to the ID used to connect to the S3 system
326
+ ssl_cert_bundle: Path to an alternate CA Bundle to validate SSL connections
327
+
328
+ s3_bucket_delete:
329
+ description: |
330
+ Delete S3 bucket content to a given folder
331
+
332
+ Will delete everything in the bucket unless a prefix is set, then only file following the given prefix will be deleted
333
+
334
+ Make use of the boto3 library to access the bucket
335
+
336
+ More information is available on this page:
337
+ [https://boto3.amazonaws.com/v1/documentation/api/latest/guide/configuration.html]
338
+ parameters:
339
+ bucket_name: The bucket on S3 to delete
340
+ prefix_filter: A prefix by which all deleted files should start in the bucket
341
+ use_ssl: Use SSL to secure connection to S3
342
+ s3_url: URL to connect to the S3 system
343
+ access_id: Identity used to connect to the S3 system
344
+ secret_key: Secret tied to the ID used to connect to the S3 system
345
+ ssl_cert_bundle: Path to an alternate CA Bundle to validate SSL connections
346
+
347
+ az_storage_upload:
348
+ description: |
349
+ Upload a folder to an Azure Storage Blob
350
+ parameters:
351
+ source_folder: The folder/file to upload to the target blob storage
352
+ recursive: Recursively send the content of every folder inside the starting folder to the blob storage
353
+ blob_name: The blob name in the Azure Storage service to upload to
354
+ prefix: A prefix by which all uploaded files should start with in the blob storage
355
+ az_storage_sas_url: SAS url allowing access to the AZ storage container
356
+
357
+ adx_send_runnerdata:
358
+ description: |
359
+ Uses environment variables to send content of CSV files to ADX
360
+ Requires a valid Azure connection either with:
361
+ - The AZ cli command: az login
362
+ - A triplet of env var AZURE_TENANT_ID, AZURE_CLIENT_ID, AZURE_CLIENT_SECRET
363
+ parameters:
364
+ dataset_absolute_path: A local folder to store the main dataset content
365
+ parameters_absolute_path: A local folder to store the parameters content
366
+ runner_id: the Runner Id to add to records
367
+ adx_uri: the ADX cluster path (URI info can be found into ADX cluster page)
368
+ adx_ingest_uri: The ADX cluster ingest path (URI info can be found into ADX cluster page)
369
+ database_name: The targeted database name
370
+ send_parameters: whether or not to send parameters (parameters path is mandatory then)
371
+ send_datasets: whether or not to send datasets (parameters path is mandatory then)
372
+ wait: Toggle waiting for the ingestion results
373
+
374
+ legacy:
375
+ description: |
376
+ Cosmo Tech legacy API group
377
+
378
+ This group will allow you to connect to the CosmoTech API and migrate solutions from pre-3.0 version to 3.X compatible solutions
379
+
380
+ generate_orchestrator:
381
+ description: |
382
+ Generate an orchestrator configuration file from a solution's run template.
383
+
384
+ This command group provides tools to generate orchestrator configuration files either from a local solution file
385
+ or directly from the Cosmo Tech API.
386
+
387
+ from_file:
388
+ description: |
389
+ Generate an orchestrator configuration from a local solution file.
390
+
391
+ parameters:
392
+ solution_file: Path to the solution file to read
393
+ output: Path where to write the generated configuration
394
+ run_template_id: The ID of the run template to use
395
+ describe: Show a description of the generated template after generation
396
+
397
+ from_api:
398
+ description: |
399
+ Generate an orchestrator configuration by fetching the solution from the API.
400
+ parameters:
401
+ output: Path where to write the generated configuration
402
+ organization_id: The id of an organization in the cosmotech api
403
+ workspace_id: The id of a solution in the cosmotech api
404
+ run_template_id: The name of the run template in the cosmotech api
405
+ describe: Show a description of the generated template after generation
406
+
407
+ init_local_parameter_folder:
408
+ description: |
409
+ Initialize a local parameter folder structure from a solution's run template.
410
+
411
+ This command group provides tools to create a local parameter folder structure either from a local solution file
412
+ or directly from the Cosmo Tech API. The folder will contain parameter files in CSV and/or JSON format.
413
+
414
+ solution:
415
+ description: |
416
+ Initialize parameter folder from a local solution file.
417
+
418
+ Parameters:
419
+ solution_file: Path to the solution file to read
420
+ output_folder: Path where to create the parameter folder structure
421
+ run_template_id: The ID of the run template to use
422
+ write_json: Toggle writing of parameters in json format
423
+ write_csv: Toggle writing of parameters in csv format
424
+
425
+ cloud:
426
+ description: |
427
+ Initialize parameter folder by fetching the solution from the API.
428
+ parameters:
429
+ output_folder: Path where to create the parameter folder structure
430
+ organization_id: The id of an organization in the cosmotech api
431
+ workspace_id: The id of a solution in the cosmotech api
432
+ run_template_id: The name of the run template in the cosmotech api
433
+ write_json: Toggle writing of parameters in json format
434
+ write_csv: Toggle writing of parameters in csv format
@@ -0,0 +1,255 @@
1
+ Metadata-Version: 2.4
2
+ Name: cosmotech_acceleration_library
3
+ Version: 1.0.0
4
+ Summary: Acceleration libraries for CosmoTech cloud based solution development
5
+ Author-email: Cosmo Tech <platform@cosmotech.com>
6
+ Project-URL: Homepage, https://www.cosmotech.com
7
+ Project-URL: Source, https://github.com/Cosmo-Tech/CosmoTech-Acceleration-Library
8
+ Project-URL: Documentation, https://cosmo-tech.github.io/CosmoTech-Acceleration-Library
9
+ Description-Content-Type: text/markdown
10
+ License-File: LICENSE
11
+ Requires-Dist: azure-functions~=1.20.0
12
+ Requires-Dist: azure-digitaltwins-core~=1.2.0
13
+ Requires-Dist: azure-identity~=1.16.1
14
+ Requires-Dist: azure-kusto-data~=4.4.1
15
+ Requires-Dist: azure-kusto-ingest~=4.4.1
16
+ Requires-Dist: tenacity~=8.3.0
17
+ Requires-Dist: python-keycloak~=4.7.3
18
+ Requires-Dist: redis==4.4.4
19
+ Requires-Dist: redisgraph_bulk_loader==0.10.2
20
+ Requires-Dist: cosmotech-api~=3.2
21
+ Requires-Dist: boto3~=1.35.19
22
+ Requires-Dist: requests~=2.32.3
23
+ Requires-Dist: singlestoredb~=1.10.0
24
+ Requires-Dist: cosmotech-run-orchestrator~=2.0.0
25
+ Requires-Dist: pyarrow~=17.0.0
26
+ Requires-Dist: adbc-driver-manager~=1.1.0
27
+ Requires-Dist: adbc-driver-sqlite~=1.1.0
28
+ Requires-Dist: adbc-driver-postgresql~=1.1.0
29
+ Requires-Dist: click~=8.1.7
30
+ Requires-Dist: rich-click~=1.7.3
31
+ Requires-Dist: click-log~=0.4.0
32
+ Requires-Dist: tqdm~=4.67.1
33
+ Requires-Dist: openpyxl~=3.1
34
+ Requires-Dist: pandas~=2.1
35
+ Requires-Dist: python-dateutil~=2.8
36
+ Requires-Dist: rich~=13.7
37
+ Requires-Dist: setuptools
38
+ Provides-Extra: doc
39
+ Requires-Dist: mkdocs~=1.5.3; extra == "doc"
40
+ Requires-Dist: mkdocs-click~=0.8.1; extra == "doc"
41
+ Requires-Dist: mkdocs-gen-files~=0.5.0; extra == "doc"
42
+ Requires-Dist: mkdocstrings[python]~=0.28.2; extra == "doc"
43
+ Requires-Dist: mkdocs-awesome-pages-plugin~=2.9.3; extra == "doc"
44
+ Requires-Dist: pymdown-extensions~=10.7; extra == "doc"
45
+ Requires-Dist: requirements-parser~=0.11.0; extra == "doc"
46
+ Requires-Dist: setuptools~=70.3.0; extra == "doc"
47
+ Requires-Dist: mike~=2.0.0; extra == "doc"
48
+ Requires-Dist: griffe~=1.5.7; extra == "doc"
49
+ Requires-Dist: mkdocs-include-dir-to-nav~=1.2.0; extra == "doc"
50
+ Requires-Dist: mkdocs-material[imaging]~=9.5.18; extra == "doc"
51
+ Requires-Dist: mkdocs-table-reader-plugin~=2.0.3; extra == "doc"
52
+ Requires-Dist: mkdocs-literate-nav~=0.6.1; extra == "doc"
53
+ Provides-Extra: test
54
+ Requires-Dist: pytest; extra == "test"
55
+ Requires-Dist: pytest-docker; extra == "test"
56
+ Requires-Dist: pytest-cov; extra == "test"
57
+ Provides-Extra: extra
58
+ Requires-Dist: pandas~=2.2.2; extra == "extra"
59
+ Provides-Extra: dev
60
+ Requires-Dist: black==23.3.0; extra == "dev"
61
+ Requires-Dist: pre-commit==3.3.2; extra == "dev"
62
+ Provides-Extra: all
63
+ Requires-Dist: CosmoTech_Acceleration_Library[dev,doc,extra,test]; extra == "all"
64
+ Dynamic: license-file
65
+
66
+ # CosmoTech-Acceleration-Library (CoAL)
67
+
68
+ Acceleration library for CosmoTech cloud-based solution development.
69
+
70
+ ## Introduction
71
+
72
+ The CosmoTech Acceleration Library (CoAL) provides a comprehensive set of tools and utilities to accelerate the development of solutions based on the CosmoTech platform. It offers a unified interface for interacting with CosmoTech APIs, managing data, and integrating with various cloud services.
73
+
74
+ ## Main Components
75
+
76
+ ### csm-data
77
+
78
+ `csm-data` is a powerful CLI tool designed to help CosmoTech solution modelers and integrators interact with multiple systems. It provides ready-to-use commands to send and retrieve data from various systems where a CosmoTech API could be integrated.
79
+
80
+ ```bash
81
+ # Get help on available commands
82
+ csm-data --help
83
+
84
+ # Get help on specific command groups
85
+ csm-data api --help
86
+ ```
87
+
88
+ ### datastore
89
+
90
+ The datastore provides a way to maintain local data during simulations and comes with `csm-data` commands to easily send those data to target systems. It offers:
91
+
92
+ - Format flexibility (Python dictionaries, CSV files, Pandas DataFrames, PyArrow Tables)
93
+ - Persistent storage in SQLite
94
+ - SQL query capabilities
95
+ - Simplified data pipeline management
96
+
97
+ ```python
98
+ from cosmotech.coal.store.store import Store
99
+ from cosmotech.coal.store.native_python import store_pylist
100
+
101
+ # Initialize and reset the data store
102
+ my_datastore = Store(reset=True)
103
+
104
+ # Create and store data
105
+ my_data = [{"foo": "bar"}, {"foo": "barbar"}, {"foo": "world"}, {"foo": "bar"}]
106
+ store_pylist("my_data", my_data)
107
+
108
+ # Query the data
109
+ results = my_datastore.execute_query("SELECT foo, count(*) as line_count FROM my_data GROUP BY foo").to_pylist()
110
+ print(results)
111
+ # > [{'foo': 'bar', 'line_count': 2}, {'foo': 'barbar', 'line_count': 1}, {'foo': 'world', 'line_count': 1}]
112
+ ```
113
+
114
+ ### CosmoTech API Integration
115
+
116
+ CoAL provides comprehensive tools for interacting with the CosmoTech API, allowing you to:
117
+
118
+ - Authenticate with different identity providers (API Key, Azure Entra, Keycloak)
119
+ - Manage workspaces and files
120
+ - Work with the Twin Data Layer for graph data
121
+ - Handle runners and runs
122
+ - Process and transform data
123
+ - Build end-to-end workflows
124
+
125
+ ```python
126
+ import os
127
+ from cosmotech.coal.cosmotech_api.connection import get_api_client
128
+
129
+ # Set up environment variables for authentication
130
+ os.environ["CSM_API_URL"] = "https://api.cosmotech.com" # Replace with your API URL
131
+ os.environ["CSM_API_KEY"] = "your-api-key" # Replace with your actual API key
132
+
133
+ # Get the API client
134
+ api_client, connection_type = get_api_client()
135
+ print(f"Connected using: {connection_type}")
136
+
137
+ # Use the client with various API instances
138
+ from cosmotech_api.api.organization_api import OrganizationApi
139
+ org_api = OrganizationApi(api_client)
140
+
141
+ # List organizations
142
+ organizations = org_api.find_all_organizations()
143
+ for org in organizations:
144
+ print(f"Organization: {org.name} (ID: {org.id})")
145
+
146
+ # Don't forget to close the client when done
147
+ api_client.close()
148
+ ```
149
+
150
+ ### Other Components
151
+
152
+ - **coal**: Core library with modules for API interaction, data management, etc.
153
+ - **csm_data**: CLI tool for data management and integration with various systems
154
+ - **orchestrator_plugins**: Plugins that integrate with external orchestration systems
155
+ - **translation**: Internationalization support for multiple languages
156
+
157
+ ## Getting Started
158
+
159
+ ### Installation
160
+
161
+ ```bash
162
+ pip install cosmotech-acceleration-library
163
+ ```
164
+
165
+ ### Basic Usage
166
+
167
+ Check out the tutorials directory for comprehensive examples of how to use the library:
168
+
169
+ - [CosmoTech API Integration](https://cosmo-tech.github.io/CosmoTech-Acceleration-Library/tutorials/cosmotech-api/)
170
+ - [Data Store Usage](https://cosmo-tech.github.io/CosmoTech-Acceleration-Library/tutorials/datastore/)
171
+ - [csm-data CLI](https://cosmo-tech.github.io/CosmoTech-Acceleration-Library/tutorials/csm-data/)
172
+
173
+ ## Key Features
174
+
175
+ ### Cloud Service Integration
176
+
177
+ CoAL provides built-in support for various cloud services:
178
+
179
+ - **Azure**: Azure Data Explorer (ADX), Azure Storage, Azure Functions
180
+ - **AWS**: S3 buckets, and more
181
+ - **Database Systems**: PostgreSQL, SingleStore, and others
182
+
183
+ ### Data Management
184
+
185
+ - Load and transform data from various sources
186
+ - Store and query data locally
187
+ - Export data to different formats and destinations
188
+ - Manage datasets in the CosmoTech platform
189
+
190
+ ### Orchestration Integration
191
+
192
+ - Provides plugins that integrate with external orchestration systems
193
+ - Supports data transfer between orchestration steps
194
+ - Offers utilities for handling parameters and configurations
195
+ - Enables seamless integration with the CosmoTech platform during orchestrated workflows
196
+
197
+ ## Documentation and Tutorials
198
+
199
+ Comprehensive documentation is available at [https://cosmo-tech.github.io/CosmoTech-Acceleration-Library/](https://cosmo-tech.github.io/CosmoTech-Acceleration-Library/)
200
+
201
+ ### Tutorials
202
+
203
+ - **CosmoTech API**: Learn how to interact with the CosmoTech API directly: authentication, workspaces, Twin Data Layer, and more.
204
+ - **Data Store**: The datastore is your friend to keep data between orchestration steps. It comes with multiple ways to interact with it.
205
+ - **csm-data**: Make full use of `csm-data` commands to connect to services during your orchestration runs.
206
+
207
+ ## Testing and Code Coverage
208
+
209
+ The CosmoTech Acceleration Library maintains a comprehensive test suite to ensure reliability and stability. We use pytest for testing and pytest-cov for coverage reporting.
210
+
211
+ ### Running Tests
212
+
213
+ To run the test suite:
214
+
215
+ ```bash
216
+ # Install test dependencies
217
+ pip install -e ".[test]"
218
+
219
+ # Run tests with coverage reporting
220
+ pytest tests/unit/coal/ --cov=cosmotech.coal --cov-report=term-missing --cov-report=html
221
+ ```
222
+
223
+ ### Coverage Reports
224
+
225
+ After running tests with coverage, you can view detailed HTML reports:
226
+
227
+ ```bash
228
+ # Open the HTML coverage report
229
+ open coverage_html_report/index.html
230
+ ```
231
+
232
+ [![codecov](https://codecov.io/gh/Cosmo-Tech/CosmoTech-Acceleration-Library/branch/main/graph/badge.svg)](https://codecov.io/gh/Cosmo-Tech/CosmoTech-Acceleration-Library)
233
+
234
+ We maintain high test coverage to ensure code quality and reliability. All pull requests are expected to maintain or improve the current coverage levels.
235
+
236
+ ### Test Generation Tools
237
+
238
+ To help maintain test coverage, we provide tools to identify untested functions and generate test files:
239
+
240
+ ```bash
241
+ # Find functions without tests
242
+ python find_untested_functions.py
243
+
244
+ # Generate test files for a specific module
245
+ python generate_test_files.py --module cosmotech/coal/module/file.py
246
+
247
+ # Generate test files for all untested functions
248
+ python generate_test_files.py --all
249
+ ```
250
+
251
+ These tools help ensure that every function has at least one test, which is a requirement for contributions to the project.
252
+
253
+ ## Contact
254
+
255
+ For support, feature requests, or contributions, please use the [GitHub repository](https://github.com/Cosmo-Tech/CosmoTech-Acceleration-Library).