Skip to content

Commit

Permalink
Backwards Compatibility Tests (#596)
Browse files Browse the repository at this point in the history
## Pull Request: Backward Compatibility Testing

### Description
This Pull Request introduces backward compatibility tests to ensure that
different branches produce identical model outputs under the same
conditions. The primary goal of these tests is to confirm that there are
no regressions or inconsistencies in the model's behavior when
developing or refactoring features on a development branch based on the
main branch.

### Changes
- Added a new shell script `compare.sh` for running backward
compatibility tests.
- The script sets a reference output directory that must be located
outside the adapters repository to ensure it's available when switching
branches.
- Created two Python scripts, `create_outputs.py` and
`compare_outputs.py`, to generate and compare reference model outputs.
- The script performs the following steps:
  1. Installs the adapters version of the current branch.
  2. Creates reference model outputs using `create_outputs.py`.
  3. Checks out the target branch to be tested.
  4. Installs the adapters version of the target branch.
5. Compares the model outputs produced by the target branch with the
reference outputs using `compare_outputs.py`.

### How to Use
1. Navigate to the `back_comp` directory in the terminal
2. Run the following command: `sh compare.sh`
  • Loading branch information
TimoImhof authored Nov 15, 2023
1 parent a6055d0 commit 841ce18
Show file tree
Hide file tree
Showing 6 changed files with 665 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -172,3 +172,6 @@ scripts/git-strip-merge
# DS_Store (MacOS)
.DS_Store
tests_adapters/backwards_compatibility/Ref_Out

# backwards compatibility
model_outputs
26 changes: 26 additions & 0 deletions utils/back_comp/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Backwards Compatibility Tests

## Motivation

This directory contains a set of tests that can be run to ensure that newly introduced changes or refactorings do not break existing functionalities. These tests verify model output consistency between two branches; here, we use the names `dev` and `main` for demonstration purposes, but these tests can be performed between any two branches where the `back_comp` directory with tests is available.
For this, the test script performs a forward pass for each supported model and compares the outputs between `dev` and `main` to identify any differences.

## Requirements

To execute these tests, you must meet the following requirements:

- Ability to run bash scripts (in-built on Linux/macOS; for Windows, consider using third-party software like [GNU Bash](https://www.gnu.org/software/bash/)).
- Git as the version control system to switch between branches.
- The ability to check out the desired branch. If the branch is from another fork, you may need to add the repository as a remote. Refer to [GitHub's instructions](https://docs.github.com/en/get-started/getting-started-with-git/managing-remote-repositories) for details.
- A Python virtual environment to modify the installed package version of `adapters`.

## Procedure

To perform the compatibility tests, follow these steps:

1. Determine a directory where you want to save the model output generated by the tests. Save this directory path to the variable `SaveDir` in the shell script `compare.sh`. (Careful: select a directory OUTSIDE of the repository; otherwise, the saved model output is no longer available when changing the branch.)
2. Select the branch you want to compare with `main` and save its name to the variable `Branch`.
3. Make sure you are checked out in `main` before starting the test script.
4. In your command line, navigate to the `back_comp` directory and execute the script by running `sh compare.sh`.

The results will be displayed in the command line for visualization.
Loading

0 comments on commit 841ce18

Please sign in to comment.