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

fix #1147 (search environments.txt file for conda environments) #1240

Merged
merged 9 commits into from
Sep 26, 2017

Conversation

DonJayamanne
Copy link
Owner

environments.txt file returns conda environments not returned by the command conda info --envs

return getInterpreterDisplayName(pythonPath)
.catch(() => defaultValue);
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Missing a newline.

Copy link
Owner Author

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
Copy link
Contributor

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.)

Copy link
Owner Author

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.

Copy link
Owner Author

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);
Copy link
Contributor

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?

Copy link
Owner Author

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);
}
}
Copy link
Contributor

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) => {
Copy link
Contributor

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)?

Copy link
Owner Author

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}
Copy link
Contributor

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.

Copy link
Owner Author

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.

Copy link
Contributor

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
Copy link
Contributor

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);
Copy link
Contributor

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);

Copy link
Owner Author

Choose a reason for hiding this comment

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

Agreed

if (stdout.length === 0) {
return '';
}
const lines = stdout.split(/\r?\n/g).filter(line => line.trim().length > 0);
Copy link
Contributor

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}`);
Copy link
Contributor

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.

Copy link
Owner Author

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.

@DonJayamanne DonJayamanne merged commit b46ae28 into master Sep 26, 2017
@DonJayamanne DonJayamanne deleted the 1147envfile branch October 11, 2017 18:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants