Skip to content
This repository was archived by the owner on Aug 28, 2024. It is now read-only.

Commit

Permalink
Set the progress bar in tqdm so that it manually updates
Browse files Browse the repository at this point in the history
  • Loading branch information
daminton committed Nov 22, 2022
1 parent 9f429d1 commit e6de73a
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions python/swiftest/swiftest/simulation_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,14 +377,16 @@ def _run_swiftest_driver(self):
env=env,
universal_newlines=True) as p:
process_output = False
noutput = int((self.param['TSTOP'] - self.param['T0']) / (self.param['DT'] * self.param['ISTEP_OUT']))
for line in tqdm(p.stdout,total=noutput):
noutput = int((self.param['TSTOP'] - self.param['T0']) / self.param['DT'])
pbar = tqdm(total=noutput)
for line in p.stdout:
if "SWIFTEST STOP" in line:
process_output = False

if process_output:
kvstream=line.replace('\n','').strip().split(';') # Removes the newline character,
output_data = {kv.split()[0]: kv.split()[1] for kv in kvstream[:-1]}
pbar.update(self.param['ISTEP_OUT'])

if "SWIFTEST START" in line:
process_output = True
Expand All @@ -397,6 +399,7 @@ def _run_swiftest_driver(self):
except:
warnings.warn(f"Error executing main swiftest_driver program", stacklevel=2)

pbar.close()
return

def run(self,**kwargs):
Expand Down

0 comments on commit e6de73a

Please sign in to comment.