Skip to content

Commit 9e2fb81

Browse files
committed
rare python version NoneTypes fix and rewrite to schem file stopped
1 parent 8a33b12 commit 9e2fb81

File tree

3 files changed

+29
-3
lines changed

3 files changed

+29
-3
lines changed

ARM_template.json

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,17 @@
9191
"metadata": {
9292
"description": "Time interval (in secs), incremental sync waits before replicating accumulated changes when next event occurs"
9393
}
94-
}
94+
},
95+
"OwnerTag":{
96+
"defaultValue": "your_username",
97+
"type":"string",
98+
"metadata": {"description": "Owner tag for the resource"}
99+
},
100+
"KeepUntilTag":{
101+
"defaultValue": "2025-12-30",
102+
"type": "string",
103+
"metadata": {"Description": "Date to keep the resource running"}
104+
}
95105
},
96106
"variables": {
97107
"appServicePlanPortalName": "[format('AppServicePlan-{0}', parameters('webAppName'))]"

schema_utils.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
from datetime import datetime
22
import os
33
import logging
4-
from types import NoneType
4+
#17June2025 - doesnt work for 3.9 and lesser Python versions
5+
#from types import NoneType
56
import bson.int64
67
import pymongo
78
import pandas as pd
@@ -30,6 +31,8 @@
3031

3132

3233
logger = logging.getLogger(f"{__name__}")
34+
#17June2025 - added NoneType manually instead of importing from types for 3.9 and lesser Python versions
35+
NoneType = type(None)
3336

3437
def _converter_template(obj, type_name, raw_convert_func, default_value=None):
3538
original_type = type(obj)
@@ -228,7 +231,9 @@ def init_table_schema(table_name: str):
228231
)
229232
if schema_of_this_table:
230233
logger.info(f"loaded schema of {table_name} from file")
231-
schemas.init_table_schema(table_name, schema_of_this_table)
234+
# schemas.init_table_schema(table_name, schema_of_this_table)
235+
# 9 May 2025 should not write back to internal schema file
236+
schemas.init_table_schema_to_mem(table_name, schema_of_this_table)
232237
# load column renaming if it exists, otherwise this table has been previously
233238
# initiated but no column is renamed, so we don't need to do anything
234239
table_column_renaming = read_from_file(
@@ -282,6 +287,9 @@ def process_dataframe(table_name_param: str, df: pd.DataFrame):
282287

283288

284289
processed_col_name = schemas.find_column_renaming(table_name, col_name)
290+
logger.debug(
291+
f"%%%% Processed col name found: processed_col_name is {processed_col_name} %%%%%"
292+
)
285293
schema_of_this_column = schemas.get_table_column_schema(table_name, col_name)
286294
logger.debug(
287295
f"%%%% In process_df: schema_of_this_column is {schema_of_this_column} %%%%%"
@@ -311,6 +319,8 @@ def process_dataframe(table_name_param: str, df: pd.DataFrame):
311319
if processed_col_name and processed_col_name != col_name:
312320
df.rename(columns={col_name: processed_col_name}, inplace=True)
313321
col_name = processed_col_name
322+
# May 9 : get schema from file for the renamed column
323+
schema_of_this_column = schemas.get_table_column_schema(table_name, col_name)
314324

315325
# schema_of_this_column should always exists at this point
316326
# existing column or new column with schema appended, process according to schema_of_this_column

schemas.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@ def init_table_schema(table_name: str, table_schema: dict):
2929
__locks[table_name] = threading.Lock()
3030
write_table_schema_to_file(table_name)
3131

32+
# 9 May 2025 when schema file exists no need to rewrite it
33+
def init_table_schema_to_mem(table_name: str, table_schema: dict):
34+
__schemas[table_name] = table_schema
35+
__locks[table_name] = threading.Lock()
36+
# write_table_schema_to_file(table_name)
37+
3238

3339
def get_table_schema(table_name: str) -> dict:
3440
return __schemas.get(table_name, None)

0 commit comments

Comments
 (0)