Skip to content
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

fix: add ordering check to param meta matching #354

Merged
merged 26 commits into from
Apr 1, 2025

Conversation

Nitish-bot
Copy link

@Nitish-bot Nitish-bot commented Mar 15, 2025

This pull request modifies an existing rule to wdl-lint.

  • Rule Name: MatchingParameterMeta

Closes #259, and now checks for the order of parameter_metadata comparing it to the order of inputs

I have:

  • You have added a few sentences describing the PR here.
  • You have added yourself or the appropriate individual as the assignee.
  • You have added at least one relevant code reviewer to the PR.
  • Your code builds clean without any errors or warnings.
  • You have added an entry to the relevant CHANGELOG.md (see
    "keep a changelog" for more information).
  • Your commit messages follow the conventional commit style.
  • Your PR title follows the conventional commit style.

Rule specific checks:

  • You have added the rule as an entry within RULES.md.
  • You have added the rule to the rules() function in wdl-lint/src/lib.rs.
  • You have added a test case in wdl-lint/tests/lints that covers every
    possible diagnostic emitted for the rule within the file where the rule
    is implemented.
  • You have run gauntlet --bless to ensure that there are no
    unintended changes to the baseline configuration file (Gauntlet.toml).
  • You have run gauntlet --bless --arena to ensure that all of the
    rules added/removed are now reflected in the baseline configuration file
    (Arena.toml).

@Nitish-bot Nitish-bot changed the title Add ordering check to param meta matching fix: add ordering check to param meta matching Mar 15, 2025
@Nitish-bot
Copy link
Author

Nitish-bot commented Mar 15, 2025

I get a warning across 19 files at the first line saying the same thing i.e.

unknown lint: `rust_2024_incompatible_pat`
the `rust_2024_incompatible_pat` lint is unstable
see issue #123076 <https://github.com/rust-lang/rust/issues/123076> for more information
`#[warn(unknown_lints)]` on by default

I also get one more error warning two files that I haven't even touched so I am assuming they existed before my PR. It's a "missing documentation for a function" warning in wdl-engine/src/backend.rs:710:5 in the recurse_fit_maximal_range function along with another under wdl-doc/src/docs_tree.rs:99:9

Besides that, there are some changes to arena.toml after running the test and I went through a couple of them to find that the ordering of parameters was indeed not consistent.

Finally, while working on this PR I looked at some other lint rules and such to understand the codebase better and I think there is a certain inconsistency in the source.wdl files, some explain through comments, others assign strings and use those to convey the desired effect and some don't do any at all. I was wondering if this is a priority for you guys and if so I could go ahead and do a small review PR of all the rules and messages as a newcomer to see if they are easy to understand.

This is my first PR here so I am looking forward to learning how you guys do things around here and I was wondering if there is a separate communication channel where we can connect better.

@Nitish-bot Nitish-bot marked this pull request as ready for review March 15, 2025 13:58
@a-frantz
Copy link
Member

I get a warning across 19 files at the first line saying the same thing i.e.

unknown lint: `rust_2024_incompatible_pat`
the `rust_2024_incompatible_pat` lint is unstable
see issue #123076 <https://github.com/rust-lang/rust/issues/123076> for more information
`#[warn(unknown_lints)]` on by default

I also get one more error warning two files that I haven't even touched so I am assuming they existed before my PR. It's a "missing documentation for a function" warning in wdl-engine/src/backend.rs:710:5 in the recurse_fit_maximal_range function along with another under wdl-doc/src/docs_tree.rs:99:9

I believe that all these errors would be resolved by rebasing onto main. Your fork is out of sync with our latest changes.

Besides that, there are some changes to arena.toml after running the test and I went through a couple of them to find that the ordering of parameters was indeed not consistent.

Yes, the Arena.toml changes look correct to me!

@peterhuene
Copy link
Collaborator

Hi @Nitish-bot. I merged in a very large refactoring just a few minutes ago that is causing a conflict with your PR.

