Skip to content

Commit

Permalink
Identify benchmark type (#3495)
Browse files Browse the repository at this point in the history
PBENCH-1210

Right now we only support visualizing and comparing `uperf` benchmark data
with Quisby. However as we expand that support within the server, the UI code
will need to be able to identify the schema of the output data, which depends
on the benchmark.

As a simple solution, add a `"benchmark"` field to the response data which the
client can read.
  • Loading branch information
dbutenhof authored Jul 12, 2023
1 parent 4435b3d commit e82943e
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 8 deletions.
9 changes: 5 additions & 4 deletions lib/pbench/server/api/resources/datasets_compare.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,12 @@ def _get(
) from e
stream_file[dataset.name] = file

get_quisby_data = QuisbyProcessing().compare_csv_to_json(
quisby_response = QuisbyProcessing().compare_csv_to_json(
benchmark_type, InputType.STREAM, stream_file
)
if get_quisby_data["status"] != "success":
if quisby_response["status"] != "success":
raise APIInternalError(
f"Quisby processing failure. Exception: {get_quisby_data['exception']}"
f"Quisby processing failure. Exception: {quisby_response['exception']}"
)
return jsonify(get_quisby_data)
quisby_response["benchmark"] = benchmark.lower()
return jsonify(quisby_response)
9 changes: 5 additions & 4 deletions lib/pbench/server/api/resources/datasets_visualize.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,13 @@ def _get(
except Exception as e:
raise APIInternalError(str(e)) from e

get_quisby_data = QuisbyProcessing().extract_data(
quisby_response = QuisbyProcessing().extract_data(
benchmark_type, dataset.name, InputType.STREAM, file
)

if get_quisby_data["status"] != "success":
if quisby_response["status"] != "success":
raise APIInternalError(
f"Quisby processing failure. Exception: {get_quisby_data['exception']}"
f"Quisby processing failure. Exception: {quisby_response['exception']}"
)
return jsonify(get_quisby_data)
quisby_response["benchmark"] = benchmark.lower()
return jsonify(quisby_response)
2 changes: 2 additions & 0 deletions lib/pbench/test/functional/server/test_datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -610,6 +610,7 @@ def test_visualize(self, server_client: PbenchServerClient, login_user):
), f"VISUALIZE {dataset.name} failed {response.status_code}:{response.json()['message']}"
json = response.json()
assert json["status"] == "success"
assert json["benchmark"] == "uperf"
assert "csv_data" in json
assert json["json_data"]["dataset_name"] == dataset.name
assert isinstance(json["json_data"]["data"], list)
Expand Down Expand Up @@ -643,6 +644,7 @@ def test_compare(self, server_client: PbenchServerClient, login_user):
response.ok
), f"COMPARE {candidates[:2]} failed {response.status_code}:{json['message']}"
assert json["status"] == "success"
assert json["benchmark"] == "uperf"
assert isinstance(json["json_data"]["data"], list)

@pytest.mark.dependency(name="inventory", depends=["upload"], scope="session")
Expand Down
1 change: 1 addition & 0 deletions lib/pbench/test/unit/server/test_datasets_compare.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ def mock_get_inventory(_self, _dataset: str, _path: str) -> dict[str, Any]:
response = query_get_as(datasets, user, exp_status)
if exp_status == HTTPStatus.OK:
assert response.json["status"] == "success"
assert response.json["benchmark"] == "uperf"
assert response.json["json_data"] == "quisby_data"
else:
assert response.json["message"] == exp_message
1 change: 1 addition & 0 deletions lib/pbench/test/unit/server/test_datasets_visualize.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ def mock_extract_data(self, test_name, dataset_name, input_type, data) -> JSON:

response = query_get_as("uperf_1", "test", HTTPStatus.OK)
assert response.json["status"] == "success"
assert response.json["benchmark"] == "uperf"
assert response.json["json_data"] == "quisby_data"

def test_unsuccessful_get_with_incorrect_data(self, query_get_as, monkeypatch):
Expand Down

0 comments on commit e82943e

Please sign in to comment.