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

Patch lifecycle to avoid interacting with project boards overly #375

Merged
merged 14 commits into from
Sep 12, 2024
2 changes: 1 addition & 1 deletion .github/workflows/lifecycle-backlog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ jobs:

- name: Run lifecycle processing script
env:
GH_TOKEN: ${{ secrets.GH_DANGERBOT_TOKEN_LIMITED }}
GH_TOKEN: ${{ secrets.QCA_DATASET_SUBMISSION_PAT }}
QCA_USER: ${{ secrets.QCA_USER }}
QCA_KEY: ${{ secrets.QCA_KEY }}
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lifecycle-set-priority-computetag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jobs:

- name: Run lifecycle processing script
env:
GH_TOKEN: ${{ secrets.GH_DANGERBOT_TOKEN_LIMITED }}
GH_TOKEN: ${{ secrets.QCA_DATASET_SUBMISSION_PAT }}
QCA_USER: ${{ secrets.QCA_USER }}
QCA_KEY: ${{ secrets.QCA_KEY }}
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lifecycle-submission.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ jobs:

- name: Run lifecycle processing script
env:
GH_TOKEN: ${{ secrets.GH_DANGERBOT_TOKEN_LIMITED }}
GH_TOKEN: ${{ secrets.QCA_DATASET_SUBMISSION_PAT }}
QCA_USER: ${{ secrets.QCA_USER }}
QCA_KEY: ${{ secrets.QCA_KEY }}
run: |
Expand Down
52 changes: 35 additions & 17 deletions management/lifecycle.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,25 +133,36 @@ def execute_state(self, board=None, states=None,
"""Based on current state of the PR, perform appropriate actions.

"""
if board is None:
board = _get_full_board(self.repo)
import projectsv2

pr_card, pr_state = self._get_board_card_state(board, self.pr)
# we're going to give up on evolving boards entirely for now
if board is None:
board = projectsv2._get_full_board()
# look for the card
pr_state = None
pr_card = None
for col_name, cards in board.items():
for card in cards:
if int(card.pr_number) == int(self.pr.number):
pr_card = card
pr_state = col_name

# pr_card, pr_state = self._get_board_card_state(board, self.pr)
# if card not on board, then it starts in the Backlog
if pr_state is None:
pr_state = self.set_backlog()
# skip this completely, we can't do it
# if pr_state is None:
# pr_state = self.set_backlog()

# reload board, since we just added this card
board = _get_full_board(self.repo)
pr_card, pr_state = self._get_board_card_state(board, self.pr)
# board = _get_full_board(self.repo)
# pr_card, pr_state = self._get_board_card_state(board, self.pr)

# exit early if states specified, and this PR is not
# in one of those
if states is not None:
if pr_state not in states:
return

if pr_state == "Backlog":
return self.execute_backlog(pr_card, pr_state)
elif pr_state == "Queued for Submission":
Expand Down Expand Up @@ -199,7 +210,8 @@ def execute_backlog(self, pr_card, pr_state):
comment = f"""
## Lifecycle - Backlog

Merged dataset moved from "Backlog" to "Queued for Submission".
Project boards are not working as expected.
However, please consider this queued for submission.

"""

Expand All @@ -209,11 +221,11 @@ def execute_backlog(self, pr_card, pr_state):
# submit comment
self.pr.create_issue_comment(comment)

self.evolve_state(pr_card, pr_state, "Queued for Submission")
# self.evolve_state(pr_card, pr_state, "Queued for Submission")

return {"new_state": "Queued for Submission"}
else:
return {"new state": "Backlog"}
# return {"new_state": "Queued for Submission"}
# else:
# return {"new state": "Backlog"}

def execute_queued_submit(self, pr_card, pr_state):
"""Submit datasets, perhaps with some retry logic.
Expand All @@ -231,8 +243,11 @@ def execute_queued_submit(self, pr_card, pr_state):
results.append(ct.execute_queued_submit())

new_state = self.resolve_new_state(results)
if new_state is not None:
self.evolve_state(pr_card, pr_state, new_state)
# if new_state is not None:
# self.evolve_state(pr_card, pr_state, new_state)

# comment status on PR
self.pr.create_issue_comment(f"## Current status - {new_state}\n\n Consider manually moving this.")

def execute_errorcycle(self, pr_card, pr_state,
reset_errors=False,
Expand All @@ -259,8 +274,11 @@ def execute_errorcycle(self, pr_card, pr_state,
set_computetag=set_computetag))

new_state = self.resolve_new_state(results)
if new_state is not None:
self.evolve_state(pr_card, pr_state, new_state)
# if new_state is not None:
# self.evolve_state(pr_card, pr_state, new_state)

# comment status on PR
self.pr.create_issue_comment(f"## Current status - {new_state}\n\n Consider manually moving this.")

if new_state == "Archived/Complete":
for dataset in self.datasets:
Expand Down