CCSI-Toolset / FOQUS

FOQUS: Framework for Optimization and Quantification of Uncertainty and Surrogates
https://foqus.readthedocs.io
Other
45 stars 53 forks source link

MAC FOQUS NSException #1090

Open boverhof opened 1 year ago

boverhof commented 1 year ago

Description

Backtrace

(py3.9) joshuas-mbp:foqus-boverhof boverhof$ foqus
2022-11-29 10:20:45,842 - DEBUG - foqus.foqus_lib.foqus - Working directory set to /Users/boverhof/Documents/workspace.ccsi2/foqus_working_dir_test
2022-11-29 10:20:45,846 - DEBUG - foqus.foqus_lib.foqus - Create Flowsheet Session
2022-11-29 10:20:45,850 - DEBUG - foqus.foqus_lib.framework.session.session - Initializing session, Log file: /Users/boverhof/Documents/workspace.ccsi2/foqus_working_dir_test/logs/foqus.log, Position: 3314308
2022-11-29 10:20:45,851 - INFO - foqus.foqus_lib.framework.plugins.pluginSearch - Loading Plugin: /Users/boverhof/Documents/workspace.ccsi2/py3.9/lib/python3.9/site-packages/foqus_lib/framework/surrogate/BSS-ANOVA.py
2022-11-29 10:20:45,852 - INFO - foqus.foqus_lib.framework.plugins.pluginSearch - Loading Plugin: /Users/boverhof/Documents/workspace.ccsi2/py3.9/lib/python3.9/site-packages/foqus_lib/framework/surrogate/ALAMO.py
2022-11-29 10:20:45,854 - INFO - foqus.foqus_lib.framework.plugins.pluginSearch - Loading Plugin: /Users/boverhof/Documents/workspace.ccsi2/py3.9/lib/python3.9/site-packages/foqus_lib/framework/surrogate/ACOSSO.py
2022-11-29 10:20:45,857 - INFO - foqus.foqus_lib.framework.plugins.pluginSearch - Loading Plugin: /Users/boverhof/Documents/workspace.ccsi2/py3.9/lib/python3.9/site-packages/foqus_lib/framework/optimizer/OptCMA.py
2022-11-29 10:20:45,885 - INFO - foqus.foqus_lib.framework.plugins.pluginSearch - Loading Plugin: /Users/boverhof/Documents/workspace.ccsi2/py3.9/lib/python3.9/site-packages/foqus_lib/framework/optimizer/SM_Optimizer.py
2022-11-29 10:20:45,887 - INFO - foqus.SM_Optimizer - Failed to import the required packages for SM Optimizer solver
2022-11-29 10:20:45,888 - INFO - foqus.foqus_lib.framework.plugins.pluginSearch - Loading Plugin: /Users/boverhof/Documents/workspace.ccsi2/py3.9/lib/python3.9/site-packages/foqus_lib/framework/optimizer/NLopt.py
2022-11-29 10:20:45,890 - INFO - foqus.NLopt - Failed to import the nlopt package
2022-11-29 10:20:45,891 - INFO - foqus.foqus_lib.framework.plugins.pluginSearch - Loading Plugin: /Users/boverhof/Documents/workspace.ccsi2/py3.9/lib/python3.9/site-packages/foqus_lib/framework/optimizer/SLSQP.py
2022-11-29 10:20:45,893 - INFO - foqus.foqus_lib.framework.plugins.pluginSearch - Loading Plugin: /Users/boverhof/Documents/workspace.ccsi2/py3.9/lib/python3.9/site-packages/foqus_lib/framework/optimizer/PSUADE.py
2022-11-29 10:20:45,894 - INFO - foqus.foqus_lib.framework.plugins.pluginSearch - Loading Plugin: /Users/boverhof/Documents/workspace.ccsi2/py3.9/lib/python3.9/site-packages/foqus_lib/framework/optimizer/Sample.py
2022-11-29 10:20:45,896 - INFO - foqus.foqus_lib.framework.plugins.pluginSearch - Loading Plugin: /Users/boverhof/Documents/workspace.ccsi2/py3.9/lib/python3.9/site-packages/foqus_lib/framework/optimizer/Snobfit.py
2022-11-29 10:20:45,897 - INFO - foqus.Snobfit - Failed to import SQSnobFit and SQCommon packages used to access the snobfit solver
2022-11-29 10:20:45,898 - INFO - foqus.foqus_lib.framework.plugins.pluginSearch - Loading Plugin: /Users/boverhof/Documents/workspace.ccsi2/py3.9/lib/python3.9/site-packages/foqus_lib/framework/optimizer/BFGS.py
2022-11-29 10:20:45,996 - INFO - foqus.foqus_lib.framework.plugins.pluginSearch - Removing plugin, due to missing dependency: SM_Optimizer
2022-11-29 10:20:45,996 - INFO - foqus.foqus_lib.framework.plugins.pluginSearch - Removing plugin, due to missing dependency: NLopt
2022-11-29 10:20:45,996 - INFO - foqus.foqus_lib.framework.plugins.pluginSearch - Removing plugin, due to missing dependency: Snobfit
2022-11-29 10:20:45,997 - INFO - foqus.foqus_lib.framework.plugins.pluginSearch - Loading Plugin: /Users/boverhof/Documents/workspace.ccsi2/py3.9/lib/python3.9/site-packages/foqus_lib/framework/pymodel/steam_cycle.py
2022-11-29 10:20:45,999 - INFO - foqus.foqus_lib.framework.plugins.pluginSearch - Loading Plugin: /Users/boverhof/Documents/workspace.ccsi2/py3.9/lib/python3.9/site-packages/foqus_lib/framework/pymodel/matlab_fs.py
2022-11-29 10:20:46,002 - INFO - foqus.foqus_lib.framework.plugins.pluginSearch - Loading Plugin: /Users/boverhof/Documents/workspace.ccsi2/py3.9/lib/python3.9/site-packages/foqus_lib/framework/pymodel/pymodel_test.py
2022-11-29 10:20:46,003 - INFO - foqus.foqus_lib.framework.plugins.pluginSearch - Loading Plugin: /Users/boverhof/Documents/workspace.ccsi2/py3.9/lib/python3.9/site-packages/foqus_lib/framework/pymodel/heat_integration.py
2022-11-29 10:20:46,004 - INFO - foqus.foqus_lib.framework.plugins.pluginSearch - Removing plugin, due to missing dependency: matlab_fs
2022-11-29 10:20:46,007 - DEBUG - foqus.foqus_lib.framework.sim.turbineConfiguration - turbine configuration application url="https://c1tsf1vb9a.execute-api.us-west-2.amazonaws.com/prod/application/"
2022-11-29 10:20:46,007 - DEBUG - foqus.foqus_lib.framework.sim.turbineConfiguration - turbine configuration url="https://c1tsf1vb9a.execute-api.us-west-2.amazonaws.com/prod"
2022-11-29 10:20:46,008 - DEBUG - foqus.foqus_lib.foqus - Load Flowsheet Session: None
2022-11-29 10:20:46,008 - DEBUG - foqus.foqus_lib.foqus - LoadValues Flowsheet: None
2022-11-29 10:20:46,008 - DEBUG - foqus.foqus_lib.foqus - Run Option: None
2022-11-29 10:20:46,008 - DEBUG - foqus.foqus_lib.foqus - Starting GUI
qt.qpa.fonts: Populating font family aliases took 151 ms. Replace uses of missing font family "Sans" with one that exists to avoid this cost. 
2022-11-29 10:20:56,382 - DEBUG - foqus.foqus_lib.framework.sim.turbineConfiguration - Stopped all running consumers
2022-11-29 10:20:56,448 - DEBUG - foqus.foqus_lib.framework.sim.process_management - Found Process: []
2022-11-29 10:20:56,450 - DEBUG - foqus.foqus_lib.framework.sim.turbineConfiguration - turbine configuration application url="https://c1tsf1vb9a.execute-api.us-west-2.amazonaws.com/prod/application/"
2022-11-29 10:20:56,450 - DEBUG - foqus.foqus_lib.framework.sim.turbineConfiguration - turbine configuration url="https://c1tsf1vb9a.execute-api.us-west-2.amazonaws.com/prod"
0
1
2
3
   variable 1 BFB.BFBRGN.GasIn.F
2022-11-29 10:25:36.680 Python[97131:3869606] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'NSWindow drag regions should only be invalidated on the Main Thread!'
*** First throw call stack:
(
    0   CoreFoundation                      0x00007ff815c5c773 __exceptionPreprocess + 242
    1   libobjc.A.dylib                     0x00007ff8159bcbc3 objc_exception_throw + 48
    2   CoreFoundation                      0x00007ff815c85056 -[NSException raise] + 9
    3   AppKit                              0x00007ff8186410a4 -[NSWindow(NSWindow_Theme) _postWindowNeedsToResetDragMarginsUnlessPostingDisabled] + 321
    4   AppKit                              0x00007ff81862d054 -[NSWindow _initContent:styleMask:backing:defer:contentView:] + 1288
    5   AppKit                              0x00007ff8187d5d81 -[NSPanel _initContent:styleMask:backing:defer:contentView:] + 50
    6   AppKit                              0x00007ff81862cb46 -[NSWindow initWithContentRect:styleMask:backing:defer:] + 42
    7   AppKit                              0x00007ff8187d5d3a -[NSPanel initWithContentRect:styleMask:backing:defer:] + 59
    8   AppKit                              0x00007ff81890daa7 -[NSWindow initWithContentRect:styleMask:backing:defer:screen:] + 50
    9   libqcocoa.dylib                     0x0000000141476745 -[QNSPanel initWithContentRect:styleMask:backing:defer:screen:platformWindow:] + 197
    10  libqcocoa.dylib                     0x0000000141462cac _ZN12QCocoaWindow14createNSWindowEb + 1324
    11  libqcocoa.dylib                     0x000000014145c672 _ZN12QCocoaWindow22recreateWindowIfNeededEv + 1266
    12  libqcocoa.dylib                     0x000000014145c0fe _ZN12QCocoaWindow10initializeEv + 318
    13  QtGui                               0x0000000150a2feb7 _ZN14QWindowPrivate6createEby + 151
    14  QtWidgets                           0x0000000142759771 _ZN14QWidgetPrivate6createEv + 1185
    15  QtWidgets                           0x0000000142758414 _ZN7QWidget6createEybb + 324
    16  QtWidgets                           0x000000014276b81d _ZN14QWidgetPrivate10setVisibleEb + 189
    17  QtWidgets                           0x000000014293257d _ZN7QDialog10setVisibleEb + 269
    18  QtWidgets.abi3.so                   0x000000014222eadf _ZN14sipQMessageBox10setVisibleEb + 111
    19  QtWidgets                           0x0000000142931d80 _ZN7QDialog4execEv + 240
    20  QtWidgets.abi3.so                   0x00000001423d0ab4 _ZL18meth_QDialog_exec_P7_objectS0_ + 164
    21  Python                              0x00000001056835ae cfunction_call + 90
    22  Python                              0x00000001056379a2 _PyObject_MakeTpCall + 127
    23  Python                              0x000000010572dfba call_function + 279
    24  Python                              0x0000000105727a0a _PyEval_EvalFrameDefault + 26232
    25  Python                              0x0000000105638398 _PyFunction_Vectorcall + 193
    26  Python                              0x000000010572df4b call_function + 168
    27  Python                              0x0000000105727a0a _PyEval_EvalFrameDefault + 26232
    28  Python                              0x0000000105638398 _PyFunction_Vectorcall + 193
    29  Python                              0x000000010572df4b call_function + 168
    30  Python                              0x0000000105727a0a _PyEval_EvalFrameDefault + 26232
    31  Python                              0x0000000105720218 _PyEval_EvalCode + 398
    32  Python                              0x0000000105638478 _PyFunction_Vectorcall + 417
    33  Python                              0x000000010572df4b call_function + 168
    34  Python                              0x0000000105725f31 _PyEval_EvalFrameDefault + 19359
    35  Python                              0x0000000105638398 _PyFunction_Vectorcall + 193
    36  Python                              0x000000010563b0c0 method_vectorcall + 481
    37  QtCore.abi3.so                      0x000000010b095118 _ZNK8PyQtSlot4callEP7_objectS1_ + 40
    38  QtCore.abi3.so                      0x000000010b09501d _ZNK8PyQtSlot6invokeEPPvP7_objectS0_b + 381
    39  QtCore.abi3.so                      0x000000010b095c45 _ZN13PyQtSlotProxy7unislotEPPv + 85
    40  QtCore.abi3.so                      0x000000010b095bba _ZN13PyQtSlotProxy11qt_metacallEN11QMetaObject4CallEiPPv + 58
    41  QtCore                              0x0000000141d18f6e _Z10doActivateILb0EEvP7QObjectiPPv + 1118
    42  QtCore                              0x0000000141b0ede8 _ZN7QThread7startedENS_14QPrivateSignalE + 56
    43  QtCore                              0x0000000141b0f5ff _ZN14QThreadPrivate5startEPv + 303
    44  libsystem_pthread.dylib             0x00007ff815b1a4e1 _pthread_start + 125
    45  libsystem_pthread.dylib             0x00007ff815b15f6b thread_start + 15
)
libc++abi: terminating with uncaught exception of type NSException
Abort trap: 6
Screen Shot 2022-11-29 at 10 30 22 AM
lbianchi-lbl commented 1 year ago

