Skip to content

Fix CompareMPS when files differ in length #1190

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

Merged
merged 1 commit into from
May 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions .github/workflows/CompareMPS.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,19 @@ jobs:
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: "github-actions[bot]"
body-includes: This was CompareMPS
body-includes: CompareMPS report
- name: Comment on PR with CompareMPS
if: github.event.pull_request.head.repo.full_name == github.repository
uses: peter-evans/create-or-update-comment@v4
with:
comment-id: ${{ steps.find-old-comment.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
body: |
## :robot: CompareMPS report

### :hourglass: Running MPS comparison

Please wait.

:robot: This was CompareMPS, we hope you have enjoyed this program.
edit-mode: replace
- name: Clone
uses: actions/checkout@v4
Expand All @@ -59,9 +59,11 @@ jobs:
- name: Create PR body
if: failure()
run: |
echo '## :warning: MPS files differ
echo '## :robot: CompareMPS report

### :warning: MPS files differ

### What to do?
What to do?

#### :+1: If this is expected

Expand All @@ -71,7 +73,7 @@ jobs:
julia --project=. utils/scripts/model-mps-update.jl
```

#### :-1: This is bad
#### :-1: If this is bad

Then, review the log below to figure out why the files differ:

Expand All @@ -84,8 +86,6 @@ jobs:
</details>

For more details about this workflow, check <https://tulipaenergy.github.io/TulipaEnergyModel.jl/dev/91-developer/#Testing-the-generate-MPS-files>.

:robot: This was CompareMPS, we hope you have enjoyed this program.
' >> body.md
echo "::warning title=MPS files are different::$(cat body.md)"
- name: Find Comment
Expand All @@ -95,7 +95,7 @@ jobs:
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: "github-actions[bot]"
body-includes: This was CompareMPS
body-includes: CompareMPS report
- name: Comment on PR with log if failed
if: failure() && github.event.pull_request.head.repo.full_name == github.repository
uses: peter-evans/create-or-update-comment@v4
Expand All @@ -111,7 +111,7 @@ jobs:
comment-id: ${{ steps.find-comment.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
body: |
### :white_check_mark: MPS files match
## :robot: CompareMPS report

:robot: This was CompareMPS, we hope you have enjoyed this program.
### :white_check_mark: MPS files match
edit-mode: replace
2 changes: 1 addition & 1 deletion docs/src/91-developer.md
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,7 @@ When creating a pull request, the workflow `CompareMPS.yml` will run the compari
2. **Unexpected failure**: If you made modifications that were not supposed to change the model, then you need to investigate what happened. Use the MPS difference to debug what you have done. There is no easy fix for this. If you think there are bugs in the comparison script, discuss with your PR reviewer and open an issue if necessary.

!!! warning
The comparison workflow only writes PR comments if the branch is made from within `TulipaEnergyModel`. To see the log online in that case, you have to open the GitHub action log, or run the comparison locally, as explained in the previous section.
The comparison workflow only writes PR comments if the branch is made from within `TulipaEnergyModel` (i.e., not from forks). To see the log online in that case, you have to open the GitHub action log, or run the comparison locally, as explained in the previous section.

## Procedure for Releasing a New Version (Julia Registry)

Expand Down
1 change: 1 addition & 0 deletions utils/scripts/model-mps-compare.jl
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ function compare_mps(existing_mps_folder)
new_lines = readlines(new_mps_file)

if length(existing_lines) != length(new_lines)
no_issues = false
@error "Files don't have the same size"
else
zipped_lines = zip(existing_lines, new_lines)
Expand Down