Skip to content

Commit

Permalink
flake fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Asthelen committed Jan 24, 2025
1 parent e459560 commit 2545a73
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
8 changes: 5 additions & 3 deletions mphys/network/remote_component.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import openmdao.api as om

Check failure on line 1 in mphys/network/remote_component.py

View workflow job for this annotation

GitHub Actions / build

Imports are incorrectly sorted and/or formatted.
import json, time, os
import numpy as np
import json
import time
import os


class RemoteComp(om.ExplicitComponent):
Expand Down Expand Up @@ -326,7 +328,7 @@ def _dump_json(self, remote_dict: dict, command: str):
if not os.path.isdir(save_dir):
try:
os.mkdir(save_dir)
except:
except Exception:
pass # may have been created by now, by a parallel server
if self._doing_derivative_evaluation(command):
filename = f"{save_dir}/{self.name}_{dict_type}_derivative{len(self.times_gradient)}.json"
Expand Down Expand Up @@ -499,4 +501,4 @@ def _receive_outputs_from_server(self):
raise NotImplementedError

def _setup_server_manager(self):
raise NotImplementedError
raise NotImplementedError
10 changes: 5 additions & 5 deletions mphys/network/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def _load_the_model(self):
self.prob = om.Problem()
self.prob.model = self.get_om_group_function_pointer()
if self.ignore_setup_warnings:
with warnings.catch_warnings(record=True) as w:
with warnings.catch_warnings(record=True):
self.prob.setup(mode="rev")
else:
self.prob.setup(mode="rev")
Expand All @@ -75,7 +75,7 @@ def _load_the_model(self):

def _run_model(self):
if self.ignore_runtime_warnings:
with warnings.catch_warnings(record=True) as w:
with warnings.catch_warnings(record=True):
self.prob.run_model()
else:
self.prob.run_model()
Expand All @@ -86,7 +86,7 @@ def _run_model(self):
def _compute_totals(self):
of, wrt = self._get_derivative_inputs_outputs()
if self.ignore_runtime_warnings:
with warnings.catch_warnings(record=True) as w:
with warnings.catch_warnings(record=True):
self.derivatives = self.prob.compute_totals(of=of, wrt=wrt)
else:
self.derivatives = self.prob.compute_totals(of=of, wrt=wrt)
Expand Down Expand Up @@ -407,7 +407,7 @@ def _set_additional_inputs_into_the_server_problem(
self.prob.get_val(key, get_remote=True)
!= input_dict["additional_inputs"][key]["val"]
)
if type(design_changed_condition) == type(True):
if isinstance(design_changed_condition, bool):
design_changed = deepcopy(design_changed_condition)
elif design_changed_condition.any():
design_changed = True
Expand Down Expand Up @@ -435,7 +435,7 @@ def _set_additional_constants_into_the_server_problem(
self.prob.get_val(key)
!= input_dict["additional_constants"][key]["val"]
)
if type(design_changed_condition) == type(True):
if isinstance(design_changed_condition, bool):
design_changed = deepcopy(design_changed_condition)
elif design_changed_condition.any():
design_changed = True
Expand Down

0 comments on commit 2545a73

Please sign in to comment.