Skip to content
This repository has been archived by the owner on Nov 3, 2023. It is now read-only.

Record task start and end times for Acute-Evals #4208

Merged
merged 21 commits into from
Jan 6, 2022
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion parlai/crowdsourcing/tasks/acute_eval/acute_eval_agent_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.

from typing import List, Dict, Any, TYPE_CHECKING
from typing import List, Dict, Any, Optional, TYPE_CHECKING
from mephisto.abstractions.blueprints.abstract.static_task.static_agent_state import (
StaticAgentState,
)
Expand Down Expand Up @@ -49,3 +49,15 @@ def update_data(self, packet: "Packet") -> None:
self.state["times"]["task_end"] = time.time()
self.state["outputs"] = packet.data["task_data"]
self.save_data()

def get_task_start(self) -> Optional[float]:
"""
Extract out the start time recorded for this task.
"""
return self.state['times']['task_start']

def get_task_end(self) -> Optional[float]:
"""
Extract out the end recorded for this task.
"""
return self.state['times']['task_end']
15 changes: 13 additions & 2 deletions parlai/crowdsourcing/tasks/acute_eval/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import hashlib
import os
from typing import Iterable, List, Tuple, Union
from typing import Iterable, List, Optional, Tuple, Union

import pandas as pd
from pytest_regressions.data_regression import DataRegressionFixture
Expand Down Expand Up @@ -114,6 +114,7 @@ def test_full_csv(
results_folder=outputs['results_folder'],
file_suffix='full.csv',
dataframe_regression=dataframe_regression,
drop_columns=['task_start', 'time_taken'],
)

def test_grid_csv(
Expand Down Expand Up @@ -169,11 +170,21 @@ def _check_dataframe(
results_folder: str,
file_suffix: str,
dataframe_regression: DataFrameRegressionFixture,
drop_columns: Optional[list] = None,
):
"""
Check a dataframe for correctness.

Check the dataframe stored at the file with suffix file_suffix in the folder
results_folder. Pass in drop_column to indicate columns that shouldn't be
checked because they will vary across runs (for instance, timestamp columns).
"""
if drop_columns is None:
drop_columns = []
file_path = self._get_matching_file_path(
results_folder=results_folder, file_suffix=file_suffix
)
df = pd.read_csv(file_path)
df = pd.read_csv(file_path).drop(columns=drop_columns)
dataframe_regression.check(data_frame=df)

def _check_file_contents(
Expand Down
Loading