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

flush streams and files before/after optimization #403

Merged
merged 1 commit into from
Jun 5, 2024
Merged
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
12 changes: 8 additions & 4 deletions pyoptsparse/pySNOPT/pySNOPT.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@
pySNOPT - A variation of the pySNOPT wrapper specifically designed to
work with sparse optimization problems.
"""

# Standard Python modules
import datetime
import os
import re
import sys

Check warning on line 10 in pyoptsparse/pySNOPT/pySNOPT.py

View check run for this annotation

Codecov / codecov/patch

pyoptsparse/pySNOPT/pySNOPT.py#L10

Added line #L10 was not covered by tests
import time
from typing import Any, Dict, Optional, Tuple

Expand Down Expand Up @@ -259,6 +261,9 @@
self.startTime = time.time()
self.callCounter = 0
self.storeSens = storeSens
# flush the output streams
sys.stdout.flush()
sys.stderr.flush()

# Store the starting time if the keyword timeLimit is given:
self.timeLimit = timeLimit
Expand Down Expand Up @@ -513,6 +518,8 @@
"pi": pi,
}

self._on_flushFiles()

else: # We are not on the root process so go into waiting loop:
self._waitLoop()
restartDict = None
Expand Down Expand Up @@ -559,10 +566,7 @@
elif fail == 2:
mode = -2

# Flush the files to the buffer for all the people who like to
# monitor the residual
snopt.pyflush(self.getOption("iPrint"))
snopt.pyflush(self.getOption("iSumm"))
self._on_flushFiles()

# Check if we've exceeded the timeLimit
if self.timeLimit is not None:
Expand Down
Loading