Skip to content

Commit

Permalink
fix: reduce tqdm progress display unless on TTY (#21)
Browse files Browse the repository at this point in the history
  • Loading branch information
holtgrewe committed Jun 21, 2023
1 parent 75c485b commit 770b0c8
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion clinvar_tsv/parse_clinvar_xml.py
Expand Up @@ -9,6 +9,7 @@
"""

import json
import sys
import xml.etree.ElementTree as ET

import binning
Expand Down Expand Up @@ -81,7 +82,9 @@ def run(self): # noqa: C901
for d in out_files.values():
for out_file in d.values():
print(TSV_HEADER, file=out_file)
with tqdm.tqdm(unit="rcvs") as progress:
# Reduce the progress bar refresh rate if we're not in a TTY
mininterval = 0.1 if sys.stdout.isatty() else 60
with tqdm.tqdm(unit="rcvs", mininterval=mininterval) as progress:
for event, elem in ET.iterparse(self.input):
if elem.tag == "ClinVarSet" and event == "end":
self.rcvs += 1
Expand Down

0 comments on commit 770b0c8

Please sign in to comment.