Skip to content

216 td fix inverted reporter mode assignment#243

Open
matheusmra wants to merge 6 commits intomainfrom
216-td-fix-inverted-reporter-mode-assignment
Open

216 td fix inverted reporter mode assignment#243
matheusmra wants to merge 6 commits intomainfrom
216-td-fix-inverted-reporter-mode-assignment

Conversation

@matheusmra
Copy link
Member

This pull request introduces a comprehensive refactor and enhancement of the feedback/report generation system in the autograder, including improvements to the reporting logic, service delegation, and integration with pipeline steps. The changes also add robust unit and playroom tests to ensure reliability and correctness. The most important changes are grouped below:

Reporting Logic Improvements

  • Refactored DefaultReporter.generate_report to produce structured, customizable reports based on user preferences, including titles, summaries, categorized results, scores, and learning resources.
  • Updated AiReporter.generate_report to accept new parameters (focus, result_tree, preferences) for future extensibility and compatibility with the new reporting interface.

Service Delegation and Integration

  • Refactored ReporterService to select the correct reporter based on feedback_mode, parse feedback config into preference objects, and delegate report generation to the active reporter. Added a new generate_feedback method for unified report creation.
  • Updated FeedbackStep.execute to use the new ReporterService.generate_feedback method, properly handle success/failure, and utilize new factory methods for StepResult. [1] [2]

Testing Enhancements

  • Added playroom-style integration test for DefaultReporter to demonstrate report generation with mock data and preferences.
  • Added unit tests for DefaultReporter covering report structure, passed test filtering, and graceful handling of empty input.
  • Added unit tests for ReporterService to verify reporter selection, feedback delegation, and preference parsing.
  • Added integration test for FeedbackStep to ensure correct execution and report content in the pipeline.

Copilot AI review requested due to automatic review settings March 20, 2026 00:14
@matheusmra matheusmra linked an issue Mar 20, 2026 that may be closed by this pull request
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Refactors the autograder’s feedback/report generation flow by introducing a preference-driven reporter interface, wiring it into the FeedbackStep, and adding tests to validate reporter selection and basic report output.

Changes:

  • Implemented a markdown-based DefaultReporter.generate_report(focus, result_tree, preferences) and updated AiReporter to the new interface.
  • Added ReporterService.generate_feedback() to select/delegate report generation and parse feedback config into preference objects.
  • Added StepResult.success() / StepResult.fail() helpers and updated FeedbackStep plus new unit/playroom tests around the reporting flow.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
autograder/services/report/reporter_service.py Selects reporter by mode and parses feedback config into FeedbackPreferences before delegating report generation.
autograder/services/report/default_reporter.py New structured markdown report generation using ResultTreeFormatter and preferences.
autograder/services/report/ai_reporter.py Updated AI reporter stub to new report-generation interface.
autograder/steps/feedback_step.py Uses ReporterService.generate_feedback() and StepResult.success/fail() to store FEEDBACK step results.
autograder/models/dataclass/step_result.py Adds StepResult.success() and StepResult.fail() factory methods and docstrings.
tests/unit/services/test_reporter_service.py Unit tests for reporter selection and delegation + preference parsing.
tests/unit/services/test_default_reporter.py Unit tests for default reporter output, passed-test toggling, and empty-input handling.
tests/unit/pipeline/test_feedback_step_integration.py Pipeline-level test ensuring FEEDBACK step generates expected content.
tests/playroom/test_reporter.py Manual “playroom” script demonstrating default reporter output with mock data and preferences.


class AiReporter:
"""Reporter that uses AI to generate feedback."""
def generate_report(self, _focus, _result_tree, _preferences=None):
Copy link

Copilot AI Mar 20, 2026

Choose a reason for hiding this comment

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

AiReporter.generate_report defines parameters named _focus, _result_tree, _preferences, but ReporterService calls it using keyword arguments focus=, result_tree=, and preferences=. This will raise a TypeError in AI mode. Rename the parameters to focus, result_tree, preferences (or accept **kwargs) to match the service call signature.

