-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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 #1147 (search environments.txt file for conda environments) #1240
Conversation
return getInterpreterDisplayName(pythonPath) | ||
.catch(() => defaultValue); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing a newline.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed.
private locators: IInterpreterLocatorService[] = []; | ||
constructor(private virtualEnvMgr: VirtualEnvironmentManager) { | ||
const versionService = new InterpreterVersionService(); | ||
// The order of the services is important |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is not ending comments in a period a thing in the TypeScript world? (Serious question because it's definitely a thing to always use a period in Python.) Otherwise I would definitely use an exclamation point here. 😄 (And if you don't have a preference then I vote for putting in periods to know that a comment definitely is finished and not accidentally incomplete.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is not ending comments in a period a thing in the TypeScript world
Never heard of this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now i have
} | ||
public getInterpreters() { | ||
if (this.interpreters.length > 0) { | ||
return Promise.resolve(this.interpreters); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No async
/await
yet in the version of TypeScript that VS Code uses?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Old habbits die hard, async await is available and used.
I'm using promises as well, in most of these places as we I to maximize parallelism... (i.e. return promises) and await on ALL where possible
}, [])) | ||
.then(interpreters => this.interpreters = interpreters); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing a newline.
.then(interpreters => _.flatten(interpreters)) | ||
.then(items => items.map(fixInterpreterDisplayName)) | ||
.then(items => items.map(fixInterpreterPath)) | ||
.then(items => items.reduce<PythonInterpreter[]>((prev, current) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The name prev
is misleading since it's a collection and not a single item like current
. Maybe rename it accum
or accumulator
(typical name from functional programming)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
agreed
* However all these environments seem to be listed in the environments.txt file (confirmed on windows and linux) | ||
* @export | ||
* @class CondaEnvFileProvider | ||
* @implements {IInterpreterLocatorService} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What are these comments for? They seem to (be trying to) mirror what the code already says so I'm wondering what the benefit is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought it would be best to write the comments out. Else one might ask whey use environments.txt as well as conda info --env
. This makes it obvious that environments.txt can contain additional items. Comment removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the ambiguity of that comment, I meant the @export
comments and such more than the block comments. (I totally support block comments 😄 )
* Environments created using the command 'conda create --p python=x.x' are not returned by the above command | ||
* However all these environments seem to be listed in the environments.txt file (confirmed on windows and linux) | ||
* @export | ||
* @class CondaEnvFileProvider |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't match the CondaEnvFileService
name below.
}) | ||
.then(promises => Promise.all(promises)) | ||
.then(interpreterPaths => { | ||
return interpreterPaths.filter(item => item.trim().length > 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it worth keeping the paths trimmed instead of tossing the trimmed result? I.e.
interpreterPaths.map(String.prototype.trim).filter(item => item.length > 0);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed
src/client/interpreter/helpers.ts
Outdated
if (stdout.length === 0) { | ||
return ''; | ||
} | ||
const lines = stdout.split(/\r?\n/g).filter(line => line.trim().length > 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason not to keep the trimmed version?
return this.versionService.getVersion(interpreter, path.basename(interpreter)) | ||
.then(version => { | ||
// Strip company name from version | ||
const startOfCompanyName = version.indexOf(`:: ${AnacondaCompanyName}`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is going to be tricky once Anaconda Co starts to use that name instead of Continuum Analytics.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will add both company names. I'm not too concerned even if it doesn't work as its merely a formatting issue.
environments.txt file returns conda environments not returned by the command
conda info --envs