Skip to content

Commit

Permalink
fix: reporting of count_glob and identified records
Browse files Browse the repository at this point in the history
  • Loading branch information
Sieboldianus committed Aug 22, 2019
1 parent dc87e87 commit 7feb38a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 12 deletions.
1 change: 1 addition & 0 deletions lbsntransform/__main__.py
Expand Up @@ -109,6 +109,7 @@ def main():
f'Count per type: '
f'{lbsntransform.lbsn_records.get_type_counts()}'
f'records.', end='\r')
sys.stdout.flush()
if (config.transferlimit and
lbsntransform.processed_total >= config.transferlimit):
break
Expand Down
16 changes: 5 additions & 11 deletions lbsntransform/classes/helper_functions.py
Expand Up @@ -501,6 +501,10 @@ def __init__(self):
(self.lbsn_relationship_dict, Relationship().DESCRIPTOR.name)
]

def get_current_count(self):
count_glob = self.count_glob
return count_glob

def get_all_records(self) -> Iterator[Tuple[Any, str]]:
"""Returns tuple of 1) all records from self
in correct order using all_dicts and 2) Type of record
Expand Down Expand Up @@ -604,21 +608,11 @@ def add_record_to_dict(self, newrecord):
self.count_dup_merge += 1
else:
# just count new entries
self.count_progress_report()
self.count_glob += 1
# update keyHash only necessary for new record
self.update_key_hash(newrecord)
sel_dict[pkeyID] = newrecord

def count_progress_report(self):
self.count_glob += 1
if self.count_glob % 1000 == 0:
# progress report (modulo)
print(
f'Identified LBSN Records: {self.count_glob}..'
f'{"".join([" " for x in range(1, 200)])}',
end='\r')
sys.stdout.flush()

def add_relationship_to_dict(self, newrelationship):
pkey_id = f'{newrelationship.pkey.relation_to.origin.origin_id}' \
f'{newrelationship.pkey.relation_to.id}' \
Expand Down
3 changes: 2 additions & 1 deletion lbsntransform/classes/submit_data.py
Expand Up @@ -113,9 +113,10 @@ def store_lbsn_record_dicts(self, lbsn_record_dicts):
# self.headersWritten.clear()
r_cnt = 0
self.count_affected = 0
g_cnt = lbsn_record_dicts.get_current_count()
for record, type_name in lbsn_record_dicts.get_all_records():
r_cnt += 1
print(f'Storing {r_cnt} of {lbsn_record_dicts.count_glob} '
print(f'Storing {r_cnt} of {g_cnt} '
f'lbsn records ({type_name})..', end='\r')
self.prepare_lbsn_record(record, type_name)
self.count_glob += 1 # self.dbCursor.rowcount
Expand Down

0 comments on commit 7feb38a

Please sign in to comment.