Skip to content

Make the monitoring command slightly simpler and handle being called on any variant analysis#1690

Merged
robertbrignull merged 3 commits intomainfrom
robertbrignull/handle_states_monitoring
Nov 2, 2022
Merged

Make the monitoring command slightly simpler and handle being called on any variant analysis#1690
robertbrignull merged 3 commits intomainfrom
robertbrignull/handle_states_monitoring

Conversation

@robertbrignull
Copy link
Copy Markdown
Contributor

This PR aims to make the variant analysis monitoring command able to handle all states and also be slightly cleaner in its logic. I don't think any of the changes in this PR are critical, but I think they are all improvements.

The changes made are:

  • Instead of firing _onVariantAnalysisChange from three different places under various conditions, fire it from one place and always fire it in every loop right after getting the updated variant analysis summary.
    • I'm not sure why we fired the event before the loop. This is before we fetched the new updated state so we're just emitting the old state that the monitor was passed when it started up. In the case of rehydrating query history this state could be very old. My only thought is that it's to ensure that the event always fires at least once. Ignoring a HTTP error I think this PR still does that so I think that's fine.
  • Try to available download results regardless of if the variant analysis has a failure reason. I'm not sure if this matters as possibly we only set a failure reason for errors that happen before triggering the workflow run, but the idea is to always download available results regardless of other errors. If there are some results available then we should show them to the user.
  • Reduces the VariantAnalysisMonitorResult to only the cases that we actually use, and make it fit better to the variant analysis summary status.
    • There were various cases in that type that we never used, so it seems sensible to remove them.
    • There were other cases that I didn't really understand. What does it mean for the monitor to "complete unsuccessfully"?
    • This type is only used for this one return value, and in the production code this return value is not used. It's only read from tests as a way of verifying the behaviour of the monitoring command.

Checklist

  • CHANGELOG.md has been updated to incorporate all user visible changes made by this pull request.
  • Issues have been created for any UI or other user-facing changes made by this pull request.
  • [Maintainers only] If this pull request makes user-facing changes that require documentation changes, open a corresponding docs pull request in the github/codeql repo and add the ready-for-doc-review label there.

@robertbrignull robertbrignull requested a review from a team as a code owner November 1, 2022 12:19
Copy link
Copy Markdown
Member

@koesie10 koesie10 left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for cleaning this up!

Since you mention the VariantAnalysisMonitorStatus is only used in tests, would it make sense to remove the return type completely and rely on the actual behaviour in the tests, rather than on the return type? It now seems like we're testing something that doesn't actually get used.

@robertbrignull
Copy link
Copy Markdown
Contributor Author

Since you mention the VariantAnalysisMonitorStatus is only used in tests, would it make sense to remove the return type completely and rely on the actual behaviour in the tests, rather than on the return type? It now seems like we're testing something that doesn't actually get used.

I agree with you, but I didn't want to go too far with changing things in this PR. I'll open a tech-debt issue about it and we can discuss there.

function processApiStatus(status: ApiVariantAnalysisStatus, failureReason: string | undefined): VariantAnalysisStatus {
if (status === 'in_progress') {
return VariantAnalysisStatus.InProgress;
} else if (failureReason !== undefined) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is this different than if (failureReason) ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It is technically different because the empty string is falsy. Practically I'm not sure it'll make a difference.

If the failure message is set to the empty string that's not great, but I'd say it's a bug earlier in the system rather than here. So here I generally prefer to be explicit about checking for undefined rather than using the implicit conversion to a boolean.

Copy link
Copy Markdown
Contributor

@elenatanasoiu elenatanasoiu left a comment

Choose a reason for hiding this comment

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

Had one question, but looks great!

@robertbrignull robertbrignull merged commit 36754a8 into main Nov 2, 2022
@robertbrignull robertbrignull deleted the robertbrignull/handle_states_monitoring branch November 2, 2022 09:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants