Skip to content

Commit ac03573

Browse files
committed
feat: optimize well transfer process by removing redundant checks and enhancing logging
1 parent 3b0cbce commit ac03573

3 files changed

Lines changed: 164 additions & 162 deletions

File tree

transfers/geologic_formation_transfer.py

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,6 @@ def transfer_geologic_formations(session: Session, limit: int = None) -> tuple:
3838

3939
# 4. Process each row
4040
for i, row in enumerate(cleaned_df.itertuples()):
41-
# check if limit is reached
42-
if limit and i >= limit:
43-
logger.info(f"Reached limit of {limit} rows. Stopping migration.")
44-
break
45-
4641
# Log progress every 'step' rows
4742
if i and not i % step:
4843
logger.info(
@@ -67,18 +62,18 @@ def transfer_geologic_formations(session: Session, limit: int = None) -> tuple:
6762
continue
6863

6964
# Check if this formation already exists
70-
existing = (
71-
session.query(GeologicFormation)
72-
.filter(GeologicFormation.formation_code == formation_code)
73-
.first()
74-
)
75-
76-
if existing:
77-
logger.info(
78-
f"Skipping row {i}: Formation code {formation_code} already exists"
79-
)
80-
skipped_count += 1
81-
continue
65+
# existing = (
66+
# session.query(GeologicFormation)
67+
# .filter(GeologicFormation.formation_code == formation_code)
68+
# .first()
69+
# )
70+
#
71+
# if existing:
72+
# logger.info(
73+
# f"Skipping row {i}: Formation code {formation_code} already exists"
74+
# )
75+
# skipped_count += 1
76+
# continue
8277

8378
# 6. Prepare data for creation
8479
# Note: We only store the formation_code. Formation names will be mapped by the API using a

transfers/util.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ def convert_mt_to_utc(dt_record: datetime) -> datetime:
382382
return dt_record
383383

384384

385-
def chunk_by_size(df: pd.DataFrame | list, chunk_size: int) -> pd.DataFrame:
385+
def chunk_by_size(df: pd.DataFrame | list, chunk_size: int = 100) -> pd.DataFrame:
386386
if isinstance(df, list):
387387
df = pd.DataFrame(df)
388388

0 commit comments

Comments
 (0)