Skip to content

Commit e39e2b9

Browse files
committed
Moved to cleaner log translation organization
1 parent 24c9041 commit e39e2b9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+388
-359
lines changed

cosmotech/coal/aws/s3.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ def upload_file(
102102
file_prefix: Prefix to add to the file name in the bucket
103103
"""
104104
uploaded_file_name = file_prefix + file_path.name
105-
LOGGER.info(T("coal.logs.data_transfer.file_sent").format(file_path=file_path, uploaded_name=uploaded_file_name))
105+
LOGGER.info(T("coal.common.data_transfer.file_sent").format(file_path=file_path, uploaded_name=uploaded_file_name))
106106
s3_resource.Bucket(bucket_name).upload_file(str(file_path), uploaded_file_name)
107107

108108

@@ -125,8 +125,8 @@ def upload_folder(
125125
"""
126126
source_path = pathlib.Path(source_folder)
127127
if not source_path.exists():
128-
LOGGER.error(T("coal.errors.file_system.file_not_found").format(source_folder=source_folder))
129-
raise FileNotFoundError(T("coal.errors.file_system.file_not_found").format(source_folder=source_folder))
128+
LOGGER.error(T("coal.common.file_operations.not_found").format(source_folder=source_folder))
129+
raise FileNotFoundError(T("coal.common.file_operations.not_found").format(source_folder=source_folder))
130130

131131
if source_path.is_dir():
132132
_source_name = str(source_path)
@@ -135,7 +135,7 @@ def upload_folder(
135135
_file_name = str(_file_path).removeprefix(_source_name).removeprefix("/")
136136
uploaded_file_name = file_prefix + _file_name
137137
LOGGER.info(
138-
T("coal.logs.data_transfer.file_sent").format(
138+
T("coal.common.data_transfer.file_sent").format(
139139
file_path=_file_path, uploaded_name=uploaded_file_name
140140
)
141141
)
@@ -176,7 +176,7 @@ def download_files(
176176
target_file = target_file.removeprefix(file_prefix)
177177
output_file = f"{target_folder}/{target_file}"
178178
pathlib.Path(output_file).parent.mkdir(parents=True, exist_ok=True)
179-
LOGGER.info(T("coal.logs.storage.downloading").format(path=path_name, output=output_file))
179+
LOGGER.info(T("coal.services.azure_storage.downloading").format(path=path_name, output=output_file))
180180
bucket.download_file(_file.key, output_file)
181181

182182

@@ -202,7 +202,7 @@ def upload_data_stream(
202202
size = len(data_stream.read())
203203
data_stream.seek(0)
204204

205-
LOGGER.info(T("coal.logs.data_transfer.sending_data").format(size=size))
205+
LOGGER.info(T("coal.common.data_transfer.sending_data").format(size=size))
206206
s3_client.upload_fileobj(data_stream, bucket_name, uploaded_file_name)
207207

208208

@@ -228,8 +228,8 @@ def delete_objects(
228228

229229
boto_objects = [{"Key": _file.key} for _file in bucket_files if _file.key != file_prefix]
230230
if boto_objects:
231-
LOGGER.info(T("coal.logs.storage.deleting_objects").format(objects=boto_objects))
231+
LOGGER.info(T("coal.services.azure_storage.deleting_objects").format(objects=boto_objects))
232232
boto_delete_request = {"Objects": boto_objects}
233233
bucket.delete_objects(Delete=boto_delete_request)
234234
else:
235-
LOGGER.info(T("coal.logs.storage.no_objects"))
235+
LOGGER.info(T("coal.services.azure_storage.no_objects"))

cosmotech/coal/azure/adx/auth.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def create_kusto_client(
3333
Returns:
3434
KustoClient: A client for querying ADX
3535
"""
36-
LOGGER.debug(T("coal.logs.adx.creating_kusto_client").format(cluster_url=cluster_url))
36+
LOGGER.debug(T("coal.services.adx.creating_kusto_client").format(cluster_url=cluster_url))
3737

3838
try:
3939
az_client_id = client_id or os.environ["AZURE_CLIENT_ID"]
@@ -43,9 +43,9 @@ def create_kusto_client(
4343
kcsb = KustoConnectionStringBuilder.with_aad_application_key_authentication(
4444
cluster_url, az_client_id, az_client_secret, az_tenant_id
4545
)
46-
LOGGER.debug(T("coal.logs.adx.using_app_auth"))
46+
LOGGER.debug(T("coal.services.adx.using_app_auth"))
4747
except KeyError:
48-
LOGGER.debug(T("coal.logs.adx.using_cli_auth"))
48+
LOGGER.debug(T("coal.services.adx.using_cli_auth"))
4949
kcsb = KustoConnectionStringBuilder.with_az_cli_authentication(cluster_url)
5050

5151
return KustoClient(kcsb)
@@ -69,7 +69,7 @@ def create_ingest_client(
6969
Returns:
7070
QueuedIngestClient: A client for ingesting data to ADX
7171
"""
72-
LOGGER.debug(T("coal.logs.adx.creating_ingest_client").format(ingest_url=ingest_url))
72+
LOGGER.debug(T("coal.services.adx.creating_ingest_client").format(ingest_url=ingest_url))
7373

7474
try:
7575
az_client_id = client_id or os.environ["AZURE_CLIENT_ID"]
@@ -79,9 +79,9 @@ def create_ingest_client(
7979
kcsb = KustoConnectionStringBuilder.with_aad_application_key_authentication(
8080
ingest_url, az_client_id, az_client_secret, az_tenant_id
8181
)
82-
LOGGER.debug(T("coal.logs.adx.using_app_auth"))
82+
LOGGER.debug(T("coal.services.adx.using_app_auth"))
8383
except KeyError:
84-
LOGGER.debug(T("coal.logs.adx.using_cli_auth"))
84+
LOGGER.debug(T("coal.services.adx.using_cli_auth"))
8585
kcsb = KustoConnectionStringBuilder.with_az_cli_authentication(ingest_url)
8686

8787
return QueuedIngestClient(kcsb)
@@ -98,7 +98,7 @@ def initialize_clients(adx_uri: str, adx_ingest_uri: str) -> Tuple[KustoClient,
9898
Returns:
9999
tuple: (kusto_client, ingest_client)
100100
"""
101-
LOGGER.debug(T("coal.logs.adx.auth.initializing_clients"))
101+
LOGGER.debug(T("coal.services.adx.initializing_clients"))
102102
kusto_client = create_kusto_client(adx_uri)
103103
ingest_client = create_ingest_client(adx_ingest_uri)
104104
return kusto_client, ingest_client
@@ -115,7 +115,9 @@ def get_cluster_urls(cluster_name: str, cluster_region: str) -> Tuple[str, str]:
115115
Returns:
116116
tuple: (cluster_url, ingest_url)
117117
"""
118-
LOGGER.debug(T("coal.logs.adx.generating_urls").format(cluster_name=cluster_name, cluster_region=cluster_region))
118+
LOGGER.debug(
119+
T("coal.services.adx.generating_urls").format(cluster_name=cluster_name, cluster_region=cluster_region)
120+
)
119121

120122
cluster_url = f"https://{cluster_name}.{cluster_region}.kusto.windows.net"
121123
ingest_url = f"https://ingest-{cluster_name}.{cluster_region}.kusto.windows.net"

cosmotech/coal/azure/adx/ingestion.py

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def ingest_dataframe(
6464
Returns:
6565
The ingestion result with source_id for status tracking
6666
"""
67-
LOGGER.debug(T("coal.logs.adx.ingesting_dataframe").format(table_name=table_name, rows=len(dataframe)))
67+
LOGGER.debug(T("coal.services.adx.ingesting_dataframe").format(table_name=table_name, rows=len(dataframe)))
6868

6969
drop_by_tags = [drop_by_tag] if (drop_by_tag is not None) else None
7070

@@ -83,7 +83,7 @@ def ingest_dataframe(
8383
_ingest_status[source_id] = IngestionStatus.QUEUED
8484
_ingest_times[source_id] = time.time()
8585

86-
LOGGER.debug(T("coal.logs.adx.ingestion_queued").format(source_id=source_id))
86+
LOGGER.debug(T("coal.services.adx.ingestion_queued").format(source_id=source_id))
8787

8888
return ingestion_result
8989

@@ -112,10 +112,10 @@ def send_to_adx(
112112
Returns:
113113
The ingestion result with source_id for status tracking
114114
"""
115-
LOGGER.debug(T("coal.logs.adx.sending_to_adx").format(table_name=table_name, items=len(dict_list)))
115+
LOGGER.debug(T("coal.services.adx.sending_to_adx").format(table_name=table_name, items=len(dict_list)))
116116

117117
if not dict_list:
118-
LOGGER.warning(T("coal.logs.adx.empty_dict_list"))
118+
LOGGER.warning(T("coal.services.adx.empty_dict_list"))
119119
return None
120120

121121
if not ignore_table_creation:
@@ -125,7 +125,7 @@ def send_to_adx(
125125

126126
# Then try to create the table
127127
if not create_table(query_client, database, table_name, types):
128-
LOGGER.error(T("coal.logs.adx.table_creation_failed").format(table_name=table_name))
128+
LOGGER.error(T("coal.services.adx.table_creation_failed").format(table_name=table_name))
129129
return False
130130

131131
# Create a dataframe with the data to write and send them to ADX
@@ -169,7 +169,7 @@ def check_ingestion_status(
169169
if not remaining_ids:
170170
return
171171

172-
LOGGER.debug(T("coal.logs.adx.checking_status").format(count=len(remaining_ids)))
172+
LOGGER.debug(T("coal.services.adx.checking_status").format(count=len(remaining_ids)))
173173

174174
# Get status queues
175175
qs = KustoIngestStatusQueues(client)
@@ -183,7 +183,7 @@ def get_messages(queues):
183183
successes = get_messages(qs.success._get_queues())
184184
failures = get_messages(qs.failure._get_queues())
185185

186-
LOGGER.debug(T("coal.logs.adx.status_messages").format(success=len(successes), failure=len(failures)))
186+
LOGGER.debug(T("coal.services.adx.status_messages").format(success=len(successes), failure=len(failures)))
187187

188188
queued_ids = list(remaining_ids)
189189
# Process success and failure messages
@@ -199,7 +199,7 @@ def get_messages(queues):
199199
if dm.IngestionSourceId == str(source_id):
200200
_ingest_status[source_id] = status
201201

202-
log_function(T("coal.logs.adx.status_found").format(source_id=source_id, status=status.value))
202+
log_function(T("coal.services.adx.status_found").format(source_id=source_id, status=status.value))
203203

204204
_q.delete_message(_m)
205205
remaining_ids.remove(source_id)
@@ -213,7 +213,7 @@ def get_messages(queues):
213213
for source_id in remaining_ids:
214214
if time.time() - _ingest_times[source_id] > actual_timeout:
215215
_ingest_status[source_id] = IngestionStatus.TIMEOUT
216-
LOGGER.warning(T("coal.logs.adx.ingestion_timeout").format(source_id=source_id))
216+
LOGGER.warning(T("coal.services.adx.ingestion_timeout").format(source_id=source_id))
217217

218218
# Yield results for remaining IDs
219219
for source_id in queued_ids:
@@ -237,7 +237,7 @@ def monitor_ingestion(
237237
has_failures = False
238238
source_ids_copy = source_ids.copy()
239239

240-
LOGGER.info(T("coal.logs.adx.waiting_ingestion"))
240+
LOGGER.info(T("coal.services.adx.waiting_ingestion"))
241241

242242
with tqdm.tqdm(desc="Ingestion status", total=len(source_ids_copy)) as pbar:
243243
while any(
@@ -252,7 +252,7 @@ def monitor_ingestion(
252252
for ingestion_id, ingestion_status in results:
253253
if ingestion_status == IngestionStatus.FAILURE:
254254
LOGGER.error(
255-
T("coal.logs.adx.ingestion_failed").format(
255+
T("coal.services.adx.ingestion_failed").format(
256256
ingestion_id=ingestion_id, table=table_ingestion_id_mapping.get(ingestion_id)
257257
)
258258
)
@@ -273,14 +273,14 @@ def monitor_ingestion(
273273
for ingestion_id, ingestion_status in results:
274274
if ingestion_status == IngestionStatus.FAILURE:
275275
LOGGER.error(
276-
T("coal.logs.adx.ingestion_failed").format(
276+
T("coal.services.adx.ingestion_failed").format(
277277
ingestion_id=ingestion_id, table=table_ingestion_id_mapping.get(ingestion_id)
278278
)
279279
)
280280
has_failures = True
281281
pbar.update(len(source_ids_copy))
282282

283-
LOGGER.info(T("coal.logs.adx.ingestion_completed"))
283+
LOGGER.info(T("coal.services.adx.ingestion_completed"))
284284
return has_failures
285285

286286

@@ -298,7 +298,7 @@ def handle_failures(kusto_client: KustoClient, database: str, operation_tag: str
298298
bool: True if the process should abort, False otherwise
299299
"""
300300
if has_failures:
301-
LOGGER.warning(T("coal.logs.adx.failures_detected").format(operation_tag=operation_tag))
301+
LOGGER.warning(T("coal.services.adx.failures_detected").format(operation_tag=operation_tag))
302302
_drop_by_tag(kusto_client, database, operation_tag)
303303
return True
304304
return False
@@ -314,10 +314,10 @@ def clear_ingestion_status_queues(client: QueuedIngestClient, confirmation: bool
314314
confirmation: Must be True to proceed with clearing
315315
"""
316316
if not confirmation:
317-
LOGGER.warning(T("coal.logs.adx.clear_queues_no_confirmation"))
317+
LOGGER.warning(T("coal.services.adx.clear_queues_no_confirmation"))
318318
return
319319

320-
LOGGER.warning(T("coal.logs.adx.clearing_queues"))
320+
LOGGER.warning(T("coal.services.adx.clearing_queues"))
321321
qs = KustoIngestStatusQueues(client)
322322

323323
while not qs.success.is_empty():
@@ -326,4 +326,4 @@ def clear_ingestion_status_queues(client: QueuedIngestClient, confirmation: bool
326326
while not qs.failure.is_empty():
327327
qs.failure.pop(32)
328328

329-
LOGGER.info(T("coal.logs.adx.queues_cleared"))
329+
LOGGER.info(T("coal.services.adx.queues_cleared"))

cosmotech/coal/azure/adx/query.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,13 @@ def run_query(client: KustoClient, database: str, query: str) -> KustoResponseDa
2424
Returns:
2525
KustoResponseDataSet: The results of the query
2626
"""
27-
LOGGER.debug(T("coal.logs.adx.running_query").format(database=database, query=query))
27+
LOGGER.debug(T("coal.services.adx.running_query").format(database=database, query=query))
2828

2929
result = client.execute(database, query)
3030
LOGGER.debug(
31-
T("coal.logs.adx.query_complete").format(rows=len(result.primary_results[0]) if result.primary_results else 0)
31+
T("coal.services.adx.query_complete").format(
32+
rows=len(result.primary_results[0]) if result.primary_results else 0
33+
)
3234
)
3335

3436
return result
@@ -46,9 +48,9 @@ def run_command_query(client: KustoClient, database: str, query: str) -> KustoRe
4648
Returns:
4749
KustoResponseDataSet: The results of the query
4850
"""
49-
LOGGER.debug(T("coal.logs.adx.running_command").format(database=database, query=query))
51+
LOGGER.debug(T("coal.services.adx.running_command").format(database=database, query=query))
5052

5153
result = client.execute_mgmt(database, query)
52-
LOGGER.debug(T("coal.logs.adx.command_complete"))
54+
LOGGER.debug(T("coal.services.adx.command_complete"))
5355

5456
return result

cosmotech/coal/azure/adx/runner.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def prepare_csv_content(folder_path: str) -> Dict[str, Dict[str, Any]]:
5757
cols = {k.strip(): "string" for k in headers}
5858
csv_datas = {"filename": _file.name.removesuffix(".csv"), "headers": cols}
5959
content[str(_file)] = csv_datas
60-
LOGGER.debug(T("coal.logs.adx.runner.content_debug").format(content=content))
60+
LOGGER.debug(T("coal.services.adx.content_debug").format(content=content))
6161

6262
return content
6363

@@ -110,7 +110,7 @@ def insert_csv_files(
110110
fields = file_info.get("headers")
111111
with open(file_path) as _f:
112112
file_size = sum(map(len, _f.readlines()))
113-
LOGGER.debug(T("coal.logs.data_transfer.sending_data").format(size=file_size))
113+
LOGGER.debug(T("coal.common.data_transfer.sending_data").format(size=file_size))
114114
fd = FileDescriptor(file_path, file_size)
115115
ord = 0
116116
mappings = list()

0 commit comments

Comments
 (0)