Skip to content

Commit

Permalink
add ordering tqdm
Browse files Browse the repository at this point in the history
  • Loading branch information
CodyCBakerPhD committed Aug 12, 2024
1 parent 7db9f9d commit 5d85375
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/dandi_s3_log_parser/_dandi_s3_log_file_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ def asset_id_handler(*, raw_asset_id: str) -> str:
total=len(per_job_parsed_s3_log_file_paths),
position=1,
leave=False,
mininterval=1.0,
mininterval=3.0,
):
merged_temporary_file_path = temporary_output_folder_path / per_job_parsed_s3_log_file_path.name

Expand All @@ -202,6 +202,8 @@ def asset_id_handler(*, raw_asset_id: str) -> str:
path_or_buf=merged_temporary_file_path, mode="a", sep="\t", header=header, index=False
)

print("\n\n")

# Always apply this step at the end to be sure we maintained chronological order
# (even if you think order of iteration itself was performed chronologically)
# This step also adds the index counter to the TSV
Expand Down
11 changes: 10 additions & 1 deletion src/dandi_s3_log_parser/_order_parsed_logs.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import importlib.metadata

import pandas
import tqdm

from ._config import DANDI_S3_LOG_PARSER_BASE_FOLDER_PATH

Expand All @@ -21,7 +22,15 @@ def order_parsed_logs(
date = datetime.datetime.now().strftime("%y%m%d")
ordering_errors_file_path = errors_folder_path / f"v{dandi_s3_log_parser_version}_{date}_ordering_errors.txt"

for unordered_parsed_s3_log_file_path in unordered_parsed_s3_log_folder_path.glob("*.tsv"):
unordered_file_paths = list(unordered_parsed_s3_log_folder_path.glob("*.tsv"))
for unordered_parsed_s3_log_file_path in tqdm.tqdm(
iterable=unordered_parsed_s3_log_folder_path.glob("*.tsv"),
len=(unordered_file_paths),
desc="Ordering parsed logs...",
position=0,
leave=True,
mininterval=3.0,
):
try:
error_message = f"Ordering {unordered_parsed_s3_log_file_path}...\n\n"

Expand Down

0 comments on commit 5d85375

Please sign in to comment.