dpinney / omf

The Open Modeling Framework for smart grid cost-benefit analysis.
https://omf.coop
GNU General Public License v2.0
112 stars 60 forks source link

Show output in Multigridlab when feeder fails to execute. #225

Closed dpinney closed 10 years ago

dpinney commented 10 years ago

That way user can debug problems with model.

cshjin commented 10 years ago

What kinds of error could cause executing failures? Some have the stderr like:

ERROR [INIT] : init_triplex_line(obj=16;t2): Newton-Raphson method does not support zero length lines at this time ERROR [INIT] : init_by_deferral(): object t2 initialization failed ERROR [INIT] : model initialization failed FATAL [INIT] : shutdown after simulation stopped prematurely FATAL [INIT] : environment startup failed: Invalid argument

Some have the stderr like:

Processing 2012-04-01 00:00:00 EST... Processing 2012-04-01 00:00:30 EST... Processing 2012-04-01 00:01:00 EST... Processing 2012-04-01 00:01:00 EST...

And also other failure caused by feeder processing, for example Battery 13 Node Distributed:

Traceback (most recent call last): File "C:\Users\jxh10\Documents\GitHub\omf\omf\solvers\gridlabdinit.py", line 66, in runInFilesystem glmString = feeder.sortedWrite(localTree) File "C:\Users\jxh10\Documents\GitHub\omf\omf\feeder.py", line 33, in sortedWrite output += _dictToString(inTree[key]) + '\n' File "C:\Users\jxh10\Documents\GitHub\omf\omf\feeder.py", line 343, in _dictToString return 'object ' + inDict['object'] + ' {\n' + _gatherKeyValues(inDict, 'object') + '};\n' File "C:\Users\jxh10\Documents\GitHub\omf\omf\feeder.py", line 325, in _gatherKeyValues otherKeyValues += ('\t' + key + ' ' + inDict[key] + ';\n') TypeError: coercing to Unicode: need string or buffer, dict found

The first two errors are logged into stderr, and the last one is in std output window. Also, where and how to show those errors? Display in Model Runtime Statistics section or other windows?

dpinney commented 10 years ago

Let's put the errors in Model Runtime Statistics. If stdout.txt isn't written, we should show stderr.txt (I think). If we get an exception let's write it to stderr.txt, which should trip the same stdout/stdout code path as when GLD fails.

cshjin commented 10 years ago

After commit e258968b260689de61d972c75e93d7c44c8961d4 will look like the following, showing partial output, and also highlighting failure feeders, such that user can edit on that feeders. image

cshjin commented 10 years ago

759f4b60265e46956a2fe5579a5f45d1e792d34c catches all errors, and write to stderr.txt. In order to get the failure messages, the structure of allOutputData will be like this:

{
    "failures": {
        "feeder_Battery 13 Node Centralized": {
            "stderr": ...
        }
    }, 
    "climate": {
        "Rain Fall (in/h)": [...], 
        "Wind Speed (m/s)": null, 
        "Direct Insolation (W/m^2)": [...], 
        "Temperature (F)": [...], 
        "Snow Depth (in)": [...], 
    }, 
    "numOfFeeders": 1, 
    "feeder_Simple Market System": {
        "stderr": "", 
        "allMeterVoltages": {
            "Max": [...], 
            "Min": [...], 
            "StdDev": [...], 
            "Mean": [...], 
        }, 
        "Consumption": {
            "DG": [...], 
            "Losses": [...], 
            "Power": [...], 
        }, 
        "stdout": ...
    }, 
    "timeStamps": [...], 
}

Failed feeders error will be in allOutputData["failures"][feederName]["stderr"].

image

NOTE: the output will truncate lines.

dpinney commented 10 years ago

Add this CSS to the pre blocks to get them to word wrap: http://stackoverflow.com/questions/248011/how-do-i-wrap-text-in-a-pre-tag

cshjin commented 10 years ago

Thanks. It works.

cshjin commented 10 years ago

0d02b3703f2add72396b51c61c2703cb4e117bf7 fixed the word wrap. Add css pre.stdoutBlock {word-wrap: break-word;}