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

Sort available environments by assumed usefulness #16559

Merged
merged 15 commits into from
Jul 8, 2021

Conversation

kimadeline
Copy link

For #16520

@kimadeline kimadeline self-assigned this Jun 24, 2021
@kimadeline kimadeline marked this pull request as ready for review June 24, 2021 20:09
@karthiknadig karthiknadig self-requested a review July 6, 2021 19:02
Copy link
Member

@karthiknadig karthiknadig left a comment

Choose a reason for hiding this comment

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

Other than the path comparison thing this looks good.


switch (envType) {
case EnvironmentType.Venv: {
if (workspacePath.length > 0 && environment.envPath?.startsWith(workspacePath)) {
Copy link
Member

Choose a reason for hiding this comment

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

Paths probably should be normalized before comparing.

Copy link

Choose a reason for hiding this comment

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

This helper should be useful,

/**
* Returns true if given file path exists within the given parent directory, false otherwise.
* @param filePath File path to check for
* @param parentPath The potential parent path to check for
*/
export function isParentPath(filePath: string, parentPath: string): boolean {
return normCasePath(filePath).startsWith(normCasePath(parentPath));
}

Copy link

@karrtikr karrtikr Jul 7, 2021

Choose a reason for hiding this comment

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

EnvTypeHeuristic.Local can also be of other types, including Unknown. I think we should be doing the check of whether an env is local prior to checking env types.

Copy link
Author

Choose a reason for hiding this comment

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

EnvTypeHeuristic.Local can also be of other types, including Unknown. I think we should be doing the check of whether an env is local prior to checking env types.

So from what I understand you are suggesting that any environment path that has the workspace as the parent path should be considered local? How can an environment end up categorized as Unknown again?

I think that if we failed to identify an environment it shouldn't be prioritized it over others.

Copy link

Choose a reason for hiding this comment

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

you are suggesting that any environment path that has the workspace as the parent path should be considered local?

Yes

How can an environment end up categorized as Unknown again?

If none of our environments type checks matches, a local environment can be classified as Unknown.

But practically speaking it shouldn't happen. So maybe we shouldn't worry about the Unknown case in local envs.

I think that if we failed to identify an environment it shouldn't be prioritized it over others.

Or we can make an exception case as you suggested here.

Copy link
Author

Choose a reason for hiding this comment

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

Besides Venv and Unknown, which other environment types could possibly be categorized as local?

Copy link
Member

Choose a reason for hiding this comment

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

Poetry, conda can both have local and global versions.

Copy link

@karrtikr karrtikr Jul 7, 2021

Choose a reason for hiding this comment

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

Virtualenv, Pipenv can be in there as well. Basically I don't think we should define local envs based on kind.

Copy link

@karrtikr karrtikr left a comment

Choose a reason for hiding this comment

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

LGTM otherwise

src/client/common/experiments/groups.ts Show resolved Hide resolved

switch (envType) {
case EnvironmentType.Venv: {
if (workspacePath.length > 0 && environment.envPath?.startsWith(workspacePath)) {
Copy link

@karrtikr karrtikr Jul 7, 2021

Choose a reason for hiding this comment

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

EnvTypeHeuristic.Local can also be of other types, including Unknown. I think we should be doing the check of whether an env is local prior to checking env types.

@kimadeline kimadeline requested a review from karrtikr July 7, 2021 20:32
Copy link

@karrtikr karrtikr left a comment

Choose a reason for hiding this comment

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

LGTM

@kimadeline kimadeline added the skip package*.json package.json and package-lock.json don't both need updating label Jul 7, 2021
@kimadeline kimadeline merged commit a0f0337 into microsoft:main Jul 8, 2021
@kimadeline kimadeline deleted the 16520-sort-environments branch November 3, 2021 16:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
skip package*.json package.json and package-lock.json don't both need updating
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants