Skip to content

Refactor dummy evaluator to use conductor runner API#3693

Open
yytelliot wants to merge 3 commits intosource-academy:masterfrom
yytelliot:dummy-evaluator
Open

Refactor dummy evaluator to use conductor runner API#3693
yytelliot wants to merge 3 commits intosource-academy:masterfrom
yytelliot:dummy-evaluator

Conversation

@yytelliot
Copy link
Copy Markdown
Contributor

Description

Made the dummy evaluator use the conductor runner API instead of a dummy conductor class so that it is a more accurate reference.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update
  • Code quality improvements

How to test

Checklist

  • I have tested this code
  • I have updated the documentation

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request refactors the dummy evaluator to align with the official conductor runner API. This change ensures the dummy evaluator serves as a more accurate and realistic reference implementation, improving consistency and maintainability by leveraging the established API for conductor interactions rather than a custom, simplified version.

Highlights

  • API Integration: Refactored the dummy evaluator to utilize the conductor runner API, replacing a custom conductor implementation with the official interface.
  • Code Simplification: Removed various custom functions and objects related to channel communication and chunk handling, streamlining the evaluator's internal logic.
  • Error Handling: Introduced error normalization and an unhandled rejection listener to improve robustness and consistent error reporting within the evaluator.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the dummy-conductor-evaluator.js to integrate with the new conductor runner API, replacing the previous custom message handling and evaluator setup. This involves removing old channel-related constants and functions, introducing dynamic import for the runner, and adapting the DummyEvaluator to the new API. Feedback includes an issue where the !fileContent check in startEvaluator incorrectly treats empty files as an error, suggesting a more specific check for undefined. Additionally, there's a design concern about the DummyEvaluator constructor having a side effect by assigning to an outer-scoped variable (runnerConductor), which increases coupling and reduces reusability.

async startEvaluator(entryPoint) {
await this.evaluateFile(entryPoint, '');
const fileContent = await this.conductor.requestFile(entryPoint);
if (!fileContent) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The check !fileContent will evaluate to true for both undefined (file not found) and an empty string '' (empty file). This means that if the entrypoint file exists but is empty, this code will incorrectly throw an error. An empty file is a valid scenario. You should check specifically for undefined to distinguish between a file that was not found and a file that is empty.

Suggested change
if (!fileContent) {
if (fileContent === undefined) {

class DummyEvaluator {
constructor(conductor) {
this.conductor = conductor;
runnerConductor = conductor;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The constructor has a side effect of assigning to runnerConductor, a variable in the outer scope. This couples the DummyEvaluator class to its surrounding implementation, making it less reusable and harder to test. While this works, it's generally best to avoid side effects in constructors. If the runner's initialise API provides a way to get a handle on the conductor instance it creates, it would be cleaner to set up the unhandledrejection listener outside of this class.

class DummyEvaluator extends BasicEvaluator {
async evaluateFile(fileName, fileContent) {
this.conductor.sendOutput('[dummy] output message');
this.conductor.sendResult('[dummy] result message');

This comment was marked as outdated.

@coveralls
Copy link
Copy Markdown

Pull Request Test Coverage Report for Build 23564088475

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 41.924%

Totals Coverage Status
Change from base Build 23564037850: 0.0%
Covered Lines: 5765
Relevant Lines: 12726

💛 - Coveralls

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants