Skip to content

read_result

Python reference for nagasim.twin.read_result.

The latest result a twin wrote into directory.

The one reader, for a second process: bounded before it is parsed, whole because the writer replaces the file, and trusted for nothing beyond its format.

Parameters:

Name Type Description Default
directory str or Path

The folder a twin writes into (naga twin run ... --out DIR).

required

Returns:

Type Description
tuple

(result, []) with the result document, or (None, problems) when the folder holds no result of format 1 (none yet, over the size bound, or another file).

See Also

nagasim.twin.forecast_from_state : The runner that makes the forecast in a result.

Examples:

>>> import tempfile
>>> from nagasim import twin
>>> with tempfile.TemporaryDirectory() as folder:
...     doc, problems = twin.read_result(folder)
>>> doc is None
True
>>> problems[0].code
'E_TWIN_RESULT'