Temporarily allow null values in benchmark data models

This commit is contained in:
hunteraraujo
2023-09-22 13:48:03 -07:00
parent a0e383f4d9
commit 18333fbc7c
6 changed files with 22 additions and 14 deletions

View File

@@ -4,6 +4,7 @@ import 'package:auto_gpt_flutter_client/models/benchmark/repository_info.dart';
import 'package:auto_gpt_flutter_client/models/benchmark/run_details.dart';
import 'package:auto_gpt_flutter_client/models/benchmark/task_info.dart';
// TODO: Remove the ability to have null values when benchmark implementation is complete
/// `BenchmarkRun` represents a complete benchmark run and encapsulates all associated data.
///
/// This class is a comprehensive model that includes various sub-models, each corresponding to a different aspect of a benchmark run.
@@ -54,7 +55,7 @@ class BenchmarkRun {
runDetails: RunDetails.fromJson(json['run_details']),
taskInfo: TaskInfo.fromJson(json['task_info']),
metrics: Metrics.fromJson(json['metrics']),
reachedCutoff: json['reached_cutoff'],
reachedCutoff: json['reached_cutoff'] ?? false,
config: Config.fromJson(json['config']),
);

View File

@@ -1,3 +1,4 @@
// TODO: Remove the ability to have null values when benchmark implementation is complete
/// `Config` holds configuration settings related to the benchmark run.
///
/// It contains the path to the benchmark configuration for the agent and
@@ -27,8 +28,8 @@ class Config {
///
/// Returns a new `Config` populated with values from the map.
factory Config.fromJson(Map<String, dynamic> json) => Config(
agentBenchmarkConfigPath: json['agent_benchmark_config_path'],
host: json['host'],
agentBenchmarkConfigPath: json['agent_benchmark_config_path'] ?? "",
host: json['host'] ?? "",
);
/// Converts the `Config` instance to a map.

View File

@@ -1,3 +1,4 @@
// TODO: Remove the ability to have null values when benchmark implementation is complete
/// `Metrics` holds key performance metrics related to a benchmark test run.
///
/// The class encapsulates various data points like difficulty, success rate,
@@ -45,12 +46,12 @@ class Metrics {
///
/// Returns a new `Metrics` populated with values from the map.
factory Metrics.fromJson(Map<String, dynamic> json) => Metrics(
difficulty: json['difficulty'],
difficulty: json['difficulty'] ?? "",
success: json['success'],
attempted: json['attempted'],
successPercentage: json['success_percentage'].toDouble(),
cost: json['cost'],
runTime: json['run_time'],
successPercentage: json['success_percentage'].toDouble() ?? 0.0,
cost: json['cost'] ?? "",
runTime: json['run_time'] ?? "",
);
/// Converts the `Metrics` instance to a map.

View File

@@ -1,3 +1,4 @@
// TODO: Remove the ability to have null values when benchmark implementation is complete
/// `RepositoryInfo` encapsulates details about the repository and team associated with a benchmark run.
///
/// This class contains essential information like the repository URL, team name, and the Git commit SHA for both the benchmark and the agent.
@@ -33,10 +34,10 @@ class RepositoryInfo {
///
/// Returns a new `RepositoryInfo` populated with values from the map.
factory RepositoryInfo.fromJson(Map<String, dynamic> json) => RepositoryInfo(
repoUrl: json['repo_url'],
teamName: json['team_name'],
benchmarkGitCommitSha: json['benchmark_git_commit_sha'],
agentGitCommitSha: json['agent_git_commit_sha'],
repoUrl: json['repo_url'] ?? "",
teamName: json['team_name'] ?? "",
benchmarkGitCommitSha: json['benchmark_git_commit_sha'] ?? "",
agentGitCommitSha: json['agent_git_commit_sha'] ?? "",
);
/// Converts the `RepositoryInfo` instance to a map.

View File

@@ -1,3 +1,4 @@
// TODO: Remove the ability to have null values when benchmark implementation is complete
/// `RunDetails` encapsulates specific details about a benchmark run.
///
/// This class holds attributes such as the unique run identifier, the command used to initiate the run,
@@ -39,9 +40,11 @@ class RunDetails {
///
/// Returns a new `RunDetails` populated with values from the map.
factory RunDetails.fromJson(Map<String, dynamic> json) => RunDetails(
runId: json['run_id'],
runId: json['run_id'] ?? "",
command: json['command'],
completionTime: DateTime.parse(json['completion_time']),
completionTime: json['completion_time'] == null
? DateTime.now()
: DateTime.parse(json['completion_time']),
benchmarkStartTime: DateTime.parse(json['benchmark_start_time']),
testName: json['test_name'],
);

View File

@@ -1,3 +1,4 @@
// TODO: Remove the ability to have null values when benchmark implementation is complete
/// 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,
@@ -47,7 +48,7 @@ class TaskInfo {
/// Returns a new TaskInfo populated with values from the map.
factory TaskInfo.fromJson(Map<String, dynamic> json) => TaskInfo(
dataPath: json['data_path'],
isRegression: json['is_regression'],
isRegression: json['is_regression'] ?? false,
category: List<String>.from(json['category']),
task: json['task'],
answer: json['answer'],