Skip to content

Commit

Permalink
saving executed notebooks properly
Browse files Browse the repository at this point in the history
  • Loading branch information
dfm committed Sep 20, 2019
1 parent 1f0c358 commit 4ef3962
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
1 change: 1 addition & 0 deletions docs/notebooks/astrometric.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@
"outputs": [],
"source": [
"import pymc3 as pm \n",
"import theano\n",
"import theano.tensor as tt\n",
"\n",
"import exoplanet as xo\n",
Expand Down
12 changes: 8 additions & 4 deletions docs/run_notebooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@


def process_notebook(filename):
path = os.path.join(
os.path.abspath("theano_cache"), "p{0}".format(os.getpid())
)
os.makedirs(path, exist_ok=True)
os.environ["THEANO_FLAGS"] = "base_compiledir={0}".format(path)

errors = []

with open(filename) as f:
Expand All @@ -35,16 +41,14 @@ def process_notebook(filename):

print("running: {0}".format(filename))
try:
ep.preprocess(notebook, {"metadata": {"path": "."}})
ep.preprocess(notebook, {"metadata": {"path": "notebooks/"}})
except CellExecutionError as e:
msg = "error while running: {0}\n\n".format(filename)
msg += e.traceback
print(msg)
errors.append(msg)
finally:
with open(
os.path.splitext(filename)[0] + "_exec.ipynb", mode="wt"
) as f:
with open(os.path.join("_static", filename), mode="wt") as f:
nbformat.write(notebook, f)

return "\n\n".join(errors)
Expand Down
2 changes: 1 addition & 1 deletion exoplanet/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ def optimize(
for v in vars
]
sys.stderr.write(
"optimizing logp for variables: [{0}]\n".format(",".join(names))
"optimizing logp for variables: [{0}]\n".format(", ".join(names))
)
bar = tqdm.tqdm()

Expand Down

0 comments on commit 4ef3962

Please sign in to comment.