I have a vague recollection of running into a similar error a few years ago, although not in the context of FOQUS OUU. As I remember (disclaimer: all of this might be completely off-track):

I'd say that the first steps would be:

ksbeattie commented 1 year ago

Josh and I were able to reproduce this with stack trace:

   variable 1 BFB.BFBRGN.GasIn.F

2023-04-21 12:50:30.251 python[24187:1488008] WARNING: NSWindow drag regions should only be invalidated on the Main Thread! This will throw an exception in the future. Called from (
    0   AppKit                              0x00007ff80ac6c40e -[NSWindow(NSWindow_Theme) _postWindowNeedsToResetDragMarginsUnlessPostingDisabled] + 338
    1   AppKit                              0x00007ff80ac588e4 -[NSWindow _initContent:styleMask:backing:defer:contentView:] + 1227
    2   AppKit                              0x00007ff80adf13fd -[NSPanel _initContent:styleMask:backing:defer:contentView:] + 50
    3   AppKit                              0x00007ff80ac58412 -[NSWindow initWithContentRect:styleMask:backing:defer:] + 42
    4   AppKit                              0x00007ff80adf13b6 -[NSPanel initWithContentRect:styleMask:backing:defer:] + 59
    5   AppKit                              0x00007ff80af23493 -[NSWindow initWithContentRect:styleMask:backing:defer:screen:] + 50
    6   libqcocoa.dylib                     0x0000000128d85745 -[QNSPanel initWithContentRect:styleMask:backing:defer:screen:platformWindow:] + 197
    7   libqcocoa.dylib                     0x0000000128d71cac _ZN12QCocoaWindow14createNSWindowEb + 1324
    8   libqcocoa.dylib                     0x0000000128d6b672 _ZN12QCocoaWindow22recreateWindowIfNeededEv + 1266
    9   libqcocoa.dylib                     0x0000000128d6b0fe _ZN12QCocoaWindow10initializeEv + 318
    10  QtGui                               0x0000000128513eb7 _ZN14QWindowPrivate6createEby + 151
    11  QtWidgets                           0x0000000127ed3771 _ZN14QWidgetPrivate6createEv + 1185
    12  QtWidgets                           0x0000000127ed2414 _ZN7QWidget6createEybb + 324
    13  QtWidgets                           0x0000000127ee581d _ZN14QWidgetPrivate10setVisibleEb + 189
    14  QtWidgets                           0x00000001280ac57d _ZN7QDialog10setVisibleEb + 269
    15  QtWidgets.abi3.so                   0x00000001279a8adf _ZN14sipQMessageBox10setVisibleEb + 111
    16  QtWidgets                           0x00000001280abd80 _ZN7QDialog4execEv + 240
    17  QtWidgets.abi3.so                   0x0000000127b4aab4 _ZL18meth_QDialog_exec_P7_objectS0_ + 164
    18  python3.9                           0x0000000100f3d11a cfunction_call + 90
    19  python3.9                           0x0000000100ff992d _PyEval_EvalFrameDefault + 49901
    20  python3.9                           0x0000000100ee36d9 _PyFunction_Vectorcall + 5849
    21  python3.9                           0x0000000100ff6712 _PyEval_EvalFrameDefault + 37074
    22  python3.9                           0x0000000100ee36d9 _PyFunction_Vectorcall + 5849
    23  python3.9                           0x0000000100ff6712 _PyEval_EvalFrameDefault + 37074
    24  python3.9                           0x0000000100ee24ec _PyFunction_Vectorcall + 1260
    25  python3.9                           0x0000000100ff4c11 _PyEval_EvalFrameDefault + 30161
    26  python3.9                           0x0000000100ee21a4 _PyFunction_Vectorcall + 420
    27  python3.9                           0x0000000100ee783f method_vectorcall + 479
    28  QtCore.abi3.so                      0x0000000124cf8118 _ZNK8PyQtSlot4callEP7_objectS1_ + 40
    29  QtCore.abi3.so                      0x0000000124cf801d _ZNK8PyQtSlot6invokeEPPvP7_objectS0_b + 381
    30  QtCore.abi3.so                      0x0000000124cf8c45 _ZN13PyQtSlotProxy7unislotEPPv + 85
    31  QtCore.abi3.so                      0x0000000124cf8bba _ZN13PyQtSlotProxy11qt_metacallEN11QMetaObject4CallEiPPv + 58
    32  QtCore                              0x0000000125788f6e _Z10doActivateILb0EEvP7QObjectiPPv + 1118
    33  QtCore                              0x000000012557ede8 _ZN7QThread7startedENS_14QPrivateSignalE + 56
    34  QtCore                              0x000000012557f5ff _ZN14QThreadPrivate5startEPv + 303
    35  libsystem_pthread.dylib             0x00007ff807ad91d3 _pthread_start + 125
    36  libsystem_pthread.dylib             0x00007ff807ad4bd3 thread_start + 15
)
QPainter::begin: A paint device can only be painted by one painter at a time.
QPainter::setCompositionMode: Painter not active
QBackingStore::endPaint() called with active painter; did you forget to destroy it or call QPainter::end() on it?

