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.
- cosmotech/coal/__init__.py +8 -0
- cosmotech/coal/aws/__init__.py +23 -0
- cosmotech/coal/aws/s3.py +235 -0
- cosmotech/coal/azure/__init__.py +23 -0
- cosmotech/coal/azure/adx/__init__.py +26 -0
- cosmotech/coal/azure/adx/auth.py +125 -0
- cosmotech/coal/azure/adx/ingestion.py +329 -0
- cosmotech/coal/azure/adx/query.py +56 -0
- cosmotech/coal/azure/adx/runner.py +217 -0
- cosmotech/coal/azure/adx/store.py +255 -0
- cosmotech/coal/azure/adx/tables.py +118 -0
- cosmotech/coal/azure/adx/utils.py +71 -0
- cosmotech/coal/azure/blob.py +109 -0
- cosmotech/coal/azure/functions.py +72 -0
- cosmotech/coal/azure/storage.py +74 -0
- cosmotech/coal/cosmotech_api/__init__.py +36 -0
- cosmotech/coal/cosmotech_api/connection.py +96 -0
- cosmotech/coal/cosmotech_api/dataset/__init__.py +26 -0
- cosmotech/coal/cosmotech_api/dataset/converters.py +164 -0
- cosmotech/coal/cosmotech_api/dataset/download/__init__.py +19 -0
- cosmotech/coal/cosmotech_api/dataset/download/adt.py +119 -0
- cosmotech/coal/cosmotech_api/dataset/download/common.py +140 -0
- cosmotech/coal/cosmotech_api/dataset/download/file.py +216 -0
- cosmotech/coal/cosmotech_api/dataset/download/twingraph.py +188 -0
- cosmotech/coal/cosmotech_api/dataset/utils.py +132 -0
- cosmotech/coal/cosmotech_api/parameters.py +48 -0
- cosmotech/coal/cosmotech_api/run.py +25 -0
- cosmotech/coal/cosmotech_api/run_data.py +173 -0
- cosmotech/coal/cosmotech_api/run_template.py +108 -0
- cosmotech/coal/cosmotech_api/runner/__init__.py +28 -0
- cosmotech/coal/cosmotech_api/runner/data.py +38 -0
- cosmotech/coal/cosmotech_api/runner/datasets.py +364 -0
- cosmotech/coal/cosmotech_api/runner/download.py +146 -0
- cosmotech/coal/cosmotech_api/runner/metadata.py +42 -0
- cosmotech/coal/cosmotech_api/runner/parameters.py +157 -0
- cosmotech/coal/cosmotech_api/twin_data_layer.py +512 -0
- cosmotech/coal/cosmotech_api/workspace.py +127 -0
- cosmotech/coal/csm/__init__.py +6 -0
- cosmotech/coal/csm/engine/__init__.py +47 -0
- cosmotech/coal/postgresql/__init__.py +22 -0
- cosmotech/coal/postgresql/runner.py +93 -0
- cosmotech/coal/postgresql/store.py +98 -0
- cosmotech/coal/singlestore/__init__.py +17 -0
- cosmotech/coal/singlestore/store.py +100 -0
- cosmotech/coal/store/__init__.py +42 -0
- cosmotech/coal/store/csv.py +44 -0
- cosmotech/coal/store/native_python.py +25 -0
- cosmotech/coal/store/pandas.py +26 -0
- cosmotech/coal/store/pyarrow.py +23 -0
- cosmotech/coal/store/store.py +79 -0
- cosmotech/coal/utils/__init__.py +18 -0
- cosmotech/coal/utils/api.py +68 -0
- cosmotech/coal/utils/logger.py +10 -0
- cosmotech/coal/utils/postgresql.py +236 -0
- cosmotech/csm_data/__init__.py +6 -0
- cosmotech/csm_data/commands/__init__.py +6 -0
- cosmotech/csm_data/commands/adx_send_data.py +92 -0
- cosmotech/csm_data/commands/adx_send_runnerdata.py +119 -0
- cosmotech/csm_data/commands/api/__init__.py +6 -0
- cosmotech/csm_data/commands/api/api.py +50 -0
- cosmotech/csm_data/commands/api/postgres_send_runner_metadata.py +119 -0
- cosmotech/csm_data/commands/api/rds_load_csv.py +90 -0
- cosmotech/csm_data/commands/api/rds_send_csv.py +74 -0
- cosmotech/csm_data/commands/api/rds_send_store.py +74 -0
- cosmotech/csm_data/commands/api/run_load_data.py +120 -0
- cosmotech/csm_data/commands/api/runtemplate_load_handler.py +66 -0
- cosmotech/csm_data/commands/api/tdl_load_files.py +76 -0
- cosmotech/csm_data/commands/api/tdl_send_files.py +82 -0
- cosmotech/csm_data/commands/api/wsf_load_file.py +66 -0
- cosmotech/csm_data/commands/api/wsf_send_file.py +68 -0
- cosmotech/csm_data/commands/az_storage_upload.py +76 -0
- cosmotech/csm_data/commands/s3_bucket_delete.py +107 -0
- cosmotech/csm_data/commands/s3_bucket_download.py +118 -0
- cosmotech/csm_data/commands/s3_bucket_upload.py +128 -0
- cosmotech/csm_data/commands/store/__init__.py +6 -0
- cosmotech/csm_data/commands/store/dump_to_azure.py +120 -0
- cosmotech/csm_data/commands/store/dump_to_postgresql.py +107 -0
- cosmotech/csm_data/commands/store/dump_to_s3.py +169 -0
- cosmotech/csm_data/commands/store/list_tables.py +48 -0
- cosmotech/csm_data/commands/store/load_csv_folder.py +43 -0
- cosmotech/csm_data/commands/store/load_from_singlestore.py +96 -0
- cosmotech/csm_data/commands/store/reset.py +31 -0
- cosmotech/csm_data/commands/store/store.py +37 -0
- cosmotech/csm_data/main.py +57 -0
- cosmotech/csm_data/utils/__init__.py +6 -0
- cosmotech/csm_data/utils/click.py +18 -0
- cosmotech/csm_data/utils/decorators.py +75 -0
- cosmotech/orchestrator_plugins/csm-data/__init__.py +11 -0
- cosmotech/orchestrator_plugins/csm-data/templates/api/postgres_send_runner_metadata.json +40 -0
- cosmotech/orchestrator_plugins/csm-data/templates/api/rds_load_csv.json +27 -0
- cosmotech/orchestrator_plugins/csm-data/templates/api/rds_send_csv.json +27 -0
- cosmotech/orchestrator_plugins/csm-data/templates/api/rds_send_store.json +27 -0
- cosmotech/orchestrator_plugins/csm-data/templates/api/run_load_data.json +30 -0
- cosmotech/orchestrator_plugins/csm-data/templates/api/runtemplate_load_handler.json +27 -0
- cosmotech/orchestrator_plugins/csm-data/templates/api/tdl_load_files.json +32 -0
- cosmotech/orchestrator_plugins/csm-data/templates/api/tdl_send_files.json +27 -0
- cosmotech/orchestrator_plugins/csm-data/templates/api/try_api_connection.json +9 -0
- cosmotech/orchestrator_plugins/csm-data/templates/api/wsf_load_file.json +36 -0
- cosmotech/orchestrator_plugins/csm-data/templates/api/wsf_send_file.json +36 -0
- cosmotech/orchestrator_plugins/csm-data/templates/main/adx_send_runnerdata.json +29 -0
- cosmotech/orchestrator_plugins/csm-data/templates/main/az_storage_upload.json +25 -0
- cosmotech/orchestrator_plugins/csm-data/templates/main/s3_bucket_delete.json +31 -0
- cosmotech/orchestrator_plugins/csm-data/templates/main/s3_bucket_download.json +34 -0
- cosmotech/orchestrator_plugins/csm-data/templates/main/s3_bucket_upload.json +35 -0
- cosmotech/orchestrator_plugins/csm-data/templates/store/store_dump_to_azure.json +35 -0
- cosmotech/orchestrator_plugins/csm-data/templates/store/store_dump_to_postgresql.json +34 -0
- cosmotech/orchestrator_plugins/csm-data/templates/store/store_dump_to_s3.json +36 -0
- cosmotech/orchestrator_plugins/csm-data/templates/store/store_list_tables.json +15 -0
- cosmotech/orchestrator_plugins/csm-data/templates/store/store_load_csv_folder.json +18 -0
- cosmotech/orchestrator_plugins/csm-data/templates/store/store_load_from_singlestore.json +34 -0
- cosmotech/orchestrator_plugins/csm-data/templates/store/store_reset.json +15 -0
- cosmotech/translation/coal/__init__.py +6 -0
- cosmotech/translation/coal/en-US/coal/common/data_transfer.yml +6 -0
- cosmotech/translation/coal/en-US/coal/common/errors.yml +9 -0
- cosmotech/translation/coal/en-US/coal/common/file_operations.yml +6 -0
- cosmotech/translation/coal/en-US/coal/common/progress.yml +6 -0
- cosmotech/translation/coal/en-US/coal/common/timing.yml +5 -0
- cosmotech/translation/coal/en-US/coal/common/validation.yml +8 -0
- cosmotech/translation/coal/en-US/coal/cosmotech_api/connection.yml +10 -0
- cosmotech/translation/coal/en-US/coal/cosmotech_api/run_data.yml +2 -0
- cosmotech/translation/coal/en-US/coal/cosmotech_api/run_template.yml +8 -0
- cosmotech/translation/coal/en-US/coal/cosmotech_api/runner.yml +16 -0
- cosmotech/translation/coal/en-US/coal/cosmotech_api/solution.yml +5 -0
- cosmotech/translation/coal/en-US/coal/cosmotech_api/workspace.yml +7 -0
- cosmotech/translation/coal/en-US/coal/services/adx.yml +59 -0
- cosmotech/translation/coal/en-US/coal/services/api.yml +8 -0
- cosmotech/translation/coal/en-US/coal/services/azure_storage.yml +14 -0
- cosmotech/translation/coal/en-US/coal/services/database.yml +19 -0
- cosmotech/translation/coal/en-US/coal/services/dataset.yml +68 -0
- cosmotech/translation/coal/en-US/coal/services/postgresql.yml +28 -0
- cosmotech/translation/coal/en-US/coal/services/s3.yml +9 -0
- cosmotech/translation/coal/en-US/coal/solution.yml +3 -0
- cosmotech/translation/coal/en-US/coal/web.yml +2 -0
- cosmotech/translation/csm_data/__init__.py +6 -0
- cosmotech/translation/csm_data/en-US/csm-data.yml +434 -0
- cosmotech_acceleration_library-1.0.0.dist-info/METADATA +255 -0
- cosmotech_acceleration_library-1.0.0.dist-info/RECORD +141 -0
- cosmotech_acceleration_library-1.0.0.dist-info/WHEEL +5 -0
- cosmotech_acceleration_library-1.0.0.dist-info/entry_points.txt +2 -0
- cosmotech_acceleration_library-1.0.0.dist-info/licenses/LICENSE +17 -0
- cosmotech_acceleration_library-1.0.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,120 @@
|
|
|
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 cosmotech.csm_data.utils.click import click
|
|
9
|
+
from cosmotech.csm_data.utils.decorators import web_help, translate_help
|
|
10
|
+
from cosmotech.orchestrator.utils.translate import T
|
|
11
|
+
|
|
12
|
+
VALID_TYPES = (
|
|
13
|
+
"sqlite",
|
|
14
|
+
"csv",
|
|
15
|
+
"parquet",
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
@click.command()
|
|
20
|
+
@click.option(
|
|
21
|
+
"--store-folder",
|
|
22
|
+
envvar="CSM_PARAMETERS_ABSOLUTE_PATH",
|
|
23
|
+
help=T("csm-data.commands.store.dump_to_azure.parameters.store_folder"),
|
|
24
|
+
metavar="PATH",
|
|
25
|
+
type=str,
|
|
26
|
+
show_envvar=True,
|
|
27
|
+
required=True,
|
|
28
|
+
)
|
|
29
|
+
@click.option(
|
|
30
|
+
"--output-type",
|
|
31
|
+
default="sqlite",
|
|
32
|
+
help=T("csm-data.commands.store.dump_to_azure.parameters.output_type"),
|
|
33
|
+
type=click.Choice(VALID_TYPES, case_sensitive=False),
|
|
34
|
+
)
|
|
35
|
+
@click.option(
|
|
36
|
+
"--account-name",
|
|
37
|
+
"account_name",
|
|
38
|
+
envvar="AZURE_ACCOUNT_NAME",
|
|
39
|
+
help=T("csm-data.commands.store.dump_to_azure.parameters.account_name"),
|
|
40
|
+
type=str,
|
|
41
|
+
show_envvar=True,
|
|
42
|
+
required=True,
|
|
43
|
+
)
|
|
44
|
+
@click.option(
|
|
45
|
+
"--container-name",
|
|
46
|
+
"container_name",
|
|
47
|
+
envvar="AZURE_CONTAINER_NAME",
|
|
48
|
+
help=T("csm-data.commands.store.dump_to_azure.parameters.container_name"),
|
|
49
|
+
type=str,
|
|
50
|
+
show_envvar=True,
|
|
51
|
+
default="",
|
|
52
|
+
)
|
|
53
|
+
@click.option(
|
|
54
|
+
"--prefix",
|
|
55
|
+
"file_prefix",
|
|
56
|
+
envvar="CSM_DATA_PREFIX",
|
|
57
|
+
help=T("csm-data.commands.store.dump_to_azure.parameters.prefix"),
|
|
58
|
+
metavar="PREFIX",
|
|
59
|
+
type=str,
|
|
60
|
+
show_envvar=True,
|
|
61
|
+
default="",
|
|
62
|
+
)
|
|
63
|
+
@click.option(
|
|
64
|
+
"--tenant-id",
|
|
65
|
+
"tenant_id",
|
|
66
|
+
help=T("csm-data.commands.store.dump_to_azure.parameters.tenant_id"),
|
|
67
|
+
type=str,
|
|
68
|
+
required=True,
|
|
69
|
+
show_envvar=True,
|
|
70
|
+
metavar="ID",
|
|
71
|
+
envvar="AZURE_TENANT_ID",
|
|
72
|
+
)
|
|
73
|
+
@click.option(
|
|
74
|
+
"--client-id",
|
|
75
|
+
"client_id",
|
|
76
|
+
help=T("csm-data.commands.store.dump_to_azure.parameters.client_id"),
|
|
77
|
+
type=str,
|
|
78
|
+
required=True,
|
|
79
|
+
show_envvar=True,
|
|
80
|
+
metavar="ID",
|
|
81
|
+
envvar="AZURE_CLIENT_ID",
|
|
82
|
+
)
|
|
83
|
+
@click.option(
|
|
84
|
+
"--client-secret",
|
|
85
|
+
"client_secret",
|
|
86
|
+
help=T("csm-data.commands.store.dump_to_azure.parameters.client_secret"),
|
|
87
|
+
type=str,
|
|
88
|
+
required=True,
|
|
89
|
+
show_envvar=True,
|
|
90
|
+
metavar="ID",
|
|
91
|
+
envvar="AZURE_CLIENT_SECRET",
|
|
92
|
+
)
|
|
93
|
+
@web_help("csm-data/store/dump-to-azure")
|
|
94
|
+
@translate_help("csm-data.commands.store.dump_to_azure.description")
|
|
95
|
+
def dump_to_azure(
|
|
96
|
+
store_folder,
|
|
97
|
+
account_name: str,
|
|
98
|
+
container_name: str,
|
|
99
|
+
tenant_id: str,
|
|
100
|
+
client_id: str,
|
|
101
|
+
client_secret: str,
|
|
102
|
+
output_type: str,
|
|
103
|
+
file_prefix: str,
|
|
104
|
+
):
|
|
105
|
+
# Import the function at the start of the command
|
|
106
|
+
from cosmotech.coal.azure import dump_store_to_azure
|
|
107
|
+
|
|
108
|
+
try:
|
|
109
|
+
dump_store_to_azure(
|
|
110
|
+
store_folder=store_folder,
|
|
111
|
+
account_name=account_name,
|
|
112
|
+
container_name=container_name,
|
|
113
|
+
tenant_id=tenant_id,
|
|
114
|
+
client_id=client_id,
|
|
115
|
+
client_secret=client_secret,
|
|
116
|
+
output_type=output_type,
|
|
117
|
+
file_prefix=file_prefix,
|
|
118
|
+
)
|
|
119
|
+
except ValueError as e:
|
|
120
|
+
raise click.Abort() from e
|
|
@@ -0,0 +1,107 @@
|
|
|
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 cosmotech.csm_data.utils.click import click
|
|
9
|
+
from cosmotech.csm_data.utils.decorators import web_help, translate_help
|
|
10
|
+
from cosmotech.orchestrator.utils.translate import T
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
@click.command()
|
|
14
|
+
@web_help("csm-data/store/dump-to-postgres")
|
|
15
|
+
@translate_help("csm-data.commands.store.dump_to_postgresql.description")
|
|
16
|
+
@click.option(
|
|
17
|
+
"--store-folder",
|
|
18
|
+
envvar="CSM_PARAMETERS_ABSOLUTE_PATH",
|
|
19
|
+
help=T("csm-data.commands.store.dump_to_postgresql.parameters.store_folder"),
|
|
20
|
+
metavar="PATH",
|
|
21
|
+
type=str,
|
|
22
|
+
show_envvar=True,
|
|
23
|
+
required=True,
|
|
24
|
+
)
|
|
25
|
+
@click.option(
|
|
26
|
+
"--table-prefix",
|
|
27
|
+
help=T("csm-data.commands.store.dump_to_postgresql.parameters.table_prefix"),
|
|
28
|
+
metavar="PREFIX",
|
|
29
|
+
type=str,
|
|
30
|
+
default="Cosmotech_",
|
|
31
|
+
)
|
|
32
|
+
@click.option(
|
|
33
|
+
"--postgres-host",
|
|
34
|
+
help=T("csm-data.commands.store.dump_to_postgresql.parameters.postgres_host"),
|
|
35
|
+
envvar="POSTGRES_HOST_URI",
|
|
36
|
+
show_envvar=True,
|
|
37
|
+
required=True,
|
|
38
|
+
)
|
|
39
|
+
@click.option(
|
|
40
|
+
"--postgres-port",
|
|
41
|
+
help=T("csm-data.commands.store.dump_to_postgresql.parameters.postgres_port"),
|
|
42
|
+
envvar="POSTGRES_HOST_PORT",
|
|
43
|
+
show_envvar=True,
|
|
44
|
+
required=False,
|
|
45
|
+
default=5432,
|
|
46
|
+
)
|
|
47
|
+
@click.option(
|
|
48
|
+
"--postgres-db",
|
|
49
|
+
help=T("csm-data.commands.store.dump_to_postgresql.parameters.postgres_db"),
|
|
50
|
+
envvar="POSTGRES_DB_NAME",
|
|
51
|
+
show_envvar=True,
|
|
52
|
+
required=True,
|
|
53
|
+
)
|
|
54
|
+
@click.option(
|
|
55
|
+
"--postgres-schema",
|
|
56
|
+
help=T("csm-data.commands.store.dump_to_postgresql.parameters.postgres_schema"),
|
|
57
|
+
envvar="POSTGRES_DB_SCHEMA",
|
|
58
|
+
show_envvar=True,
|
|
59
|
+
required=True,
|
|
60
|
+
)
|
|
61
|
+
@click.option(
|
|
62
|
+
"--postgres-user",
|
|
63
|
+
help=T("csm-data.commands.store.dump_to_postgresql.parameters.postgres_user"),
|
|
64
|
+
envvar="POSTGRES_USER_NAME",
|
|
65
|
+
show_envvar=True,
|
|
66
|
+
required=True,
|
|
67
|
+
)
|
|
68
|
+
@click.option(
|
|
69
|
+
"--postgres-password",
|
|
70
|
+
help=T("csm-data.commands.store.dump_to_postgresql.parameters.postgres_password"),
|
|
71
|
+
envvar="POSTGRES_USER_PASSWORD",
|
|
72
|
+
show_envvar=True,
|
|
73
|
+
required=True,
|
|
74
|
+
)
|
|
75
|
+
@click.option(
|
|
76
|
+
"--replace/--append",
|
|
77
|
+
"replace",
|
|
78
|
+
help=T("csm-data.commands.store.dump_to_postgresql.parameters.replace"),
|
|
79
|
+
default=True,
|
|
80
|
+
is_flag=True,
|
|
81
|
+
show_default=True,
|
|
82
|
+
)
|
|
83
|
+
def dump_to_postgresql(
|
|
84
|
+
store_folder,
|
|
85
|
+
table_prefix: str,
|
|
86
|
+
postgres_host,
|
|
87
|
+
postgres_port,
|
|
88
|
+
postgres_db,
|
|
89
|
+
postgres_schema,
|
|
90
|
+
postgres_user,
|
|
91
|
+
postgres_password,
|
|
92
|
+
replace: bool,
|
|
93
|
+
):
|
|
94
|
+
# Import the function at the start of the command
|
|
95
|
+
from cosmotech.coal.postgresql import dump_store_to_postgresql
|
|
96
|
+
|
|
97
|
+
dump_store_to_postgresql(
|
|
98
|
+
store_folder=store_folder,
|
|
99
|
+
table_prefix=table_prefix,
|
|
100
|
+
postgres_host=postgres_host,
|
|
101
|
+
postgres_port=postgres_port,
|
|
102
|
+
postgres_db=postgres_db,
|
|
103
|
+
postgres_schema=postgres_schema,
|
|
104
|
+
postgres_user=postgres_user,
|
|
105
|
+
postgres_password=postgres_password,
|
|
106
|
+
replace=replace,
|
|
107
|
+
)
|
|
@@ -0,0 +1,169 @@
|
|
|
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 Optional
|
|
9
|
+
|
|
10
|
+
from cosmotech.csm_data.utils.click import click
|
|
11
|
+
from cosmotech.csm_data.utils.decorators import web_help, translate_help
|
|
12
|
+
from cosmotech.orchestrator.utils.translate import T
|
|
13
|
+
|
|
14
|
+
VALID_TYPES = (
|
|
15
|
+
"sqlite",
|
|
16
|
+
"csv",
|
|
17
|
+
"parquet",
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
@click.command()
|
|
22
|
+
@click.option(
|
|
23
|
+
"--store-folder",
|
|
24
|
+
envvar="CSM_PARAMETERS_ABSOLUTE_PATH",
|
|
25
|
+
help=T("csm-data.commands.store.dump_to_s3.parameters.store_folder"),
|
|
26
|
+
metavar="PATH",
|
|
27
|
+
type=str,
|
|
28
|
+
show_envvar=True,
|
|
29
|
+
required=True,
|
|
30
|
+
)
|
|
31
|
+
@click.option(
|
|
32
|
+
"--output-type",
|
|
33
|
+
default="sqlite",
|
|
34
|
+
help=T("csm-data.commands.store.dump_to_s3.parameters.output_type"),
|
|
35
|
+
type=click.Choice(VALID_TYPES, case_sensitive=False),
|
|
36
|
+
)
|
|
37
|
+
@click.option(
|
|
38
|
+
"--bucket-name",
|
|
39
|
+
envvar="CSM_DATA_BUCKET_NAME",
|
|
40
|
+
help=T("csm-data.commands.store.dump_to_s3.parameters.bucket_name"),
|
|
41
|
+
metavar="BUCKET",
|
|
42
|
+
type=str,
|
|
43
|
+
show_envvar=True,
|
|
44
|
+
required=True,
|
|
45
|
+
)
|
|
46
|
+
@click.option(
|
|
47
|
+
"--prefix",
|
|
48
|
+
"file_prefix",
|
|
49
|
+
envvar="CSM_DATA_BUCKET_PREFIX",
|
|
50
|
+
help=T("csm-data.commands.store.dump_to_s3.parameters.prefix"),
|
|
51
|
+
metavar="PREFIX",
|
|
52
|
+
type=str,
|
|
53
|
+
show_envvar=True,
|
|
54
|
+
default="",
|
|
55
|
+
)
|
|
56
|
+
@click.option(
|
|
57
|
+
"--use-ssl/--no-ssl",
|
|
58
|
+
default=True,
|
|
59
|
+
help=T("csm-data.commands.store.dump_to_s3.parameters.use_ssl"),
|
|
60
|
+
type=bool,
|
|
61
|
+
is_flag=True,
|
|
62
|
+
)
|
|
63
|
+
@click.option(
|
|
64
|
+
"--s3-url",
|
|
65
|
+
"endpoint_url",
|
|
66
|
+
help=T("csm-data.commands.store.dump_to_s3.parameters.s3_url"),
|
|
67
|
+
type=str,
|
|
68
|
+
required=True,
|
|
69
|
+
show_envvar=True,
|
|
70
|
+
metavar="URL",
|
|
71
|
+
envvar="AWS_ENDPOINT_URL",
|
|
72
|
+
)
|
|
73
|
+
@click.option(
|
|
74
|
+
"--access-id",
|
|
75
|
+
"access_id",
|
|
76
|
+
help=T("csm-data.commands.store.dump_to_s3.parameters.access_id"),
|
|
77
|
+
type=str,
|
|
78
|
+
required=True,
|
|
79
|
+
show_envvar=True,
|
|
80
|
+
metavar="ID",
|
|
81
|
+
envvar="AWS_ACCESS_KEY_ID",
|
|
82
|
+
)
|
|
83
|
+
@click.option(
|
|
84
|
+
"--secret-key",
|
|
85
|
+
"secret_key",
|
|
86
|
+
help=T("csm-data.commands.store.dump_to_s3.parameters.secret_key"),
|
|
87
|
+
type=str,
|
|
88
|
+
required=True,
|
|
89
|
+
show_envvar=True,
|
|
90
|
+
metavar="ID",
|
|
91
|
+
envvar="AWS_SECRET_ACCESS_KEY",
|
|
92
|
+
)
|
|
93
|
+
@click.option(
|
|
94
|
+
"--ssl-cert-bundle",
|
|
95
|
+
help=T("csm-data.commands.store.dump_to_s3.parameters.ssl_cert_bundle"),
|
|
96
|
+
type=str,
|
|
97
|
+
show_envvar=True,
|
|
98
|
+
metavar="PATH",
|
|
99
|
+
envvar="CSM_S3_CA_BUNDLE",
|
|
100
|
+
)
|
|
101
|
+
@web_help("csm-data/store/dump-to-s3")
|
|
102
|
+
@translate_help("csm-data.commands.store.dump_to_s3.description")
|
|
103
|
+
def dump_to_s3(
|
|
104
|
+
store_folder,
|
|
105
|
+
bucket_name: str,
|
|
106
|
+
endpoint_url: str,
|
|
107
|
+
access_id: str,
|
|
108
|
+
secret_key: str,
|
|
109
|
+
output_type: str,
|
|
110
|
+
file_prefix: str = "",
|
|
111
|
+
use_ssl: bool = True,
|
|
112
|
+
ssl_cert_bundle: Optional[str] = None,
|
|
113
|
+
):
|
|
114
|
+
# Import the modules and functions at the start of the command
|
|
115
|
+
from io import BytesIO
|
|
116
|
+
import pyarrow.csv as pc
|
|
117
|
+
import pyarrow.parquet as pq
|
|
118
|
+
from cosmotech.coal.aws import create_s3_client, upload_data_stream
|
|
119
|
+
from cosmotech.coal.store.store import Store
|
|
120
|
+
from cosmotech.coal.utils.logger import LOGGER
|
|
121
|
+
|
|
122
|
+
_s = Store(store_location=store_folder)
|
|
123
|
+
|
|
124
|
+
if output_type not in VALID_TYPES:
|
|
125
|
+
LOGGER.error(T("coal.common.errors.data_invalid_output_type").format(output_type=output_type))
|
|
126
|
+
raise ValueError(T("coal.common.errors.data_invalid_output_type").format(output_type=output_type))
|
|
127
|
+
|
|
128
|
+
# Create S3 client
|
|
129
|
+
s3_client = create_s3_client(
|
|
130
|
+
endpoint_url=endpoint_url,
|
|
131
|
+
access_id=access_id,
|
|
132
|
+
secret_key=secret_key,
|
|
133
|
+
use_ssl=use_ssl,
|
|
134
|
+
ssl_cert_bundle=ssl_cert_bundle,
|
|
135
|
+
)
|
|
136
|
+
|
|
137
|
+
if output_type == "sqlite":
|
|
138
|
+
_file_path = _s._database_path
|
|
139
|
+
_file_name = "db.sqlite"
|
|
140
|
+
_uploaded_file_name = file_prefix + _file_name
|
|
141
|
+
LOGGER.info(
|
|
142
|
+
T("coal.common.data_transfer.file_sent").format(file_path=_file_path, uploaded_name=_uploaded_file_name)
|
|
143
|
+
)
|
|
144
|
+
s3_client.upload_file(_file_path, bucket_name, _uploaded_file_name)
|
|
145
|
+
else:
|
|
146
|
+
tables = list(_s.list_tables())
|
|
147
|
+
for table_name in tables:
|
|
148
|
+
_data_stream = BytesIO()
|
|
149
|
+
_file_name = None
|
|
150
|
+
_data = _s.get_table(table_name)
|
|
151
|
+
if not len(_data):
|
|
152
|
+
LOGGER.info(T("coal.common.data_transfer.table_empty").format(table_name=table_name))
|
|
153
|
+
continue
|
|
154
|
+
if output_type == "csv":
|
|
155
|
+
_file_name = table_name + ".csv"
|
|
156
|
+
pc.write_csv(_data, _data_stream)
|
|
157
|
+
elif output_type == "parquet":
|
|
158
|
+
_file_name = table_name + ".parquet"
|
|
159
|
+
pq.write_table(_data, _data_stream)
|
|
160
|
+
LOGGER.info(
|
|
161
|
+
T("coal.common.data_transfer.sending_table").format(table_name=table_name, output_type=output_type)
|
|
162
|
+
)
|
|
163
|
+
upload_data_stream(
|
|
164
|
+
data_stream=_data_stream,
|
|
165
|
+
bucket_name=bucket_name,
|
|
166
|
+
s3_client=s3_client,
|
|
167
|
+
file_name=_file_name,
|
|
168
|
+
file_prefix=file_prefix,
|
|
169
|
+
)
|
|
@@ -0,0 +1,48 @@
|
|
|
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 cosmotech.csm_data.utils.click import click
|
|
9
|
+
from cosmotech.csm_data.utils.decorators import web_help, translate_help
|
|
10
|
+
from cosmotech.orchestrator.utils.translate import T
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
@click.command()
|
|
14
|
+
@web_help("csm-data/store/list-tables")
|
|
15
|
+
@translate_help("csm-data.commands.store.list_tables.description")
|
|
16
|
+
@click.option(
|
|
17
|
+
"--store-folder",
|
|
18
|
+
envvar="CSM_PARAMETERS_ABSOLUTE_PATH",
|
|
19
|
+
help=T("csm-data.commands.store.list_tables.parameters.store_folder"),
|
|
20
|
+
metavar="PATH",
|
|
21
|
+
type=str,
|
|
22
|
+
show_envvar=True,
|
|
23
|
+
required=True,
|
|
24
|
+
)
|
|
25
|
+
@click.option(
|
|
26
|
+
"--schema/--no-schema",
|
|
27
|
+
help=T("csm-data.commands.store.list_tables.parameters.schema"),
|
|
28
|
+
is_flag=True,
|
|
29
|
+
type=bool,
|
|
30
|
+
default=False,
|
|
31
|
+
)
|
|
32
|
+
def list_tables(store_folder, schema):
|
|
33
|
+
# Import the modules and functions at the start of the command
|
|
34
|
+
from cosmotech.coal.store.store import Store
|
|
35
|
+
from cosmotech.coal.utils.logger import LOGGER
|
|
36
|
+
|
|
37
|
+
_s = Store(store_location=store_folder)
|
|
38
|
+
tables = list(_s.list_tables())
|
|
39
|
+
if len(tables):
|
|
40
|
+
LOGGER.info(T("coal.services.database.store_tables"))
|
|
41
|
+
for table_name in tables:
|
|
42
|
+
LOGGER.info(T("coal.services.database.table_entry").format(table=table_name))
|
|
43
|
+
if schema:
|
|
44
|
+
LOGGER.info(
|
|
45
|
+
T("coal.services.database.table_schema").format(schema=str(_s.get_table_schema(table_name)))
|
|
46
|
+
)
|
|
47
|
+
else:
|
|
48
|
+
LOGGER.info(T("coal.services.database.store_empty"))
|
|
@@ -0,0 +1,43 @@
|
|
|
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 cosmotech.csm_data.utils.click import click
|
|
9
|
+
from cosmotech.csm_data.utils.decorators import web_help, translate_help
|
|
10
|
+
from cosmotech.orchestrator.utils.translate import T
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
@click.command()
|
|
14
|
+
@web_help("csm-data/store/load-csv-folder")
|
|
15
|
+
@translate_help("csm-data.commands.store.load_csv_folder.description")
|
|
16
|
+
@click.option(
|
|
17
|
+
"--store-folder",
|
|
18
|
+
envvar="CSM_PARAMETERS_ABSOLUTE_PATH",
|
|
19
|
+
help=T("csm-data.commands.store.load_csv_folder.parameters.store_folder"),
|
|
20
|
+
metavar="PATH",
|
|
21
|
+
type=str,
|
|
22
|
+
show_envvar=True,
|
|
23
|
+
required=True,
|
|
24
|
+
)
|
|
25
|
+
@click.option(
|
|
26
|
+
"--csv-folder",
|
|
27
|
+
envvar="CSM_DATASET_ABSOLUTE_PATH",
|
|
28
|
+
help=T("csm-data.commands.store.load_csv_folder.parameters.csv_folder"),
|
|
29
|
+
metavar="PATH",
|
|
30
|
+
type=str,
|
|
31
|
+
show_envvar=True,
|
|
32
|
+
required=True,
|
|
33
|
+
)
|
|
34
|
+
def load_csv_folder(store_folder, csv_folder):
|
|
35
|
+
# Import the modules and functions at the start of the command
|
|
36
|
+
import pathlib
|
|
37
|
+
from cosmotech.coal.store.csv import store_csv_file
|
|
38
|
+
from cosmotech.coal.store.store import Store
|
|
39
|
+
from cosmotech.coal.utils.logger import LOGGER
|
|
40
|
+
|
|
41
|
+
for csv_path in pathlib.Path(csv_folder).glob("*.csv"):
|
|
42
|
+
LOGGER.info(T("coal.services.azure_storage.found_file").format(file=csv_path.name))
|
|
43
|
+
store_csv_file(csv_path.name[:-4], csv_path, store=Store(False, store_folder))
|
|
@@ -0,0 +1,96 @@
|
|
|
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 cosmotech.csm_data.utils.click import click
|
|
9
|
+
from cosmotech.csm_data.utils.decorators import web_help, translate_help
|
|
10
|
+
from cosmotech.orchestrator.utils.translate import T
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
@click.command()
|
|
14
|
+
@web_help("csm-data/store/load-from-singlestore")
|
|
15
|
+
@translate_help("csm-data.commands.store.load_from_singlestore.description")
|
|
16
|
+
@click.option(
|
|
17
|
+
"--singlestore-host",
|
|
18
|
+
"single_store_host",
|
|
19
|
+
envvar="SINGLE_STORE_HOST",
|
|
20
|
+
help=T("csm-data.commands.store.load_from_singlestore.parameters.singlestore_host"),
|
|
21
|
+
type=str,
|
|
22
|
+
show_envvar=True,
|
|
23
|
+
required=True,
|
|
24
|
+
)
|
|
25
|
+
@click.option(
|
|
26
|
+
"--singlestore-port",
|
|
27
|
+
"single_store_port",
|
|
28
|
+
help=T("csm-data.commands.store.load_from_singlestore.parameters.singlestore_port"),
|
|
29
|
+
envvar="SINGLE_STORE_PORT",
|
|
30
|
+
show_envvar=True,
|
|
31
|
+
required=False,
|
|
32
|
+
default=3306,
|
|
33
|
+
)
|
|
34
|
+
@click.option(
|
|
35
|
+
"--singlestore-db",
|
|
36
|
+
"single_store_db",
|
|
37
|
+
help=T("csm-data.commands.store.load_from_singlestore.parameters.singlestore_db"),
|
|
38
|
+
envvar="SINGLE_STORE_DB",
|
|
39
|
+
show_envvar=True,
|
|
40
|
+
required=True,
|
|
41
|
+
)
|
|
42
|
+
@click.option(
|
|
43
|
+
"--singlestore-user",
|
|
44
|
+
"single_store_user",
|
|
45
|
+
help=T("csm-data.commands.store.load_from_singlestore.parameters.singlestore_user"),
|
|
46
|
+
envvar="SINGLE_STORE_USERNAME",
|
|
47
|
+
show_envvar=True,
|
|
48
|
+
required=True,
|
|
49
|
+
)
|
|
50
|
+
@click.option(
|
|
51
|
+
"--singlestore-password",
|
|
52
|
+
"single_store_password",
|
|
53
|
+
help=T("csm-data.commands.store.load_from_singlestore.parameters.singlestore_password"),
|
|
54
|
+
envvar="SINGLE_STORE_PASSWORD",
|
|
55
|
+
show_envvar=True,
|
|
56
|
+
required=True,
|
|
57
|
+
)
|
|
58
|
+
@click.option(
|
|
59
|
+
"--singlestore-tables",
|
|
60
|
+
"single_store_tables",
|
|
61
|
+
help=T("csm-data.commands.store.load_from_singlestore.parameters.singlestore_tables"),
|
|
62
|
+
envvar="SINGLE_STORE_TABLES",
|
|
63
|
+
show_envvar=True,
|
|
64
|
+
required=True,
|
|
65
|
+
)
|
|
66
|
+
@click.option(
|
|
67
|
+
"--store-folder",
|
|
68
|
+
"store_folder",
|
|
69
|
+
envvar="CSM_PARAMETERS_ABSOLUTE_PATH",
|
|
70
|
+
help=T("csm-data.commands.store.load_from_singlestore.parameters.store_folder"),
|
|
71
|
+
metavar="PATH",
|
|
72
|
+
type=str,
|
|
73
|
+
show_envvar=True,
|
|
74
|
+
required=True,
|
|
75
|
+
)
|
|
76
|
+
def load_from_singlestore_command(
|
|
77
|
+
single_store_host,
|
|
78
|
+
single_store_port,
|
|
79
|
+
single_store_db,
|
|
80
|
+
single_store_user,
|
|
81
|
+
single_store_password,
|
|
82
|
+
store_folder,
|
|
83
|
+
single_store_tables: str = "",
|
|
84
|
+
):
|
|
85
|
+
# Import the function at the start of the command
|
|
86
|
+
from cosmotech.coal.singlestore import load_from_singlestore
|
|
87
|
+
|
|
88
|
+
load_from_singlestore(
|
|
89
|
+
single_store_host=single_store_host,
|
|
90
|
+
single_store_port=single_store_port,
|
|
91
|
+
single_store_db=single_store_db,
|
|
92
|
+
single_store_user=single_store_user,
|
|
93
|
+
single_store_password=single_store_password,
|
|
94
|
+
store_folder=store_folder,
|
|
95
|
+
single_store_tables=single_store_tables,
|
|
96
|
+
)
|
|
@@ -0,0 +1,31 @@
|
|
|
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 cosmotech.csm_data.utils.click import click
|
|
9
|
+
from cosmotech.csm_data.utils.decorators import web_help, translate_help
|
|
10
|
+
from cosmotech.orchestrator.utils.translate import T
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
@click.command()
|
|
14
|
+
@web_help("csm-data/store/reset")
|
|
15
|
+
@translate_help("csm-data.commands.store.reset.description")
|
|
16
|
+
@click.option(
|
|
17
|
+
"--store-folder",
|
|
18
|
+
envvar="CSM_PARAMETERS_ABSOLUTE_PATH",
|
|
19
|
+
help=T("csm-data.commands.store.reset.parameters.store_folder"),
|
|
20
|
+
metavar="PATH",
|
|
21
|
+
type=str,
|
|
22
|
+
show_envvar=True,
|
|
23
|
+
required=True,
|
|
24
|
+
)
|
|
25
|
+
def reset(store_folder):
|
|
26
|
+
# Import the modules and functions at the start of the command
|
|
27
|
+
from cosmotech.coal.store.store import Store
|
|
28
|
+
from cosmotech.coal.utils.logger import LOGGER
|
|
29
|
+
|
|
30
|
+
Store(True, store_folder)
|
|
31
|
+
LOGGER.info(T("coal.services.database.store_reset").format(folder=store_folder))
|
|
@@ -0,0 +1,37 @@
|
|
|
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 cosmotech.csm_data.commands.api.rds_send_store import rds_send_store
|
|
9
|
+
from cosmotech.csm_data.commands.store.dump_to_azure import dump_to_azure
|
|
10
|
+
from cosmotech.csm_data.commands.store.dump_to_postgresql import dump_to_postgresql
|
|
11
|
+
from cosmotech.csm_data.commands.store.dump_to_s3 import dump_to_s3
|
|
12
|
+
from cosmotech.csm_data.commands.store.list_tables import list_tables
|
|
13
|
+
from cosmotech.csm_data.commands.store.load_csv_folder import load_csv_folder
|
|
14
|
+
from cosmotech.csm_data.commands.store.load_from_singlestore import (
|
|
15
|
+
load_from_singlestore_command,
|
|
16
|
+
)
|
|
17
|
+
from cosmotech.csm_data.commands.store.reset import reset
|
|
18
|
+
from cosmotech.csm_data.utils.click import click
|
|
19
|
+
from cosmotech.csm_data.utils.decorators import web_help, translate_help
|
|
20
|
+
from cosmotech.orchestrator.utils.translate import T
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
@click.group()
|
|
24
|
+
@web_help("csm-data/store")
|
|
25
|
+
@translate_help("csm-data.commands.store.description")
|
|
26
|
+
def store():
|
|
27
|
+
pass
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
store.add_command(rds_send_store, "rds-send-store")
|
|
31
|
+
store.add_command(reset, "reset")
|
|
32
|
+
store.add_command(list_tables, "list-tables")
|
|
33
|
+
store.add_command(load_csv_folder, "load-csv-folder")
|
|
34
|
+
store.add_command(load_from_singlestore_command, "load-from-singlestore")
|
|
35
|
+
store.add_command(dump_to_postgresql, "dump-to-postgresql")
|
|
36
|
+
store.add_command(dump_to_s3, "dump-to-s3")
|
|
37
|
+
store.add_command(dump_to_azure, "dump-to-azure")
|