Skip to content

Commit

Permalink
fix: make sure eic roles are populated correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
lwasser committed Nov 22, 2024
1 parent fb5e6f1 commit 1e187f7
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 17 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

### Fixed

* Fix: Eix field not processing correctly (@lwasser, #234)
* Fix: Updated documentation throughout with a focus on how a user's name is accessed and updated (@lwasser)
* Fix: ReviewUser object name can be optional. There are times when we don't have the actual person's name only the GH username (@lwasser)

Expand Down
35 changes: 20 additions & 15 deletions src/pyosmeta/cli/update_review_teams.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,23 +148,28 @@ def main():
for role in contrib_types.keys():
user: list[ReviewUser] | ReviewUser = getattr(review, role)

# Handle lists or single users separately
if isinstance(user, list):
for i, a_user in enumerate(user):
a_user, contribs = process_user(
a_user, role, pkg_name, contribs, process_contribs
# Eic is a newer field, so in some instances it will be empty
# if it's empty print a message noting the data are missing
if user:
# Handle lists or single users separately
if isinstance(user, list):
for i, a_user in enumerate(user):
a_user, contribs = process_user(
a_user, role, pkg_name, contribs, process_contribs
)
# Update individual user in reference to issue list
user[i] = a_user
elif isinstance(user, ReviewUser):
user, contribs = process_user(
user, role, pkg_name, contribs, process_contribs
)
setattr(review, role, user)
else:
raise TypeError(
"Keys in the `contrib_types` map must be a `ReviewUser` or `list[ReviewUser]` in the `ReviewModel`"
)
# Update individual user within the user list
user[i] = a_user
elif isinstance(user, ReviewUser):
user, contribs = process_user(
user, role, pkg_name, contribs, process_contribs
)
setattr(review, role, user)
else:
raise TypeError(
"Keys in the `contrib_types` map must be a `ReviewUser` or `list[ReviewUser]` in the `ReviewModel`"
)
print(f"I can't find a username for {role}. Moving on.")

# Export to yaml
contribs_ls = [model.model_dump() for model in contribs.values()]
Expand Down
13 changes: 13 additions & 0 deletions src/pyosmeta/contributors.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,20 @@ def __init__(self, github_api: GitHubAPI, json_files: List) -> None:
"github_username",
]

"""A dictionary that maps a category type found in our peer review
submission template to the roles and role categories that a contributor
should have populated associated with the review in the contributors.yml
example
reviewers is in the software submission template like this:
reviewers: @username, @username2
Being a reviewer maps to two roles in the users contributions to
pyOpenSci: reviewer and peer-review
packages_reviewed is another item in the contributors file that lists
all of the packages that user has reviewed. So if they ar e
"""
self.contrib_types = {
"eic": ["packages_eic", ["eic", "peer-review"]],
"reviewers": ["packages_reviewed", ["reviewer", "peer-review"]],
"editor": ["packages_editor", ["editor", "peer-review"]],
"submitting_author": [
Expand Down
2 changes: 0 additions & 2 deletions src/pyosmeta/file_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,6 @@ def export_yaml(filename: str, data_list: list):
yaml.dump(data_list, file)


# TODO: Double check - i may be able to combine this with the other clean
# function created
def clean_string(astr: str) -> str:
"""
Clean - remove strings starting with "*id0" and "[]".
Expand Down
3 changes: 3 additions & 0 deletions src/pyosmeta/models/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ class PersonModel(BaseModel, UrlValidatorMixin):
)
board: Optional[bool] = False
contributor_type: Set[str] = set()
packages_eic: Set[str] = set()
packages_editor: Set[str] = set()
packages_submitted: Set[str] = set()
packages_reviewed: Set[str] = set()
Expand All @@ -143,6 +144,7 @@ def validate_bool_fields(cls, v: Any) -> bool:
return False

@field_validator(
"packages_eic",
"packages_reviewed",
"packages_submitted",
"packages_editor",
Expand Down Expand Up @@ -176,6 +178,7 @@ def add_unique_value(self, attr_name: str, values: Union[str, list[str]]):
raise ValueError(f"{attr_name} is not a set attribute")

@field_serializer(
"packages_eic",
"packages_reviewed",
"packages_submitted",
"packages_editor",
Expand Down

0 comments on commit 1e187f7

Please sign in to comment.