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

Re-factor code python execution framework #345

Merged
merged 115 commits into from
Dec 5, 2017

Conversation

DonJayamanne
Copy link

  • Ensure we have a generic way of executing python code, modules with support for env variables
  • Improvements to gulp to speed up compilation and improved dev experience
  • Added dependency injection
  • Modifications to unit tests framework (running pytests, nose, etc in extension) to make use of the new python execution engine along with DI
  • Code refactoring
    • Move types into types.ts file
    • Ensure all promises have exception handlers
  • Use latest version of typescript

octref and others added 30 commits November 3, 2017 13:11
* 'master' of https://github.com/Microsoft/vscode-python:
  Fixes #56 list all environments (#219)
  Fixes #57 Disable activation on debugging (#220)
  Fixes #26 Do not run linters when linters are disabled (#222)
* upstream/master:
  Fix typo in README.md (#252)
  Disable linter without workspaces (#241)
@brettcannon
Copy link
Member

Is this all the work instead of just the tests?

@DonJayamanne
Copy link
Author

Yes this is, but scooped just around the feature support of running pytest, nose and unit test in the extension,
Other PRs will follow with changes around formation, linting and intellisense and musc (sort imports, etc).

@@ -47,6 +47,26 @@
"isDefault": true
}
},
{
// Task that will replace 'Compile' and 'Hygiene', after having been battle-tested.
Copy link
Member

Choose a reason for hiding this comment

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

"after having been" -> "after being"

Copy link

Choose a reason for hiding this comment

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

Sorry my linguistic curiosity, but could you please explain the difference to a non-native speaker? "after having been" sounded fine to me...

Copy link
Author

Choose a reason for hiding this comment

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

Yup, Bretts suggestion, makes sense to me.

@@ -1,155 +1,18 @@
/*---------------------------------------------------------------------------------------------
Copy link
Member

Choose a reason for hiding this comment

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

Why the removal of the copyright notice?

Copy link
Author

Choose a reason for hiding this comment

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

doh

Copy link
Author

Choose a reason for hiding this comment

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

Fixed


/**
* An interface for a JavaScript object that
* acts a dictionary. The keys are strings.
Copy link
Member

Choose a reason for hiding this comment

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

"acts a" -> "acts as a"

* An interface for a JavaScript object that
* acts a dictionary. The keys are strings.
*/
export interface IStringDictionary<V> {
Copy link
Member

Choose a reason for hiding this comment

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

TS doesn't support this by default on the object type?

Copy link
Author

Choose a reason for hiding this comment

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

But that won't be strongly typed, this ensures properties are strings and values are of type V.


resolve(messages);
return this.run(pylamaPath, pylamaArgs.concat(['--format=parsable', document.uri.fsPath]), document, this.getWorkspaceRootPath(document), cancellation, REGEX).then(messages => {
// All messages in pylama are treated as warnings for now
Copy link
Member

Choose a reason for hiding this comment

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

Missing a period.

}
// set all diagnostics found in this pass, as this method always clears existing diagnostics.
this.diagnosticCollection.set(document.uri, diagnostics);
// Build the message and suffix the message with the name of the linter used
Copy link
Member

Choose a reason for hiding this comment

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

Period.

this.diagnosticCollection.set(document.uri, diagnostics);
// Build the message and suffix the message with the name of the linter used
msgs.forEach(d => {
// ignore magic commands from jupyter
Copy link
Member

Choose a reason for hiding this comment

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

Capitalize and period.

diagnostics.push(createDiagnostics(d, document));
});

// Limit the number of messages to the max value
Copy link
Member

Choose a reason for hiding this comment

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

Period.

// We need to display the path relative to the current directory.
fileName = fileName.substring(rootDirectory.length + 1);
// we don't care about the compiled file.
if (path.extname(fileName) === '.pyc') {
Copy link
Member

Choose a reason for hiding this comment

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

Do we need to worry about .pyo files as well?

Copy link
Author

Choose a reason for hiding this comment

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

Good pick.

procService.onExecObservable((file, args, options, callback) => {
if (args.length > 1 && args[0] === '-c' && args[1].includes('import unittest') && args[1].includes('loader = unittest.TestLoader()')) {
callback({
// Ensure any spaces added during code formatting or the like are removed
Copy link
Member

Choose a reason for hiding this comment

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

Period.

@DonJayamanne
Copy link
Author

@brettcannon fixed.

* upstream/master:
  Fix package.json (#347)
@@ -178,7 +179,7 @@ export class PythonSettings extends EventEmitter implements IPythonSettings {
}
// tslint:disable-next-line:function-name
public static dispose() {
if (!IS_TEST_EXECUTION) {
if (!isTestExecution()) {

Choose a reason for hiding this comment

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

Alternative might be to define IPythonSettingsTest with additional test methods so regular code does not see test functions. Or derive a class like PythonSettingsTest with test methods and provide different factories to test and regular code.

Just a thought.

Copy link
Author

Choose a reason for hiding this comment

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

Totally agreed, unfortunately that's a bigger chunk of work.
The DI layer in this PR, and the existing IPythonSettings interface should help with this (its just a matter of refactoring stuff).
However I'd defer that to a later PR

@DonJayamanne DonJayamanne merged commit 7efb558 into microsoft:master Dec 5, 2017
@DonJayamanne DonJayamanne deleted the FixCodeExec branch December 12, 2017 21:21
DonJayamanne added a commit that referenced this pull request Dec 14, 2017
* upstream/master:
  #34, #110 - suppress Intellisense in strings and comments (#339)
  Re-factor code python execution framework  (#345)
@lock lock bot locked as resolved and limited conversation to collaborators Jul 31, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants