Skip to content

Download variant analysis results#1559

Merged
elenatanasoiu merged 11 commits intomainfrom
elenatanasoiu/download-variant-analysis-results
Oct 5, 2022
Merged

Download variant analysis results#1559
elenatanasoiu merged 11 commits intomainfrom
elenatanasoiu/download-variant-analysis-results

Conversation

@elenatanasoiu
Copy link
Copy Markdown
Contributor

@elenatanasoiu elenatanasoiu commented Sep 30, 2022

🚨 Please review this PR commit-by-commit.

What

Follow-up from this PR where we introduced a monitor to check on the status of the variant analysis.

We'd like to auto-download results from the variant analysis as they become ready.

Why

Based on a previous discussion while implementing the variant analysis monitor, we decided that we'd like to trigger separate commands for actually downloading the results rather than performing it in the same process as the monitor.

The reason for this is that it would delay the polling and isn't really connected to what the monitor is supposed to do.

Future

In a separate PR, we'll also change the monitor and manager in order to emit events to the UI. These will be the various states of a download.

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.

@elenatanasoiu elenatanasoiu force-pushed the elenatanasoiu/download-variant-analysis-results branch from f3cdd7e to 3633f71 Compare September 30, 2022 18:09
@elenatanasoiu elenatanasoiu marked this pull request as ready for review October 3, 2022 08:16
@elenatanasoiu elenatanasoiu requested review from a team as code owners October 3, 2022 08:16
return {
accessMismatchRepos: createMockSkippedRepoGroup(),
noCodeqlDbRepos: createMockSkippedRepoGroup(),
notFoundRepos: createMockSkippedRepoGroup(),
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should we ensure that this matches the actual data we receive and make the notFoundRepos mock separate/ The notFoundRepos does not have an id or private, while all the other groups will always have both.

Copy link
Copy Markdown
Contributor Author

@elenatanasoiu elenatanasoiu Oct 4, 2022

Choose a reason for hiding this comment

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

I wonder why this wasn't caught by our type system. I've added a separate method to create this: 7dc5eeb

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It seems like we don't have a different type for the not found repos in the shared VariantAnalysis, while we do have a separate type in the gh-api VariantAnalysis. It might make sense to create a separate type for it, but that's independent of this PR.

Comment thread extensions/ql-vscode/src/remote-queries/variant-analysis-manager.ts
Comment on lines +36 to +38
cancellationToken = {
isCancellationRequested: false
} as unknown as CancellationToken;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Since this is running in VSCode, could we use a real cancellation token instead using the CancellationTokenSource?

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.

Sure! It does seem a bit shady to use unknown. Have added the change here.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks! Does it make sense to not mock the cancellation token at all? Instead of mocking the cancellation token source, can we just call new CancellationTokenSource()?

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.

Ah I see what you mean! I'll take a look at this in a separate issue.

Comment thread extensions/ql-vscode/src/remote-queries/variant-analysis-monitor.ts Outdated
In a previous PR [1] we introduced factories for generating variant analyses
(and their associated objects) that were returned from the API.

Let's also introduce factories for generating their VSCode equivalent.

We can immediately use them for generating a VariantAnalysis object for the
monitor tests.

[1]: #1545
This will download the result for a particular repo by making a call
to the download URL via octokit.
This method will be called from the VariantAnalysisMonitor once
a new repo has been scanned.

It will then perform an API request to get the repo task for it,
which will contain an `artifact_url`.

Finally it will use the API method we introduced in the previous commit
to download the result for the repo and then save it on disk.
In the next commit, we'll also import `commands`.
This introduces a new `autoDownloadVariantAnalysisResult` command which
will be called by the VariantAnalysisMonitor every time it detects a new
repo has been scanned.

In turn, this will use the `autoDownloadVariantAnalysisResult` method
which we defined in an earlier commit on the VariantAnalysisManager.
This won't have an `id` field. We initially generated this the same
way we did for all other skipped repos, but this one is special because
it's only providing the fullName field, while the others also provide
`id` and `private`.
@elenatanasoiu elenatanasoiu force-pushed the elenatanasoiu/download-variant-analysis-results branch from 74f03ed to 77c20cf Compare October 4, 2022 15:36
@elenatanasoiu elenatanasoiu force-pushed the elenatanasoiu/download-variant-analysis-results branch from 77c20cf to f56f017 Compare October 4, 2022 16:07
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.

There's still one outstanding comment about creating a new CancellationTokenSource instead of mocking it, but that can also be done in a follow-up PR.

@elenatanasoiu
Copy link
Copy Markdown
Contributor Author

Thanks @koesie10! I've created an issue for that as well.

@elenatanasoiu elenatanasoiu merged commit ab9cf46 into main Oct 5, 2022
@elenatanasoiu elenatanasoiu deleted the elenatanasoiu/download-variant-analysis-results branch October 5, 2022 10:43
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.

2 participants