Skip to content

Commit

Permalink
store metric_names in db
Browse files Browse the repository at this point in the history
  • Loading branch information
lyuyangh committed Nov 5, 2022
1 parent 09125e7 commit 68b61b4
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
5 changes: 4 additions & 1 deletion backend/src/impl/db_utils/system_db_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,10 @@ def _validate_and_create_system():
def db_operations(session: ClientSession) -> None:
system.save_to_db(session)
system.save_system_output(system_output_data, session)
system.update_overall_statistics(metadata, system_output_data, session)
try:
system.update_overall_statistics(system_output_data, session)
except ValueError as e:
abort_with_error_message(400, str(e))

DBUtils.execute_transaction(db_operations)
return system
Expand Down
8 changes: 2 additions & 6 deletions backend/src/impl/internal_models/system_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
)
from explainaboard_web.models.system import System
from explainaboard_web.models.system_info import SystemInfo
from explainaboard_web.models.system_metadata import SystemMetadata
from pymongo.client_session import ClientSession


Expand Down Expand Up @@ -149,7 +148,6 @@ def save_system_output(

def update_overall_statistics(
self,
metadata: SystemMetadata,
system_output_data: FileLoaderReturn,
session: ClientSession | None = None,
force_update=False,
Expand All @@ -168,11 +166,9 @@ def _process():
for metric in get_processor(self.task).full_metric_list()
}
metric_configs: list[MetricConfig] = []
for metric_name in metadata.metric_names:
for metric_name in self.metric_names:
if metric_name not in metrics_lookup:
abort_with_error_message(
400, f"{metric_name} is not a supported metric"
)
raise ValueError(f"{metric_name} is not a supported metric")
metric_configs.append(metrics_lookup[metric_name])
custom_features = system_output_data.metadata.custom_features or {}
custom_features.update(self.get_dataset_custom_features())
Expand Down
11 changes: 10 additions & 1 deletion openapi/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ openapi: "3.0.0"
info:
title: "ExplainaBoard"
description: "Backend APIs for ExplainaBoard"
version: "0.2.11"
version: "0.2.12"
contact:
email: "explainaboard@gmail.com"
license:
Expand Down Expand Up @@ -972,6 +972,14 @@ components:
description: the user who created the system
preferred_username:
type: string
metric_names:
description: >
metric_names selected when the system is created. It is the same as
the metric_names field in SystemMetadata.
type: array
items:
type: string
example: [Accuracy, F1]
results:
type: object
example: {"span": {"F1": 0.9221}}
Expand Down Expand Up @@ -1013,6 +1021,7 @@ components:
- source_language
- target_language
- task
- metric_names
- results
- $ref: "#/components/schemas/Time"

Expand Down

0 comments on commit 68b61b4

Please sign in to comment.