Enhance runBenchmark with TestSuite Tracking (#5268)

This commit is contained in:
hunteraraujo
2023-09-19 21:31:02 -07:00
committed by GitHub
parent 80682b41cb
commit 525571c32e
2 changed files with 17 additions and 4 deletions

View File

@@ -5,8 +5,10 @@ import 'package:auto_gpt_flutter_client/models/skill_tree/skill_tree_edge.dart';
import 'package:auto_gpt_flutter_client/models/skill_tree/skill_tree_node.dart';
import 'package:auto_gpt_flutter_client/models/step.dart';
import 'package:auto_gpt_flutter_client/models/task.dart';
import 'package:auto_gpt_flutter_client/models/test_suite.dart';
import 'package:auto_gpt_flutter_client/services/benchmark_service.dart';
import 'package:auto_gpt_flutter_client/viewmodels/chat_viewmodel.dart';
import 'package:auto_gpt_flutter_client/viewmodels/task_viewmodel.dart';
import 'package:collection/collection.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/services.dart';
@@ -139,11 +141,15 @@ class SkillTreeViewModel extends ChangeNotifier {
}
// TODO: Move to task queue view model
// TODO: We should be creating TestSuite objects
Future<void> runBenchmark(ChatViewModel chatViewModel) async {
Future<void> runBenchmark(
ChatViewModel chatViewModel, TaskViewModel taskViewModel) async {
// Clear the benchmarkStatusList
benchmarkStatusList.clear();
// Create a new TestSuite object with the current timestamp
final testSuite =
TestSuite(timestamp: DateTime.now().toIso8601String(), tests: []);
// Set the benchmark running flag to true
isBenchmarkRunning = true;
// Notify listeners
@@ -209,7 +215,11 @@ class SkillTreeViewModel extends ChangeNotifier {
"Benchmark for node ${node.id} failed. Stopping all benchmarks.");
break;
}
testSuite.tests.add(task);
}
// Add the TestSuite to the TaskViewModel
taskViewModel.addTestSuite(testSuite);
} catch (e) {
print("Error while running benchmark: $e");
}

View File

@@ -1,4 +1,5 @@
import 'package:auto_gpt_flutter_client/viewmodels/chat_viewmodel.dart';
import 'package:auto_gpt_flutter_client/viewmodels/task_viewmodel.dart';
import 'package:flutter/material.dart';
import 'package:auto_gpt_flutter_client/viewmodels/skill_tree_viewmodel.dart';
import 'package:provider/provider.dart';
@@ -56,12 +57,14 @@ class TaskQueueView extends StatelessWidget {
onPressed: viewModel.isBenchmarkRunning
? null
: () {
// TODO: Handle this better
// TODO: We should not be passing this dependency in like this
final chatViewModel =
Provider.of<ChatViewModel>(context, listen: false);
final taskViewModel =
Provider.of<TaskViewModel>(context, listen: false);
chatViewModel.clearCurrentTaskAndChats();
// Call runBenchmark method from SkillTreeViewModel
viewModel.runBenchmark(chatViewModel);
viewModel.runBenchmark(chatViewModel, taskViewModel);
},
child: Row(
mainAxisAlignment: