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 submission process #701

Merged

Conversation

frankharkins
Copy link
Member

@frankharkins frankharkins commented Apr 29, 2024

Summary

The submission process was broken as some entries in the issue template were being ignored by the parser. This PR fixes that and makes the submission process more robust so similar issues don't occur in the future.

Details

Currently, to add a new field to the issue template, you need to edit four different files to make sure the field makes it through to the database. This PR avoids that by explicitly mapping field IDs in the issue template to attributes of the repository model and writing the entry immediately. After this change, you only need to edit the issue template and the repository model.

I've also added a test check the fields in the issue template match fields in the repository model.

@frankharkins frankharkins marked this pull request as ready for review April 30, 2024 15:17
Copy link
Collaborator

@Eric-Arellano Eric-Arellano left a comment

Choose a reason for hiding this comment

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

Thanks!

frankharkins and others added 3 commits April 30, 2024 21:13
Co-authored-by: Eric Arellano <14852634+Eric-Arellano@users.noreply.github.com>
* Try to use consistent naming rather than calling everything "sections"
* Make the _label_to_id function clearer by just having it transform
  string to string
* Other minor simplifications
website=website,
)
md_sections = issue_formatted.split("### ")[1:]
args = dict(_parse_section(s) for s in md_sections)
Copy link
Member Author

Choose a reason for hiding this comment

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

defaultdict isn't needed here as all args have default values

@frankharkins frankharkins requested a review from Eric-Arellano May 1, 2024 14:35
Copy link
Collaborator

@Eric-Arellano Eric-Arellano left a comment

Choose a reason for hiding this comment

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

This PR has gotten a bit involved - might be worth splitting it out into two PRs if possible.


def _label_to_id(label: str) -> str:
"""Given a fields "label", find its `id` from the issue template"""
if not hasattr(_label_to_id, "map"):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Imo this is confusing storing the value on the function object itself. Instead, I recommend using a global constant:

LABELs_TO_IDS = _load_labels()

def _load_labels() -> dict[...]:
   ...

Rather than having _label_to_id as a helper function, you can inline the call in parse_section to be LABELs_TO_IDS[label].

--

Edit: another alternative is to define the variable inside parse_submission_issue and then pass it into parse_section. That's probably clearer to avoid global state.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks! I went with the latter. And I see your point about it getting involved but I'm not sure how to cleanly split into two PRs.

frankharkins and others added 2 commits May 1, 2024 18:06
Co-authored-by: Eric Arellano <14852634+Eric-Arellano@users.noreply.github.com>
Copy link
Collaborator

@Eric-Arellano Eric-Arellano left a comment

Choose a reason for hiding this comment

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

Thanks! Great comment in parse_submission_issue

frankharkins and others added 3 commits May 1, 2024 18:51
Co-authored-by: Eric Arellano <14852634+Eric-Arellano@users.noreply.github.com>
Co-authored-by: Eric Arellano <14852634+Eric-Arellano@users.noreply.github.com>
@frankharkins
Copy link
Member Author

Thanks!

@frankharkins frankharkins enabled auto-merge (squash) May 1, 2024 17:52
@frankharkins frankharkins merged commit 4e298ff into Qiskit:main May 1, 2024
4 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.

2 participants