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

Add lint warning for tools with cores and no mem #140

Merged
merged 8 commits into from
Nov 18, 2024

Conversation

natefoo
Copy link
Member

@natefoo natefoo commented Oct 31, 2024

Related discussion in galaxyproject/tpv-shared-database#73.

I looked a bit at adding #noqa support but reading comments and figuring out the line they are associated with seemed a bit tricky. But if it's something we want I could work on that. Alternatively, tpv lint --ignore=... to simply ignore an entire class of warnings would be easy to implement, but then it's all-or-nothing.
I went ahead and added # noqa and command line tpv lint --ignore=... support. # noqa comments apply to the whole entity they are contained within and can either be without a specific code (in which case all warnings are ignored) or can specify codes as a comma-separated list like # noqa: T101, T102, .... Inline # noqa comments are not supported.

IMO you'd probably not want these warnings on your local TPV config, but we probably do want them on the shared DB.

@coveralls
Copy link
Collaborator

coveralls commented Nov 4, 2024

Pull Request Test Coverage Report for Build 11805014496

Details

  • 78 of 81 (96.3%) changed or added relevant lines in 5 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.3%) to 95.349%

Changes Missing Coverage Covered Lines Changed/Added Lines %
tpv/core/loader.py 31 34 91.18%
Totals Coverage Status
Change from base Build 10706773089: -0.3%
Covered Lines: 1071
Relevant Lines: 1102

💛 - Coveralls

Copy link
Member

@nuwang nuwang left a comment

Choose a reason for hiding this comment

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

This looks great, thanks @natefoo! I think it should finally take away all those spurious warnings.

This might be a bit hairy to merge with: https://github.com/galaxyproject/total-perspective-vortex/pull/136/files but that's on me - I still need to enhance the linter to use that PR, and check types.

tpv/core/util.py Outdated
def load_yaml_from_url_or_path(url_or_path: str):
yaml = ruamel.yaml.YAML(typ='safe')
def load_yaml_from_url_or_path(url_or_path: str, round_trip: bool = False):
typ = "rt" if round_trip else "safe"
Copy link
Member

Choose a reason for hiding this comment

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

Can we simplify this to make it roundtrip always? Is there a disadvantage?

Copy link
Member Author

Choose a reason for hiding this comment

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

With safe the data loads as plain Python objects (e.g. dicts and lists) and changing the loader to rt makes them CommentedMap, CommentedList, etc. Since only the linter needs round trip it this felt safer to me not knowing the code very well, but if you don't think it would cause problems I'm happy to change it to always load round trip.

Copy link
Member Author

Choose a reason for hiding this comment

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

Regarding a disadvantage, if all the data are copied from the loader Entity objects (and not by copying the ref to the loader object representation) then it's probably ok. If not, it could potentially increase memory usage slightly and I am not certain everything would merge the same way without digging into ruamel.yaml.

Copy link
Member

Choose a reason for hiding this comment

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

If I remember correctly, the current implementation is unlikely to preserve ruamel objects when copying. However, the current implementation will be obsolete once we merge this: #136

I'm guessing pydantic won't preserve ruamel either?

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok, I changed it to always use roundtrip. The formatter will need some extra work though to preserve comments through to writing.

Copy link
Member Author

Choose a reason for hiding this comment

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

The round trip formatter is implemented as well, this should be good to go.

Copy link
Member

@nuwang nuwang left a comment

Choose a reason for hiding this comment

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

Thanks @natefoo. Looks great!

@nuwang nuwang merged commit d835738 into galaxyproject:main Nov 18, 2024
2 checks passed
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