The CHANGELOG.md conflict should be pretty easy to resolve, but if you need any assistance with resolving conflicts in matching_parameter_meta.rs, please notify me on GitHub or Slack and I'll help out.

@Nitish-bot
Copy link
Author

Hey @a-frantz @peterhuene, I think I have addressed all concerns here and the PR is ready to be merged.

@@ -6,6 +6,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## Unreleased
### Fixed

* Fixed the `MatchingParameterMeta` rule to also check if the order of inputs matches parameter metadata ([#354](https://github.com/stjude-rust-labs/wdl/pull/354))
Copy link
Member

Choose a reason for hiding this comment

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

Please move this to the existing ### Fixed header under ## Unreleased

Copy link
Author

@Nitish-bot Nitish-bot Mar 18, 2025

Choose a reason for hiding this comment

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

You mean the previous ### Fixed pertaining to MatchingParameteMeta?

edit: nvm I got it now

Copy link
Member

Choose a reason for hiding this comment

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

@@ -1,5 +1,6 @@
## This is a test for checking for missing and extraneous entries
## in a `parameter_meta` section for a struct.
## in a `parameter_meta` section, and for ensuring that
## the order is the same as `input` section.
Copy link
Member

Choose a reason for hiding this comment

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

Can you add a new struct definition with an out of order parameter_meta to this test?

output {}
}

workflow test {
Copy link
Member

Choose a reason for hiding this comment

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

Can you add a task test case?

Comment on lines 90 to 93
.with_fix(format!(
"order the parameter metadata as:\n{}",
expected_order
))
Copy link
Member

Choose a reason for hiding this comment

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

I don't love this, but I'm not sure what a straightforward improvement would be.
My issue is that the "fix" here can't be copy and pasted, as it just outputs the order of the keys without their associated values. However, it would be difficult to properly format the values for output.

We've discussed vague plans of making wdl-lint dependent on wdl-format so that we can supply better fix messages, and I think we should probably wait for that to come to fruition instead of writing some complicated logic for this.

So for now, I'm fine with this fix message but its not ideal.

@a-frantz
Copy link
Member

@Nitish-bot two other test cases I would like to see in addition to what I just commented.

  1. an "out of order" input section with a matching parameter_meta (i.e. the parameter_meta should be in the same order as the input section, but the input section should trigger an InputSorting diagnostic)
  2. an "out of order" input section with an "out of order" parameter_meta (i.e. the parameter_meta should be in a different order than the input section, and the input section should trigger an InputSorting diagnostic)

@Nitish-bot
Copy link
Author

Nitish-bot commented Mar 19, 2025

@a-frantz

an "out of order" input section with an "out of order" parameter_meta (i.e. the parameter_meta should be in a different order than the input section, and the input section should trigger an InputSorting diagnostic)

do you mean that it should only trigger an InputSorting diagnostic? because it would also trigger the MatchingParam Diagnostic along with it

edit (19/03/25 11 PM +5:30 GMT): I have since updated it to my understanding please check it out

@claymcleod claymcleod added S-awaiting-pass-CI State: awaiting the CI to pass S-awaiting-revisions State: awaiting revisions based on code review feedback and removed S-awaiting-pass-CI State: awaiting the CI to pass labels Mar 19, 2025
@claymcleod claymcleod requested a review from a-frantz March 23, 2025 20:33
@claymcleod claymcleod added S-needs-review State: awaiting initial or additional review and removed S-awaiting-revisions State: awaiting revisions based on code review feedback labels Mar 23, 2025
@Nitish-bot
Copy link
Author

@claymcleod the revisions have been made, it is indeed awaiting review

@adthrasher adthrasher removed the S-needs-review State: awaiting initial or additional review label Mar 28, 2025
@Nitish-bot
Copy link
Author

Nitish-bot commented Mar 30, 2025

Aside from the review, I moved the struct definition test into struct-matching-param-meta test and removed the RuntimeKeys lint directive since it is deprecated and no longer throws a warning in WDL 1.2.
I can probably write a simple bash script to remove it from all test files that use 1.2 but that belongs in a PR of it's own.

Copy link
Member

@a-frantz a-frantz left a comment

Choose a reason for hiding this comment

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

I have the one concern about the interaction between InputSorting and MatchingParameterMeta, but otherwise this looks good to me 👍

Comment on lines 14 to 38
note[MatchingParameterMeta]: parameter metadata in task `input_sorting_test_2` is out of order
┌─ tests/lints/input-and-parameter-meta-sorting/source.wdl:39:5
39 │ parameter_meta {
│ ^^^^^^^^^^^^^^ parameter metadata must be in the same order as inputs
= fix: order the parameter metadata as:
w
p
t
q
b

note[InputSorting]: input not sorted
┌─ tests/lints/input-and-parameter-meta-sorting/source.wdl:47:5
47 │ input {
│ ^^^^^ input section must be sorted
= fix: sort input statements as:
File t
File b
Directory w
Array[String]+ p
Array[String]+ q
Copy link
Member

Choose a reason for hiding this comment

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

Making a new comment with the same concern I raised in an earlier review.

These diagnostics conflict with each other, and it could be confusing to users. How should we handle this case? @adthrasher

Copy link
Member

Choose a reason for hiding this comment

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

Ideally, I think the MatchingParameterMeta rule would output the "correct" order that InputSorting uses. Or it would have a flag on the task/workflow that indicates the input is not properly sorted and would update the diagnostic accordingly. That's not a straightforward change at this point, so we may have to live with it. To me, the confusion stems from parameter_meta preceding input in the source. If the InputSorting diagnostic was first, then I think it's potentially less confusing for users.

Copy link
Member

@adthrasher adthrasher Mar 31, 2025

Choose a reason for hiding this comment

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

A simple approach would be to update the "fix" message to something like: "fix: Based on current the input block, order the parameter metadata as:".

Copy link
Member

Choose a reason for hiding this comment

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

A simple approach would be to update the "fix" message to something like: "fix: Based on current the input block, order the parameter metadata as:".

I think this seems a decent bandaid for the situation. With an updated fix message, I'd be ok merging this if it's accompanied by a new issue with these details. We can come back and tinker at it later.

A potential fix is to rely on wdl-format to get the right order. However wdl-format currently doesn't do this sort, so that would need to be implemented first.

Copy link
Member

Choose a reason for hiding this comment

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

I made a suggested change above, please double-check the wording. Also the issue is:
#379

@a-frantz a-frantz added S-needs-review State: awaiting initial or additional review and removed S-awaiting-revisions State: awaiting revisions based on code review feedback labels Mar 31, 2025
Copy link
Member

@a-frantz a-frantz left a comment

Choose a reason for hiding this comment

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

pending the fix update: looks great. This fix is overdue! Happy to get it merged and into the next Sprocket release 🚀

@Nitish-bot
Copy link
Author

I have made the required change.

A potential fix is to rely on wdl-format to get the right order. However wdl-format currently doesn't do this sort, so that would need to be implemented first.

Also you mentioned handling this in wdl-format, I would love to implement this in another PR if this is a priority.

@a-frantz
Copy link
Member

I have made the required change.

A potential fix is to rely on wdl-format to get the right order. However wdl-format currently doesn't do this sort, so that would need to be implemented first.

Also you mentioned handling this in wdl-format, I would love to implement this in another PR if this is a priority.

I will write up some more details of what I had in mind in a new issue.

You also need to rebless the tests

@Nitish-bot
Copy link
Author

alright I am running the tests, in the meanwhile I found out andrew-t already created an issue #379 wherein he mentions that this would require some discussion within the team. I can open a slack thread to discuss this better.

@a-frantz
Copy link
Member

issue created: #380

@Nitish-bot
Copy link
Author

Alright this should be ready to get merged

@adthrasher adthrasher merged commit e0d636e into stjude-rust-labs:main Apr 1, 2025
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-needs-review State: awaiting initial or additional review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

lint warning for inputs and parameter_meta being in a different order
5 participants