# read_result

Python reference for `nagasim.twin.read_result`.

`nagasim.twin.read_result`

```python
read_result(directory)
```

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
----------
directory : str or Path
    The folder a twin writes into (``naga twin run ... --out DIR``).

Returns
-------
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'
