Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Quick implementation of progress bar option for the run method #1377

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions opendrift/models/basemodel/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1738,7 +1738,8 @@ def run(self,
outfile=None,
export_variables=None,
export_buffer_length=100,
stop_on_error=False):
stop_on_error=False,
progress_bar=False):
"""Start a trajectory simulation, after initial configuration.

Performs the main loop:
Expand Down Expand Up @@ -2009,7 +2010,13 @@ def run(self,
self.timer_end('preparing main loop')
self.timer_start('main loop')
self.memory_usage = np.array([])
for i in range(self.expected_steps_calculation):

if progress_bar:
from tqdm.auto import trange
iterator = trange
else:
iterator = range
for i in iterator(self.expected_steps_calculation):
self.memory_usage = np.append(self.memory_usage, psutil.virtual_memory().used / (1024.0**3))
try:
# Release elements
Expand Down