Results
Fetch results, wait for a run to finish, list a submission's results, and continue from a finished run.
The client.results resource maps to the Results endpoint.
Fetch a single result¶
result = client.results.get("res_abc123")
print(result.best_fitness, result.best_solution)
REST equivalent: GET /api/v1/results/<id>.
What is on a Result¶
| Attribute | Type | What it is |
|---|---|---|
id |
str |
Result identifier. |
submission_id |
str |
The submission this result belongs to. |
name |
str \| None |
The result's label. |
is_shared |
bool \| None |
Whether the result is shared publicly. |
best_fitness |
float \| None |
Fitness of the highest-scoring candidate. |
best_solution |
list \| None |
The gene values of that candidate. |
num_generations_ran |
int \| None |
Actual generations executed. |
stopped_reason |
str \| None |
Why the run stopped (target reached, max generations, etc.). |
created_at |
datetime \| None |
When the result was saved. |
raw |
dict |
The full server response, preserved for forward compatibility. |
Wait for a submission to finish¶
result = client.results.wait_for(
"abcDEF123456",
timeout=600, # seconds
poll_interval=3, # seconds between checks
)
print(result.best_fitness)
wait_for polls the submission until it reaches a terminal state, then returns its first result.
- Returns the
Resultwhen the run finishes successfully. - Raises
vilvik.TimeoutErrorwhentimeoutexpires before the run finishes. - Raises
vilvik.APIErrorwhen the run ends infailedorcancelled.
REST equivalent: under the hood it polls GET /api/v1/submissions/<id>. If you prefer a push model, register a webhook instead. See Webhooks.
List results¶
Optionally filter by submission:
page = client.results.list(submission_id="abcDEF123456", limit=10)
for r in page:
print(r.id, r.best_fitness)
REST equivalent: GET /api/v1/results/?submission_id=โฆ&limit=โฆ&cursor=โฆ.
Rename or share a result¶
Pass only the fields you want to change. is_shared toggles whether the result is shared publicly.
updated = client.results.update("res_abc123", name="final run", is_shared=True)
print(updated.name, updated.is_shared)
REST equivalent: PATCH /api/v1/results/<id>.
Delete a result¶
client.results.delete("res_abc123")
Removes the result. The submission it came from is untouched. REST equivalent: DELETE /api/v1/results/<id>.
Continue a finished run¶
Branch a new submission from where a finished one left off. Optional keyword arguments override any GA parameter for the child run.
child = client.results.continue_run(
"res_abc123",
num_generations=100,
mutation_probability=0.05,
)
print(child.id, child.status_url)
REST equivalent: POST /api/v1/results/<id>/continue. See Continue a submission for the broader story behind continue.