pyOpenSci / pyosMeta

A package that updates pyOpenSci contributor and package metadata on our website
BSD 3-Clause "New" or "Revised" License
4 stars 17 forks source link

Refactor issue parser - lifecycle methods, use pydantic models, support reviewer lists #174

Closed sneakers-the-rat closed 1 month ago

sneakers-the-rat commented 1 month ago

Fix: https://github.com/pyOpenSci/pyosMeta/issues/173

Wanted to do this for awhile, but i refactored the issue parser so it should be a bit easier to make modifications to it going forward.

Previously the field parsing logic was split in a bunch of different places, but this brings it into a linear set of lifecycle methods for parsing a review issue:

Currently:

This PR:

This gives clear places to add parsing logic, in a preprocessing, field processing, or postprocessing step. It also uses pydantic models instead of anonymous lists of lists, dicts of dicts, etc. so we can know what to expect at each of the stages. I noticed that a few of the methods were sort of awkward because they expected to operate over the whole list-of-lists of the '\n' and ': ' split issue body, so this separates things out a bit so they should be easier to maintain and test.

also:

sneakers-the-rat commented 1 month ago

i guess the thing that would be nice here re: https://github.com/pyOpenSci/pyopensci.github.io/pull/434 is single-sourcing the template: like ideally we would give the human readable names as aliases or title or something and make a classmethod for the ReviewModel that generates that review template, so changing the review template would be a change to the ReviewModel and there is no gap between them where it's possible to forget. Then we could have example reviews from each time the template changes to make sure we still support the current and all prior review checklist formats.

sneakers-the-rat commented 1 month ago

it looks like a number of fields were marked as optional in ReviewModel, presumably to be able to test with a reduced input set, but that causes us to improperly validate review issues with missing information.

sneakers-the-rat commented 1 month ago

it would b nice to have something like VCR to record all the website updates and put that in pytest for local testing bc rn i'm just using the CI like pytest since i don't have the GITHUB_TOKEN

sneakers-the-rat commented 1 month ago

ok there ya have it. since the model has a ton of optional params, i can't be sure that things are actually still working, but that's enough for one day. hopefully saves us some headaches in the future and makes it a little easier to tweak the reviewer template/speeds adoption of the pyos bot by making it easier to handle parsing multiple forms of review template

lwasser commented 1 month ago

it would b nice to have something like VCR to record all the website updates and put that in pytest for local testing bc rn i'm just using the CI like pytest since i don't have the GITHUB_TOKEN

@sneakers-the-rat what would that look like. i've used i think VCS (casettes?) in a package where we did api things but someone else set it up..

lwasser commented 1 month ago

@sneakers-the-rat this is working really well. There is one other issue. when i run update-review-teams it used to populate the github data from each user's github profile - specifically name given we always have ghusername. but now it doesn't seem to be popoulating that.

Given this is a big refactor should we handle that separtely? or is this a small enough thing to fix in this pr (along with the other tiny thing that is the label name (i commented on this).

Screenshot 2024-07-03 at 4 47 33 PM

thank you for this. I refactored this code from a much bigger mess to pydantic last year and i learned a TON. but i knew it was still really hard to maintain / debug. My brain isn't always great about knowing how to best refactor things !! so i really appreciate this pr.

the test issue idea in the _data folder is so smart. We can then add other examples of issues to process in the future as things come up.

lwasser commented 1 month ago

@all-contributors please add @sneakers-the-rat for code, review

allcontributors[bot] commented 1 month ago

@lwasser

I've put up a pull request to add @sneakers-the-rat! :tada:

sneakers-the-rat commented 1 month ago

There is one other issue. when i run update-review-teams it used to populate the github data from each user's github profile - specifically name given we always have ghusername. but now it doesn't seem to be popoulating that. ... Given this is a big refactor should we handle that separtely? or is this a small enough thing to fix in this pr (along with the other tiny thing that is the label name (i commented on this).

hmm mysterious. seems worth it to fix. let me see

sneakers-the-rat commented 1 month ago

@lwasser here try this - https://github.com/pyOpenSci/pyosMeta/pull/174/commits/8ff2ac35d7715f04375aff76fef3551e10439ebb

looks like the all_active_maintainers was special-cased in the body of that block that handles the username instead of using the role as a generic index. that block was also just duplicated from the single case, so i consolidated them into a single function - could def use some more work bc there's some stuff in there that i'm not sure what it's up to, but hopefully that fixes problem?

lwasser commented 1 month ago

@lwasser here try this - 8ff2ac3

looks like the all_active_maintainers was special-cased in the body of that block that handles the username instead of using the role as a generic index. that block was also just duplicated from the single case, so i consolidated them into a single function - could def use some more work bc there's some stuff in there that i'm not sure what it's up to, but hopefully that fixes problem?

Amazing. thank you. yes that CLI script is really really hacky. i really fought with how to create it in a easy-to-maintain and simple way. This is all running locally now. i'm going to merge and also i'm going to bump your permissions here Jonny.

The one item i'll open an issue about is the data-code-generator piece. I just want to document how that was done. thank you so so much!