Skip to content

Commit

Permalink
fix: Delete all uncachable chains after retrieval
Browse files Browse the repository at this point in the history
Delete all uncachable chains after we retrieve them. Previously the data
associated with a single chain was deleted.  If, say, draws from four
chains were collected only the data associated with one of the four
chains would be deleted.
  • Loading branch information
riddell-stan committed Feb 19, 2021
1 parent d6833fd commit 735a484
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions stan/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,13 @@ async def go():
if resp.status != 200:
raise RuntimeError((await resp.json())["message"])
stan_outputs.append(await resp.read())

# clean up after ourselves when fit is uncacheable (no random seed)
if self.random_seed is None:
async with aiohttp.request("DELETE", f"http://{host}:{port}/v1/{fit_name}") as resp:
if resp.status not in {200, 202, 204}:
raise RuntimeError((await resp.json())["message"])

stan_outputs = tuple(stan_outputs) # Fit constructor expects a tuple.

def is_nonempty_logger_message(msg: simdjson.Object):
Expand Down Expand Up @@ -216,12 +223,6 @@ def is_iteration_or_elapsed_time_logger_message(msg: simdjson.Object):
progress_bar.finish()
io.error_line("\n<info>Done.</info>")

# clean up after ourselves when fit is uncacheable (no random seed)
if self.random_seed is None:
async with aiohttp.request("DELETE", f"http://{host}:{port}/v1/{fit_name}") as resp:
if resp.status not in {200, 202, 204}:
raise RuntimeError((await resp.json())["message"])

return stan.fit.Fit(
stan_outputs,
num_chains,
Expand Down

0 comments on commit 735a484

Please sign in to comment.