-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix: refactor to use pydantic and validation ✨
✨ Refactor: move to pydantic for validation✨
- Loading branch information
Showing
12 changed files
with
826 additions
and
779 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[flake8] | ||
ignore = E203, W503 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,5 +41,5 @@ dmypy.json | |
|
||
token.txt | ||
src/test-model.py | ||
|
||
src/pyosmeta/_version_generated.py | ||
.pdm-build/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,14 @@ | ||
# SPDX-FileCopyrightText: 2023-present Leah Wasser <[email protected]> | ||
# | ||
# SPDX-License-Identifier: MIT | ||
from .contributors import PersonModel, ProcessContributors | ||
from .parse_issues import ProcessIssues, ReviewModel | ||
|
||
# Trick suggested by flake8 maintainer to ensure the imports above don't | ||
# get flagged as being "unused" | ||
__all__ = ( | ||
"ProcessIssues", | ||
"ReviewModel", | ||
"PersonModel", | ||
"ProcessContributors", | ||
) | ||
|
||
try: | ||
from ._version_generated import __version__ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
""" | ||
Script that parses metadata from na issue and adds it to a yml file for the | ||
website. It also grabs some of the package metadata such as stars, | ||
last commit, etc. | ||
Output: packages.yml file containing a list of | ||
1. all packages with accepted reviews | ||
2. information related to the review including reviewers, editors | ||
3. basic package stats including stars, etc. | ||
To run at the CLI: parse_issue_metadata | ||
""" | ||
|
||
# TODO: if we export files we might want packages.yml and then under_review.yml | ||
# thus we'd want to add a second input parameters which was file_name | ||
# TODO: feature - Would be cool to create an "under review now" list as well - | ||
# ideally this could be passed as a CLI argument with the label we want to | ||
# search for | ||
|
||
import pickle | ||
|
||
from pydantic import ValidationError | ||
|
||
from pyosmeta import ProcessIssues, ReviewModel | ||
|
||
# TODO: change the template to ask for date accepted format year-month-day | ||
|
||
|
||
def main(): | ||
process_review = ProcessIssues( | ||
org="pyopensci", | ||
repo_name="software-submission", | ||
label_name="6/pyOS-approved 🚀🚀🚀", | ||
) | ||
|
||
# Get all issues for approved packages - load as dict | ||
issues = process_review.return_response() | ||
accepted_reviews = process_review.parse_issue_header(issues, 45) | ||
|
||
# Update gh metrics via api for all packages | ||
repo_endpoints = process_review.get_repo_endpoints(accepted_reviews) | ||
all_reviews = process_review.get_gh_metrics( | ||
repo_endpoints, accepted_reviews | ||
) | ||
|
||
# Populate model objects with review data + metrics | ||
final_reviews = {} | ||
for key, review in all_reviews.items(): | ||
# First add gh meta to each dict | ||
print("Parsing & validating", key) | ||
try: | ||
final_reviews[key] = ReviewModel(**review) | ||
except ValidationError as ve: | ||
print(key, ":", ve) | ||
|
||
with open("all_reviews.pickle", "wb") as f: | ||
pickle.dump(final_reviews, f) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.