From 61ee995beac8ea3724c9b167661837c0fcf4f50c Mon Sep 17 00:00:00 2001 From: Ludovico Bianchi Date: Tue, 14 Jun 2022 14:43:05 -0500 Subject: [PATCH 1/3] Update pylint version for Python 3.9 and 3.10 support --- .pylint/foqus_transform.py | 1 + foqus_lib/framework/graph/graph.py | 2 +- foqus_lib/framework/listen/listen.py | 4 ++++ foqus_lib/framework/sdoe/irsf.py | 3 +++ foqus_lib/framework/sim/turbineConfiguration.py | 4 ++++ foqus_lib/framework/uq/Model.py | 4 ++-- foqus_lib/gui/model/dmfUploadDialog.py | 2 +- requirements-dev.txt | 4 ++-- 8 files changed, 18 insertions(+), 6 deletions(-) diff --git a/.pylint/foqus_transform.py b/.pylint/foqus_transform.py index 272e635ca..2f8cf87e0 100644 --- a/.pylint/foqus_transform.py +++ b/.pylint/foqus_transform.py @@ -43,6 +43,7 @@ def emit(self, *args): PYQTSIGNAL_ATTRIBUTE_NAMES = frozenset( [ "currentIndexChanged", + "valueChanged", ] ) diff --git a/foqus_lib/framework/graph/graph.py b/foqus_lib/framework/graph/graph.py index 426a8f39a..f9a327303 100644 --- a/foqus_lib/framework/graph/graph.py +++ b/foqus_lib/framework/graph/graph.py @@ -940,7 +940,7 @@ def runListAsThread( else: newGr.res_re = resubs else: - raise ("Must supply runList or jobIds") + raise ValueError("Must supply runList or jobIds") newGr.status = { "unfinished": len(newGr.res), "finished": 0, diff --git a/foqus_lib/framework/listen/listen.py b/foqus_lib/framework/listen/listen.py index 2291f87f2..f757600a7 100644 --- a/foqus_lib/framework/listen/listen.py +++ b/foqus_lib/framework/listen/listen.py @@ -187,6 +187,9 @@ def run(self): self.gt.join() ret = [] stat = [] + # WHY pylint infers `res` as an unsubscriptable object + # (possibly because of None default value?) + # pylint: disable=unsubscriptable-object for res in self.gt.res: self.dat.flowsheet.results.addFromSavedValues( self.resStoreSet, "res_{0}".format(self.runid), None, res @@ -203,6 +206,7 @@ def run(self): for i in range(len(r)): r[i] = self.failValue ret.append(r) + # pylint: enable=unsubscriptable-object conn.send(["result", stat, ret]) elif msg[0] == "save": # Save the flow sheet diff --git a/foqus_lib/framework/sdoe/irsf.py b/foqus_lib/framework/sdoe/irsf.py index 5b540e160..e242c8f8a 100644 --- a/foqus_lib/framework/sdoe/irsf.py +++ b/foqus_lib/framework/sdoe/irsf.py @@ -188,7 +188,10 @@ def criterion(cand, args, nr, nd, mode="maximin", hist=None, test=False): PV_tuple = () for key in PV: if len(PV[key].shape) == 1: + # WHY: causes `modified-iterating-dict` in pylint 2.14.1 + # pylint: disable=modified-iterating-dict PV[key] = np.expand_dims(PV[key], axis=0) + # pylint: enable=modified-iterating-dict PV_tuple += (PV[key],) PV_arr = np.concatenate(PV_tuple, axis=0) PV_df = pd.DataFrame(data=PV_arr, columns=["Best Input", "Best Response"]) diff --git a/foqus_lib/framework/sim/turbineConfiguration.py b/foqus_lib/framework/sim/turbineConfiguration.py index d829ef865..892d1f794 100644 --- a/foqus_lib/framework/sim/turbineConfiguration.py +++ b/foqus_lib/framework/sim/turbineConfiguration.py @@ -231,6 +231,10 @@ def __init__(self, path="turbine.cfg"): self.aspenVersion = 2 self.dat = None self.tldb = None + # WHY: setting these directly in makeCopy without defining them as attributes here + # triggers no-member errors in pylint 2.14.1 + self.configExt = None + self.subDir = None @property def notification(self): diff --git a/foqus_lib/framework/uq/Model.py b/foqus_lib/framework/uq/Model.py index d6ab08d6a..22c5db9f0 100644 --- a/foqus_lib/framework/uq/Model.py +++ b/foqus_lib/framework/uq/Model.py @@ -104,6 +104,7 @@ Gets the filename of the driver or emulator """ +import collections.abc import numbers, json import numpy @@ -272,9 +273,8 @@ def getEmulatorOutputStatus(self): return self.emulatorOutputStatus def setEmulatorOutputStatus(self, outputIds, value): - import collections - if isinstance(outputIds, collections.Sequence): # Check if list or tuple + if isinstance(outputIds, collections.abc.Sequence): # Check if list or tuple for outputId in outputIds: self.emulatorOutputStatus[outputId] = value else: diff --git a/foqus_lib/gui/model/dmfUploadDialog.py b/foqus_lib/gui/model/dmfUploadDialog.py index 97fd169ac..a19c88544 100644 --- a/foqus_lib/gui/model/dmfUploadDialog.py +++ b/foqus_lib/gui/model/dmfUploadDialog.py @@ -356,7 +356,7 @@ def browseSinter(self): self.files[1] = ["model", m_path] self.updateFileTable() self.appEdit.setText(a) - except: + except Exception as e: QMessageBox.information(self, "Error", str(e)) logging.getLogger("foqus." + __name__).exception( "Error reading sinter config" diff --git a/requirements-dev.txt b/requirements-dev.txt index d20bad7c0..b8b4959b8 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -2,11 +2,11 @@ # These will override requirements picked up from setup.py below: # pinning the pylint version to ensure reproducible behavior and defaults -pylint==2.6.0 +pylint==2.14.1 # also pinning the version for astroid (used by pylint to analyze the AST) # since there can be significant differences between (non-major) versions, # both in terms of behavior and performance -astroid==2.4.2 +astroid==2.11.6 pytest ### coverage coverage From 1fa704b3764e42752dda5d1ca012c6a3a4733a4c Mon Sep 17 00:00:00 2001 From: Ludovico Bianchi Date: Tue, 14 Jun 2022 14:43:37 -0500 Subject: [PATCH 2/3] Add Python 3.9 and 3.10 to supported Python versions --- .github/workflows/checks.yml | 6 ++++-- docs/source/chapt_install/install_python.rst | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 752f55f2d..ea14bf2e8 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -58,7 +58,8 @@ jobs: python-version: - '3.7' - '3.8' - # - '3.9' + - '3.9' + - '3.10' os: - linux - win64 @@ -125,7 +126,8 @@ jobs: python-version: - '3.7' - '3.8' - # - '3.9' + - '3.9' + - '3.10' steps: - uses: actions/checkout@v2 - name: Set up Conda diff --git a/docs/source/chapt_install/install_python.rst b/docs/source/chapt_install/install_python.rst index ca8a02e44..851b3a6ab 100644 --- a/docs/source/chapt_install/install_python.rst +++ b/docs/source/chapt_install/install_python.rst @@ -3,7 +3,7 @@ Install Python -------------- -Python version 3.7 up through 3.8 is required to run FOQUS. +Python version 3.7 up through 3.10 is required to run FOQUS. We recommend using either the `Miniconda `_ or `Anaconda `_ Python distribution and package management @@ -17,7 +17,7 @@ ability to create self-contained python environments without any need for admini privileges. These separate environments can have different set of packages, isolating version dependencies when working with multiple python projects. -If you have a working version of Python 3.7 through 3.8, which you prefer over Anaconda, you can +If you have a working version of Python 3.7 through 3.10, which you prefer over Anaconda, you can skip these steps. Anaconda or Miniconda Install and Setup From 2ad26afb0429853543f387413c366eb4cb4ace6a Mon Sep 17 00:00:00 2001 From: Ludovico Bianchi Date: Thu, 16 Jun 2022 09:42:54 -0500 Subject: [PATCH 3/3] Remove 3.10 due to PyQt5 errors --- .github/workflows/checks.yml | 4 ++-- docs/source/chapt_install/install_python.rst | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index ea14bf2e8..2094614c2 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -59,7 +59,7 @@ jobs: - '3.7' - '3.8' - '3.9' - - '3.10' + # - '3.10' os: - linux - win64 @@ -127,7 +127,7 @@ jobs: - '3.7' - '3.8' - '3.9' - - '3.10' + # - '3.10' steps: - uses: actions/checkout@v2 - name: Set up Conda diff --git a/docs/source/chapt_install/install_python.rst b/docs/source/chapt_install/install_python.rst index 851b3a6ab..1c8e88f64 100644 --- a/docs/source/chapt_install/install_python.rst +++ b/docs/source/chapt_install/install_python.rst @@ -3,7 +3,7 @@ Install Python -------------- -Python version 3.7 up through 3.10 is required to run FOQUS. +Python version 3.7 up through 3.9 is required to run FOQUS. We recommend using either the `Miniconda `_ or `Anaconda `_ Python distribution and package management @@ -17,7 +17,7 @@ ability to create self-contained python environments without any need for admini privileges. These separate environments can have different set of packages, isolating version dependencies when working with multiple python projects. -If you have a working version of Python 3.7 through 3.10, which you prefer over Anaconda, you can +If you have a working version of Python 3.7 through 3.9, which you prefer over Anaconda, you can skip these steps. Anaconda or Miniconda Install and Setup