Skip to content

Add support for specifying response file location #30

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

mattleibow
Copy link
Contributor

@mattleibow mattleibow commented May 29, 2025

This pull request introduces a new feature for handling custom response file paths in the AI inference action, along with improvements to error handling and test coverage. The changes include updates to the README.md documentation, the action.yml file, the main action logic in src/main.ts, and the test suite in __tests__/main.test.ts.

New Feature: Custom Response File Paths

  • Documentation Update: Added a new section in README.md explaining how to use a custom response file path (response-file) in workflows.
  • Input Definition: Added a new response-file input in action.yml to specify the file path where the model's response should be saved.
  • Logic Implementation: Introduced the getResponseFilePath helper function in src/main.ts to handle custom response file paths, ensuring directories are created if necessary. Updated the main logic to use this function. [1] [2]

Improved Error Handling

  • Enhanced error handling in src/main.ts to gracefully manage both Error and non-Error exceptions, providing clearer feedback in workflow runs. [1] [2]

Test Suite Enhancements

  • New Test Cases: Added tests in __tests__/main.test.ts to verify:
    • Proper handling of custom and default response file paths.
    • Behavior when the model response is empty.
    • Handling of Error and non-Error exceptions.
  • Mock Updates: Introduced new mocks for fs.writeFileSync and fs.mkdirSync to support testing file system operations. [1] [2]

These changes collectively improve the flexibility, reliability, and testability of the action.

Currently, the response goes to a temp location and subsequent
inference requests overwrite.

This change adds a new input that will allow the user to specify
where the response file should be located.
@Copilot Copilot AI review requested due to automatic review settings May 29, 2025 19:31
@mattleibow mattleibow requested a review from a team as a code owner May 29, 2025 19:31
Copy link

@Copilot 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

This pull request adds support for specifying a custom response file location so that subsequent inference requests do not overwrite previous responses. Key changes include:

  • Updating the token validation to check for empty strings.
  • Adding a new input (response-file) and logic to use a custom file path with directory creation if needed.
  • Extending tests to cover scenarios for both custom and default response file paths.

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

File Description
src/main.ts Added custom response file input and directory creation.
action.yml Defined the new input for specifying the response file.
tests/main.test.ts Updated tests to verify the new response file behavior.

@StefMa
Copy link

StefMa commented May 29, 2025

Why should someone be interested in setting the path to the response file? 🤔 What is the use case for this?

@mattleibow
Copy link
Contributor Author

I have a workflow where I am doing inference a few times: selecting an area label, a regression label, etc and each time I need a new location.

I could (I am now) running the inference, then copying the output, then running again.

But, having the copy is messy when I could just run the inference a few times and then collect all the files and post as a single comment.

@sgoedecke
Copy link
Collaborator

Looks reasonable enough to me. I can see why you might want to specify the file location if you're plugging this into other workflows that might expect particular files to be in particular places.

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.

3 participants