Manage Open Suggestions

If you run into an error, there may be some outstanding suggestions with no reported observations (called open suggestions in the API). Here are some strategies you can use to recover in this situation.

Iterate through all open suggestions and reevaluate

suggestions = conn.experiments(EXPERIMENT_ID).suggestions().fetch(state="open")
for suggestion in suggestions.iterate_pages():
  value = evaluate_metric(suggestion.assignments)  # implement this
  conn.experiments(EXPERIMENT_ID).observations().create(
    suggestion=suggestion.id,
    values=values,
  )

If you know the suggestion ID and wish to report it as a failure

conn.experiments(EXPERIMENT_ID).observations().create(
  suggestion=SUGGESTION_ID,
  failed=True,
)

If you know the suggestion ID and wish to retry evaluating and reporting

suggestion = conn.experiments(EXPERIMENT_ID).suggestions(SUGGESTION_ID).fetch()
values = evaluate_metric(suggestion.assignments)  # Implement this
conn.experiments(EXPERIMENT_ID).observations().create(
  suggestion=SUGGESTION_ID,
  values=values,
)

If you know the suggestion ID and want to delete the suggestion

conn.experiments(EXPERIMENT_ID).suggestions(SUGGESTION_ID).delete()

If you just want to delete all open suggestions

conn.experiments(EXPERIMENT_ID).suggestions().delete(state="open")

Last updated