Skip to content

Commit

Permalink
Persist run info
Browse files Browse the repository at this point in the history
  • Loading branch information
dianaclarke committed Mar 5, 2021
1 parent 199a3b0 commit 92a22a1
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 5 deletions.
22 changes: 18 additions & 4 deletions conbench/api/_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ def _api_benchmark_entity(
"self": "http://localhost/api/benchmarks/%s/" % summary_id,
"context": "http://localhost/api/contexts/%s/" % context_id,
"machine": "http://localhost/api/machines/%s/" % machine_id,
"run": "http://localhost/api/runs/%s/" % run_id,
},
}

Expand Down Expand Up @@ -200,9 +201,10 @@ def _api_machine_entity(machine_id):
}


def _api_run_entity(run_id, machine_id):
def _api_run_entity(run_id, machine_id, now):
return {
"id": run_id,
"timestamp": now,
"links": {
"self": "http://localhost/api/runs/%s/" % run_id,
"machine": "http://localhost/api/machines/%s/" % machine_id,
Expand Down Expand Up @@ -259,10 +261,22 @@ def _api_run_entity(run_id, machine_id):
)
CONTEXT_ENTITY = _api_context_entity("some-context-uuid-1")
MACHINE_ENTITY = _api_machine_entity("some-machine-uuid-1")
RUN_ENTITY = _api_run_entity("some-run-uuid-1", "some-machine-uuid-1")
RUN_ENTITY = _api_run_entity(
"some-run-uuid-1",
"some-machine-uuid-1",
"2021-02-04T17:22:05.225583",
)
RUN_LIST = [
_api_run_entity("some-run-uuid-1", "some-machine-uuid-1"),
_api_run_entity("some-run-uuid-2", "some-machine-uuid-1"),
_api_run_entity(
"some-run-uuid-1",
"some-machine-uuid-1",
"2021-02-04T17:22:05.225583",
),
_api_run_entity(
"some-run-uuid-2",
"some-machine-uuid-1",
"2021-03-04T17:18:05.715583",
),
]
USER_ENTITY = _api_user_entity(FakeUser1())
USER_LIST = [
Expand Down
1 change: 1 addition & 0 deletions conbench/entities/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class _Serializer(EntitySerializer):
def _dump(self, run):
result = {
"id": run.id,
"timestamp": run.timestamp.isoformat(),
"links": {
"self": f.url_for("api.run", run_id=run.id, _external=True),
"machine": f.url_for(
Expand Down
1 change: 1 addition & 0 deletions conbench/entities/summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ def _dump(self, summary):
"machine": f.url_for(
"api.machine", machine_id=summary.machine_id, _external=True
),
"run": f.url_for("api.run", run_id=summary.run_id, _external=True),
},
}

Expand Down
7 changes: 7 additions & 0 deletions conbench/tests/api/_expected_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
"context": "http://localhost/api/contexts/some-context-uuid-1/",
"list": "http://localhost/api/benchmarks/",
"machine": "http://localhost/api/machines/some-machine-uuid-1/",
"run": "http://localhost/api/runs/some-run-uuid-1/",
"self": "http://localhost/api/benchmarks/some-benchmark-uuid-1/",
},
"stats": {
Expand Down Expand Up @@ -120,6 +121,7 @@
"context": "http://localhost/api/contexts/some-context-uuid-1/",
"list": "http://localhost/api/benchmarks/",
"machine": "http://localhost/api/machines/some-machine-uuid-1/",
"run": "http://localhost/api/runs/some-run-uuid-1/",
"self": "http://localhost/api/benchmarks/some-benchmark-uuid-1/",
},
"stats": {
Expand Down Expand Up @@ -190,6 +192,7 @@
"context": "http://localhost/api/contexts/some-context-uuid-1/",
"list": "http://localhost/api/benchmarks/",
"machine": "http://localhost/api/machines/some-machine-uuid-1/",
"run": "http://localhost/api/runs/some-run-uuid-1/",
"self": "http://localhost/api/benchmarks/some-benchmark-uuid-1/",
},
"stats": {
Expand Down Expand Up @@ -252,6 +255,7 @@
"context": "http://localhost/api/contexts/some-context-uuid-1/",
"list": "http://localhost/api/benchmarks/",
"machine": "http://localhost/api/machines/some-machine-uuid-1/",
"run": "http://localhost/api/runs/some-run-uuid-1/",
"self": "http://localhost/api/benchmarks/some-benchmark-uuid-2/",
},
"stats": {
Expand Down Expand Up @@ -464,6 +468,7 @@
"machine": "http://localhost/api/machines/some-machine-uuid-1/",
"self": "http://localhost/api/runs/some-run-uuid-1/",
},
"timestamp": "2021-02-04T17:22:05.225583",
}
}
},
Expand All @@ -479,13 +484,15 @@
"machine": "http://localhost/api/machines/some-machine-uuid-1/",
"self": "http://localhost/api/runs/some-run-uuid-1/",
},
"timestamp": "2021-02-04T17:22:05.225583",
},
{
"id": "some-run-uuid-2",
"links": {
"machine": "http://localhost/api/machines/some-machine-uuid-1/",
"self": "http://localhost/api/runs/some-run-uuid-2/",
},
"timestamp": "2021-03-04T17:18:05.715583",
},
]
}
Expand Down
6 changes: 5 additions & 1 deletion conbench/tests/api/test_runs.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@


def _expected_entity(run):
return _api_run_entity(run.id, run.machine_id)
return _api_run_entity(
run.id,
run.machine_id,
run.timestamp.isoformat(),
)


def create_benchmark_summary():
Expand Down

0 comments on commit 92a22a1

Please sign in to comment.