This was using the following (dramatically shortened) as the z3Samples.smp file:

2 1 0
-2.11503
0.696938

Maybe this is a simple as adding a QPainter::end() call (or equivalent in python) somewhere?

ksbeattie commented 1 year ago

Here's how to reproduce:

Boom!

sotorrio1 commented 1 year ago

First line in the .smp file is (sample size, number of inputs, number of outputs). I got this information from the PSUADE manual, page 3, read_std command.

ksbeattie commented 1 year ago

We should try to reproduce this and capture the python stacktrace, not just the C++ stack.

lbianchi-lbl commented 1 year ago
ksbeattie commented 1 year ago

@sotorrio1 needs a config file from @boverhof to reproduce this.

sotorrio1 commented 1 year ago

Here's how to reproduce:

  • Start foqus
  • Open Session: ./examples/test_files/OUU_Remote_Turbine_BFB/BFB_OUU_06_09_2020.foqus
  • In Settings, change "FOQUS Flowsheet Run Method" to Remote

    • In Turbine tab, in lower "Turbine Gateway (Remote)" section, click Browse and open turbine_oregon.cfg (this is a file that you'll need to get from Josh B. since it uses his AWS instance)
    • Click Test there to make sure it works
  • Back in Flowsheet, click on the one and only "BFB" node. It should turn green.
  • Now in OUU:

    • Choose Flowsheet Node: Full flowsheet

    • Set the first 3 vars to Z1:

    • BFBadsB.Cr

    • BFBadsB.Dt

    • BFBadsB.dx

    • Scroll down and set one var to Z3:

    • BFB.fg_flow

    • Click on lower "UQ Setup" tab and load a file with the contents of z3Samples.smp from the previous comment above.

    • Click on "Launch/Progress" tab and hit "Run OUU"

Boom!

@ksbeattie from your instructions how to reproduce, you don't specify what objective function you're using. Default is 'BFB.BFBRGN.GasIn.F' but I believe in this problem it should be 'BFB.Cost_coe_obj'.

sotorrio1 commented 1 year ago

I was able to run this example without getting the NSException... I ran two different tests, one using 'BFB.Cost_coe_obj' as the bbjective and the other one using 'BFB.BFBRGN.GasIn.F' as the objective.

lbianchi-lbl commented 1 year ago

@sotorrio1 will try to reproduce @ksbeattie's steps without selecting an objective function. Although, one objective should be selected by default, so it's not clear if this is a promising thing to look into.

sotorrio1 commented 1 year ago

OUU will error out if trying to run without selecting an objective. By default first one is selected, but I manually changed it to not use an objective and hit run and it gave an error.

ksbeattie commented 11 months ago

I should take another try and reproducing this.

ksbeattie commented 9 months ago

Unfortunately, I'm still getting this error, regardless of the objective function used.