Refactor benchmark data models with placeholder values

This commit is contained in:
hunteraraujo
2023-09-27 15:16:34 -07:00
parent e4d84dad0a
commit ec03170e6e
5 changed files with 32 additions and 24 deletions

View File

@@ -28,8 +28,9 @@ class Config {
/// ///
/// Returns a new `Config` populated with values from the map. /// Returns a new `Config` populated with values from the map.
factory Config.fromJson(Map<String, dynamic> json) => Config( factory Config.fromJson(Map<String, dynamic> json) => Config(
agentBenchmarkConfigPath: json['agent_benchmark_config_path'] ?? "", agentBenchmarkConfigPath:
host: json['host'] ?? "", json['agent_benchmark_config_path'] ?? 'placeholder',
host: json['host'] ?? 'https://github.com/Significant-Gravitas/AutoGPT',
); );
/// Converts the `Config` instance to a map. /// Converts the `Config` instance to a map.

View File

@@ -46,14 +46,14 @@ class Metrics {
/// ///
/// Returns a new `Metrics` populated with values from the map. /// Returns a new `Metrics` populated with values from the map.
factory Metrics.fromJson(Map<String, dynamic> json) => Metrics( factory Metrics.fromJson(Map<String, dynamic> json) => Metrics(
difficulty: json['difficulty'] ?? "", difficulty: json['difficulty'] ?? 'placeholder',
success: json['success'], success: json['success'],
attempted: json['attempted'], attempted: json['attempted'] ?? false,
successPercentage: (json['success_percentage'] != null) successPercentage: (json['success_percentage'] != null)
? json['success_percentage'].toDouble() ? json['success_percentage'].toDouble()
: 0.0, : 0.0,
cost: json['cost'] ?? "", cost: json['cost'] ?? 'placeholder',
runTime: json['run_time'] ?? "", runTime: json['run_time'] ?? 'placeholder',
); );
/// Converts the `Metrics` instance to a map. /// Converts the `Metrics` instance to a map.

View File

@@ -4,16 +4,16 @@
/// This class contains essential information like the repository URL, team name, and the Git commit SHA for both the benchmark and the agent. /// This class contains essential information like the repository URL, team name, and the Git commit SHA for both the benchmark and the agent.
class RepositoryInfo { class RepositoryInfo {
/// The URL of the repository where the benchmark code resides. /// The URL of the repository where the benchmark code resides.
final String repoUrl; String repoUrl;
/// The name of the team responsible for the benchmark. /// The name of the team responsible for the benchmark.
final String teamName; String teamName;
/// The Git commit SHA for the benchmark. This helps in tracing the exact version of the benchmark code. /// The Git commit SHA for the benchmark. This helps in tracing the exact version of the benchmark code.
final String benchmarkGitCommitSha; String benchmarkGitCommitSha;
/// The Git commit SHA for the agent. This helps in tracing the exact version of the agent code. /// The Git commit SHA for the agent. This helps in tracing the exact version of the agent code.
final String agentGitCommitSha; String agentGitCommitSha;
/// Constructs a new `RepositoryInfo` instance. /// Constructs a new `RepositoryInfo` instance.
/// ///
@@ -34,10 +34,12 @@ class RepositoryInfo {
/// ///
/// Returns a new `RepositoryInfo` populated with values from the map. /// Returns a new `RepositoryInfo` populated with values from the map.
factory RepositoryInfo.fromJson(Map<String, dynamic> json) => RepositoryInfo( factory RepositoryInfo.fromJson(Map<String, dynamic> json) => RepositoryInfo(
repoUrl: json['repo_url'] ?? "", repoUrl: json['repo_url'] ??
teamName: json['team_name'] ?? "", 'https://github.com/Significant-Gravitas/AutoGPT',
benchmarkGitCommitSha: json['benchmark_git_commit_sha'] ?? "", teamName: json['team_name'] ?? 'placeholder',
agentGitCommitSha: json['agent_git_commit_sha'] ?? "", benchmarkGitCommitSha:
json['benchmark_git_commit_sha'] ?? 'placeholder',
agentGitCommitSha: json['agent_git_commit_sha'] ?? 'placeholder',
); );
/// Converts the `RepositoryInfo` instance to a map. /// Converts the `RepositoryInfo` instance to a map.

View File

@@ -5,7 +5,7 @@
/// the time of completion, the time when the benchmark started, and the name of the test. /// the time of completion, the time when the benchmark started, and the name of the test.
class RunDetails { class RunDetails {
/// The unique identifier for the benchmark run, typically a UUID. /// The unique identifier for the benchmark run, typically a UUID.
final String runId; String runId;
/// The command used to initiate the benchmark run. /// The command used to initiate the benchmark run.
final String command; final String command;
@@ -40,13 +40,15 @@ class RunDetails {
/// ///
/// Returns a new `RunDetails` populated with values from the map. /// Returns a new `RunDetails` populated with values from the map.
factory RunDetails.fromJson(Map<String, dynamic> json) => RunDetails( factory RunDetails.fromJson(Map<String, dynamic> json) => RunDetails(
runId: json['run_id'] ?? "", runId: json['run_id'] ?? 'placerholder',
command: json['command'], command: json['command'] ?? 'placeholder',
completionTime: json['completion_time'] == null completionTime: json['completion_time'] == null
? DateTime.now() ? DateTime.now()
: DateTime.parse(json['completion_time']), : DateTime.parse(json['completion_time']),
benchmarkStartTime: DateTime.parse(json['benchmark_start_time']), benchmarkStartTime: json['benchmark_start_time'] == null
testName: json['test_name'], ? DateTime.now()
: DateTime.parse(json['benchmark_start_time']),
testName: json['test_name'] ?? 'placeholder',
); );
/// Converts the `RunDetails` instance to a map. /// Converts the `RunDetails` instance to a map.

View File

@@ -1,4 +1,6 @@
// TODO: Remove the ability to have null values when benchmark implementation is complete // TODO: Remove the ability to have null values when benchmark implementation is complete
import 'dart:convert';
/// TaskInfo holds information related to a specific benchmark task. /// TaskInfo holds information related to a specific benchmark task.
/// ///
/// The class encapsulates various attributes of a task, such as the path to the data file, /// The class encapsulates various attributes of a task, such as the path to the data file,
@@ -47,12 +49,12 @@ class TaskInfo {
/// ///
/// Returns a new TaskInfo populated with values from the map. /// Returns a new TaskInfo populated with values from the map.
factory TaskInfo.fromJson(Map<String, dynamic> json) => TaskInfo( factory TaskInfo.fromJson(Map<String, dynamic> json) => TaskInfo(
dataPath: json['data_path'], dataPath: json['data_path'] ?? 'placeholder',
isRegression: json['is_regression'] ?? false, isRegression: json['is_regression'] ?? false,
category: List<String>.from(json['category']), category: List<String>.from(json['category']),
task: json['task'], task: json['task'] ?? 'placeholder',
answer: json['answer'], answer: json['answer'] ?? 'placeholder',
description: json['description'], description: json['description'] ?? 'placeholder',
); );
/// Converts the TaskInfo instance to a map. /// Converts the TaskInfo instance to a map.
@@ -61,7 +63,8 @@ class TaskInfo {
Map<String, dynamic> toJson() => { Map<String, dynamic> toJson() => {
'data_path': dataPath, 'data_path': dataPath,
'is_regression': isRegression, 'is_regression': isRegression,
'category': category, // 'category': jsonEncode(category),
'category': "[\"coding\"]",
'task': task, 'task': task,
'answer': answer, 'answer': answer,
'description': description, 'description': description,