Suggested change
def generate_report(self, _focus, _result_tree, _preferences=None):
def generate_report(self, focus, result_tree, preferences=None):

Copilot uses AI. Check for mistakes.
Comment on lines +26 to +35
# Simple manual parsing of the nested config dict into FeedbackPreferences
general_cfg = feedback_config.get("general", {})
ai_cfg = feedback_config.get("ai", {})
default_cfg = feedback_config.get("default", {})

preferences = FeedbackPreferences(
general=GeneralPreferences(**general_cfg),
ai=AiReporterPreferences(**ai_cfg),
default=DefaultReporterPreferences(**default_cfg)
)
Copy link

Copilot AI Mar 20, 2026

Choose a reason for hiding this comment

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

ReporterService builds GeneralPreferences(**general_cfg) directly from feedback.json. Existing configs in the repo (e.g., examples/assets/*/feedback.json) include keys like show_test_details that are not fields on GeneralPreferences, which will raise an unexpected-key TypeError and fail feedback generation. Consider filtering/whitelisting known keys (or adding backwards-compatible fields) so unknown config options don’t break report generation.

Copilot uses AI. Check for mistakes.
return pipeline_exec.add_step_result(feedback) #Assuming feedback is a StepResult
except Exception as e:
return pipeline_exec.add_step_result(feedback)
except (ValueError, KeyError, AttributeError, TypeError, RuntimeError) as e:
Copy link

Copilot AI Mar 20, 2026

Choose a reason for hiding this comment

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

FeedbackStep now only catches a narrow set of exception types. Other pipeline steps consistently catch Exception and convert errors into a failed StepResult; with the narrowed catch, unexpected exceptions from reporters (e.g., network/SDK errors) will bubble up and interrupt the pipeline instead of producing a FEEDBACK step failure result. Align with the other steps by catching Exception here (while still logging details) so feedback failures are reported through StepResult consistently.

Suggested change
except (ValueError, KeyError, AttributeError, TypeError, RuntimeError) as e:
except Exception as e:

Copilot uses AI. Check for mistakes.
Comment on lines +2 to +3
import sys
from pathlib import Path
Copy link

Copilot AI Mar 20, 2026

Choose a reason for hiding this comment

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

tests/playroom/test_reporter.py imports sys and Path but does not use them. Removing unused imports will avoid lint/test failures in environments that enforce import cleanliness.

Suggested change
import sys
from pathlib import Path

Copilot uses AI. Check for mistakes.
Comment on lines +26 to +35
# Simple manual parsing of the nested config dict into FeedbackPreferences
general_cfg = feedback_config.get("general", {})
ai_cfg = feedback_config.get("ai", {})
default_cfg = feedback_config.get("default", {})

preferences = FeedbackPreferences(
general=GeneralPreferences(**general_cfg),
ai=AiReporterPreferences(**ai_cfg),
default=DefaultReporterPreferences(**default_cfg)
)
Copy link

Copilot AI Mar 20, 2026

Choose a reason for hiding this comment

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

GeneralPreferences.online_content is typed as List[LearningResource], but ReporterService currently passes through whatever is in feedback_config['general']['online_content'] via GeneralPreferences(**general_cfg). Since feedback_config comes from JSON, online_content entries will be dicts, and DefaultReporter later expects each item to have .description/.url attributes. Parse online_content into LearningResource instances (or adjust DefaultReporter to handle dicts) to prevent runtime AttributeError when online resources are configured.

Copilot uses AI. Check for mistakes.
@matheusmra
Copy link
Member Author

@ArthurCRodrigues ready for review :)

Copy link
Member

@ArthurCRodrigues ArthurCRodrigues left a comment

Choose a reason for hiding this comment

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

@matheusmra can you provide some feedback examples in the PR description?

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.

[TD] Fix FeedbackStep Contract [TD] Implement DefaultReporter Output [TD] Fix Inverted Reporter Mode Assignment

3 participants