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

Removing all wildcard imports #1252

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion .github/actions/pylint/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ runs:
shell: bash
run: |
echo '::group::Output of pylint'
pylint --rcfile=.pylint/pylintrc --disable=all --enable=E --enable=wrong-import-order,unused-import foqus_lib/
pylint --rcfile=.pylint/pylintrc --disable=all --enable=E --enable=wrong-import-order,unused-import,wildcard-import foqus_lib/
echo '::endgroup::'

12 changes: 9 additions & 3 deletions foqus_lib/foqus.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@
Keith Beattie, Lawrence Berkeley National Labs, 2020
"""

# Imports
import argparse
import json
import logging

# Imports
import os
import shutil
import signal
import sys
import time
Expand All @@ -34,7 +35,12 @@
# FOQUS imports
import foqus_lib.version.version as ver # foqus version and other info
from foqus_lib.framework.listen.listen import foqusListener2
from foqus_lib.framework.session.session import *
from foqus_lib.framework.session.session import (
generalSettings,
makeWorkingDirStruct,
makeWorkingDirFiles,
session,
)
from foqus_lib.gui.make_shortcut import makeShortcut

loadGUI = False
Expand Down
2 changes: 1 addition & 1 deletion foqus_lib/framework/foqusOptions/optionList.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
John Eslick, Carnegie Mellon University, 2014
"""

from foqus_lib.framework.foqusOptions.option import *
from foqus_lib.framework.foqusOptions.option import option


class optionList(dict):
Expand Down
3 changes: 0 additions & 3 deletions foqus_lib/framework/graph/OptGraphOptim.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@
#################################################################################
import numpy

from foqus_lib.framework.graph.edge import *
from foqus_lib.framework.graph.node import *
bpaul4 marked this conversation as resolved.
Show resolved Hide resolved


class optimObj:
def __init__(self, pycode="", ps=1, failval=1000):
Expand Down
11 changes: 6 additions & 5 deletions foqus_lib/framework/graph/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import copy
import logging
import math
import os
import sys
import threading
import time
Expand All @@ -33,12 +34,12 @@
import pandas

import foqus_lib.framework.sampleResults.results as resultList
from foqus_lib.framework.graph.edge import * # Edge and variable connection classes
from foqus_lib.framework.graph.node import * # Node, input var and output var classes
from foqus_lib.framework.foqusException.foqusException import foqusException
from foqus_lib.framework.graph.edge import edge
from foqus_lib.framework.graph.node import Node, NodeEx
from foqus_lib.framework.graph.nodeModelTypes import nodeModelTypes
from foqus_lib.framework.graph.nodeVars import *
from foqus_lib.framework.graph.OptGraphOptim import * # Objective function calculation class
from foqus_lib.framework.sim.turbineConfiguration import *
from foqus_lib.framework.graph.nodeVars import NodeVarList, NodeVarVectorList
from foqus_lib.framework.sim.turbineConfiguration import TurbineConfiguration

_log = logging.getLogger("foqus." + __name__)

Expand Down
5 changes: 3 additions & 2 deletions foqus_lib/framework/graph/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,11 @@
import numpy as np

from foqus_lib.framework.at_dict.at_dict import AtDict
from foqus_lib.framework.foqusException.foqusException import foqusException
from foqus_lib.framework.foqusOptions.optionList import optionList
from foqus_lib.framework.graph.nodeModelTypes import nodeModelTypes
from foqus_lib.framework.graph.nodeVars import *
from foqus_lib.framework.pymodel.pymodel import *
from foqus_lib.framework.graph.nodeVars import NodeVars, NodeVarVector
from foqus_lib.framework.pymodel.pymodel import pymodel
from foqus_lib.framework.sim.turbineConfiguration import TurbineInterfaceEx

_logger = logging.getLogger("foqus." + __name__)
Expand Down
2 changes: 1 addition & 1 deletion foqus_lib/framework/graph/nodeVars.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
from collections import OrderedDict


from foqus_lib.framework.foqusException.foqusException import *
from foqus_lib.framework.foqusException.foqusException import foqusException
from foqus_lib.framework.uq.Distribution import Distribution

ivarScales = [ # list of scaling options for input variables
Expand Down
11 changes: 4 additions & 7 deletions foqus_lib/framework/optimizer/SM_Optimizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,7 @@

# Check that the required pyomo, pyDOE, and smt packages are available for the surrogate based optimization plugin and import it.
# If not the Surrogate Based Optimization plug-in will not be available.

try:
# add direct imports (in addition to existing wildcard import)
# to make pylint happy without affecting the existing runtime behavior
import pyutilib.subprocess.GlobalData
from pyomo.environ import (
ConstraintList,
Expand All @@ -57,13 +54,13 @@
from pyomo.opt import SolverFactory

pyutilib.subprocess.GlobalData.DEFINE_SIGNAL_HANDLERS_DEFAULT = False
from pyDOE import *
import pyDOE # pylint: disable=unused-import

Check warning on line 57 in foqus_lib/framework/optimizer/SM_Optimizer.py

View check run for this annotation

Codecov / codecov/patch

foqus_lib/framework/optimizer/SM_Optimizer.py#L57

Added line #L57 was not covered by tests
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't look like this import is covered, or necessary. Can this be removed?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this is a tricky one. I left it in and added the pylint disable because I believe that Anuja (who wrote this code) was using it to detect if the SM Opt "plugin" was available or not. I actually couldn't find where else it is used. I would like to get @anujad95 to review and test this part directly, if possible.

from smt.sampling_methods import LHS

packages_available = True
except ImportError:
logging.getLogger("foqus." + __name__).info(
"Failed to import the required packages for SM Optimizer solver"
except ImportError as ie:
logging.getLogger("foqus." + __name__).warn(
"Failed to import the required packages for SM Optimizer solver: " + str(ie)
)
packages_available = False

Expand Down
2 changes: 0 additions & 2 deletions foqus_lib/framework/optimizer/optimization.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@

from foqus_lib.framework.foqusOptions.optionList import optionList

from .problem import *
bpaul4 marked this conversation as resolved.
Show resolved Hide resolved


class optimization(threading.Thread):
"""
Expand Down
4 changes: 2 additions & 2 deletions foqus_lib/framework/pymodel/heat_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@

import numpy

from foqus_lib.framework.graph.nodeVars import *
from foqus_lib.framework.pymodel.pymodel import *
from foqus_lib.framework.graph.nodeVars import NodeVars
from foqus_lib.framework.pymodel.pymodel import pymodel

Check warning on line 23 in foqus_lib/framework/pymodel/heat_integration.py

View check run for this annotation

Codecov / codecov/patch

foqus_lib/framework/pymodel/heat_integration.py#L22-L23

Added lines #L22 - L23 were not covered by tests
Comment on lines +22 to +23
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Digging a bit into the files, the coverage issue is because this file is never executed directly:

# def test_load_and_run_heatintegration(self, active_session, simnode):

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this is related to the whole plugin management problem (described in #1085) but shelved due to lack of time. If we could get it into the CI somehow, that would be great.



def checkAvailable():
Expand Down
2 changes: 1 addition & 1 deletion foqus_lib/framework/pymodel/matlab_fs.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import subprocess
import time

from foqus_lib.framework.pymodel.pymodel import *
from foqus_lib.framework.pymodel.pymodel import pymodel

# Check that the MATLAB engine module is available and import it if possible.
# If not the MATLAB plug-in cannot be used.
Expand Down
2 changes: 0 additions & 2 deletions foqus_lib/framework/pymodel/pymodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
#################################################################################
from collections import OrderedDict

from foqus_lib.framework.graph.nodeVars import *
bpaul4 marked this conversation as resolved.
Show resolved Hide resolved


class pymodel:
def __init__(self):
Expand Down
4 changes: 2 additions & 2 deletions foqus_lib/framework/pymodel/pymodel_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
#
# FOQUS_PYMODEL_PLUGIN

from foqus_lib.framework.graph.nodeVars import *
from foqus_lib.framework.pymodel.pymodel import *
from foqus_lib.framework.graph.nodeVars import NodeVars
from foqus_lib.framework.pymodel.pymodel import pymodel


def checkAvailable():
Expand Down
4 changes: 2 additions & 2 deletions foqus_lib/framework/pymodel/steam_cycle.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@

import numpy

from foqus_lib.framework.graph.nodeVars import *
from foqus_lib.framework.pymodel.pymodel import *
from foqus_lib.framework.graph.nodeVars import NodeVars
from foqus_lib.framework.pymodel.pymodel import pymodel

Check warning on line 21 in foqus_lib/framework/pymodel/steam_cycle.py

View check run for this annotation

Codecov / codecov/patch

foqus_lib/framework/pymodel/steam_cycle.py#L20-L21

Added lines #L20 - L21 were not covered by tests
Comment on lines +20 to +21
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as heat integration, no coverage probably because the plugin GUI test is commented out.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's look into how we might be able to add those test back.



def checkAvailable():
Expand Down
10 changes: 6 additions & 4 deletions foqus_lib/framework/session/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,17 @@
John Eslick, Carnegie Mellon University, 2014
"""
import collections
import copy
import json
import logging
import os
import shutil
import sys
import time
import uuid

from foqus_lib import core
import foqus_lib.framework.optimizer.problem as oprob
from foqus_lib import core
from foqus_lib.framework.graph.graph import Graph
from foqus_lib.framework.ml_ai_models import mlaiSearch
from foqus_lib.framework.optimizer import problem
Expand All @@ -41,9 +43,9 @@
from foqus_lib.framework.sampleResults.results import Results
from foqus_lib.framework.sim.turbineConfiguration import TurbineConfiguration
from foqus_lib.framework.surrogate import surrogate
from foqus_lib.framework.uq.LocalExecutionModule import *
from foqus_lib.framework.uq.Model import *
from foqus_lib.framework.uq.SampleData import *
from foqus_lib.framework.uq.LocalExecutionModule import LocalExecutionModule
from foqus_lib.framework.uq.Model import Model
from foqus_lib.framework.uq.SampleData import SampleData

# Before the session class there are a few functions to help set up the
# FOQUS environment.
Expand Down
2 changes: 1 addition & 1 deletion foqus_lib/framework/sim/turbineConfiguration.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@

from foqus_lib import core
import foqus_lib.framework.sim.process_management as _pm
from foqus_lib.framework.foqusException.foqusException import *
from foqus_lib.framework.foqusException.foqusException import foqusException

_log = logging.getLogger("foqus." + __name__)

Expand Down
4 changes: 2 additions & 2 deletions foqus_lib/framework/solventfit/SolventFit.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@

import numpy as np

from foqus_lib.framework.uq.Common import *
from foqus_lib.framework.uq.Distribution import *
from foqus_lib.framework.uq.Common import Common
from foqus_lib.framework.uq.Distribution import Distribution
from foqus_lib.framework.uq.Plotter import Plotter
from foqus_lib.framework.uq.RSInference import RSInferencer

Expand Down
4 changes: 2 additions & 2 deletions foqus_lib/framework/solventfit/SolventFit_testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
import csv
import os

from foqus_lib.framework.uq.Common import Common

Check warning on line 18 in foqus_lib/framework/solventfit/SolventFit_testing.py

View check run for this annotation

Codecov / codecov/patch

foqus_lib/framework/solventfit/SolventFit_testing.py#L18

Added line #L18 was not covered by tests

# print(sys.path)
# sys.path.append('/Users/a241211/Documents/CCSI/Solvents/RCode/SolventFit/');
# sys.path.append('/Users/a241211/Documents/CCSI/Solvents/RCode/SolventFit/foqus_lib/framework/uq/');

from foqus_lib.framework.uq.Common import *
from foqus_lib.framework.uq.Distribution import *
bpaul4 marked this conversation as resolved.
Show resolved Hide resolved

# from Distribution import *
# from Common import *
bpaul4 marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
2 changes: 1 addition & 1 deletion foqus_lib/framework/uq/Model.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@

import numpy

from .Distribution import *
from .Distribution import Distribution


class Model:
Expand Down
4 changes: 1 addition & 3 deletions foqus_lib/framework/uq/flowsheetToUQModel.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@
# respectively. This file is also available online at the URL
# "https://github.com/CCSI-Toolset/FOQUS".
#################################################################################
from foqus_lib.framework.graph.graph import *
from foqus_lib.framework.uq.Distribution import *
bpaul4 marked this conversation as resolved.
Show resolved Hide resolved
from foqus_lib.framework.uq.Model import *
from foqus_lib.framework.uq.Model import Model


def flowsheetToUQModel(gr):
Expand Down
7 changes: 5 additions & 2 deletions foqus_lib/gui/common/InputPriorTable.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# "https://github.com/CCSI-Toolset/FOQUS".
#################################################################################
import os
import platform

import numpy as np
from PyQt5.QtCore import Qt, pyqtSignal
Expand All @@ -29,8 +30,10 @@
QTableWidgetItem,
)

from foqus_lib.framework.uq.LocalExecutionModule import *
from foqus_lib.framework.uq.SampleData import *
from foqus_lib.framework.uq.Common import Common
from foqus_lib.framework.uq.Distribution import Distribution
from foqus_lib.framework.uq.LocalExecutionModule import LocalExecutionModule
from foqus_lib.framework.uq.Model import Model


class InputPriorTable(QTableWidget):
Expand Down
4 changes: 2 additions & 2 deletions foqus_lib/gui/flowsheet/dataBrowserDialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@
"""
import os

from PyQt5 import uic
from PyQt5 import QtCore, uic
from PyQt5.QtWidgets import QDialog

from foqus_lib.gui.flowsheet.dataBrowserFrame import *
from foqus_lib.gui.flowsheet.dataBrowserFrame import dataBrowserFrame

mypath = os.path.dirname(__file__)
_dataBrowserDialogUI, _dataBrowserDialog = uic.loadUiType(
Expand Down
4 changes: 2 additions & 2 deletions foqus_lib/gui/flowsheet/dataBrowserFrame.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
)

from foqus_lib.gui.flowsheet.calculatedColumns import calculatedColumnsDialog
from foqus_lib.gui.flowsheet.columns import *
from foqus_lib.gui.flowsheet.dataModel import *
from foqus_lib.gui.flowsheet.columns import columnsDialog
from foqus_lib.gui.flowsheet.dataModel import dataModel

from . import dataFilterDialog

Expand Down
2 changes: 1 addition & 1 deletion foqus_lib/gui/flowsheet/dataFilterDialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
QMessageBox,
)

from foqus_lib.framework.sampleResults.results import *
from foqus_lib.framework.sampleResults.results import dataFilter
from foqus_lib.gui.flowsheet.calculatedColumns import calculatedColumnsDialog

mypath = os.path.dirname(__file__)
Expand Down
2 changes: 0 additions & 2 deletions foqus_lib/gui/flowsheet/drawFlowsheet.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@
QMessageBox,
)

from foqus_lib.framework.graph import *
bpaul4 marked this conversation as resolved.
Show resolved Hide resolved


class fsScene(QGraphicsScene):
"""
Expand Down
15 changes: 9 additions & 6 deletions foqus_lib/gui/flowsheet/nodePanel.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,28 +18,31 @@
John Eslick, Carnegie Mellon University, 2014
"""
import ast
import logging
import math
import os
import re
import platform
from shutil import copyfile
import re
import time
from shutil import copyfile

from PyQt5 import QtCore, uic
from PyQt5.QtGui import QColor
from PyQt5.QtWidgets import (
QAbstractItemView,
QFileDialog,
QInputDialog,
QLineEdit,
QMessageBox,
QFileDialog,
QTableWidgetItem,
)

import foqus_lib.gui.helpers.guiHelpers as gh
from foqus_lib.framework.graph.node import *
from foqus_lib.framework.graph.node import NodeEx
from foqus_lib.framework.graph.nodeModelTypes import nodeModelTypes
from foqus_lib.framework.uq.Distribution import Distribution
from foqus_lib.gui.dialogs.tagSelectDialog import *
from foqus_lib.gui.pysyntax_hl.pysyntax_hl import *
from foqus_lib.gui.dialogs.tagSelectDialog import tagSelectDialog
from foqus_lib.gui.pysyntax_hl.pysyntax_hl import PythonHighlighter

mypath = os.path.dirname(__file__)
_nodeDockUI, _nodeDock = uic.loadUiType(os.path.join(mypath, "nodePanel_UI.ui"))
Expand Down
4 changes: 2 additions & 2 deletions foqus_lib/gui/help/helpBrowser.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@
from PyQt5.QtWidgets import QDialog, QFileDialog, QMainWindow, QMessageBox, QTextBrowser

from foqus_lib.framework.sim.turbineConfiguration import TurbineConfiguration
from foqus_lib.gui.pysyntax_hl.pysyntax_hl import *
from foqus_lib.help.helpPath import *
from foqus_lib.gui.pysyntax_hl.pysyntax_hl import PythonHighlighter
from foqus_lib.help.helpPath import helpPath

mypath = os.path.dirname(__file__)
_helpBrowserDockUI, _helpBrowserDock = uic.loadUiType(
Expand Down
Loading
Loading