-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Add conda run without output #17982
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
Add conda run without output #17982
Changes from all commits
2037cd7
d6b57dc
4111210
e21243c
0ca6cfc
efe6155
0bd6ddb
d2944bd
11680ae
3c2ae1c
bc2713c
e879116
5ce2665
619a9b7
2c4d9d4
2fdcb6a
355179c
caf5ada
c666e09
2a7b343
df16208
0ba12cb
fee7cbd
51ce1e4
a3a067a
cf146a2
9a1052c
8c5d1c0
bbb3700
efeef07
90a8349
96d5d3c
6f1c112
995f54c
7a36818
d11654b
ac7c626
e167a03
d767c26
7fb6003
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Add support for conda run without output, using `--no-capture-output` flag. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,8 +29,8 @@ import { IInterpreterAutoSelectionService } from '../../interpreter/autoSelectio | |
import { sleep } from '../utils/async'; | ||
import { traceError } from '../../logging'; | ||
|
||
// Minimum version number of conda required to be able to use 'conda run' | ||
export const CONDA_RUN_VERSION = '4.6.0'; | ||
// Minimum version number of conda required to be able to use 'conda run' and '--no-capture--output' option | ||
export const CONDA_RUN_VERSION = '4.9.0'; | ||
|
||
@injectable() | ||
export class PythonExecutionFactory implements IPythonExecutionFactory { | ||
|
@@ -83,6 +83,14 @@ export class PythonExecutionFactory implements IPythonExecutionFactory { | |
} | ||
const processService: IProcessService = await this.processServiceFactory.create(options.resource); | ||
|
||
// Allow parts of the code to ignore conda run. | ||
if (!options.bypassCondaExecution) { | ||
const condaExecutionService = await this.createCondaExecutionService(pythonPath, processService); | ||
if (condaExecutionService) { | ||
return condaExecutionService; | ||
} | ||
} | ||
|
||
const windowsStoreInterpreterCheck = this.pyenvs.isWindowsStoreInterpreter.bind(this.pyenvs); | ||
|
||
return createPythonService( | ||
|
@@ -108,6 +116,7 @@ export class PythonExecutionFactory implements IPythonExecutionFactory { | |
return this.create({ | ||
resource: options.resource, | ||
pythonPath: options.interpreter ? options.interpreter.path : undefined, | ||
bypassCondaExecution: options.bypassCondaExecution, | ||
}); | ||
} | ||
const pythonPath = options.interpreter | ||
|
@@ -117,11 +126,17 @@ export class PythonExecutionFactory implements IPythonExecutionFactory { | |
processService.on('exec', this.logger.logProcess.bind(this.logger)); | ||
this.disposables.push(processService); | ||
|
||
// Allow parts of the code to ignore conda run. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In this PR it seems it's only used for tests, can you elaborate where this is needed? |
||
if (!options.bypassCondaExecution) { | ||
const condaExecutionService = await this.createCondaExecutionService(pythonPath, processService); | ||
if (condaExecutionService) { | ||
return condaExecutionService; | ||
} | ||
} | ||
|
||
return createPythonService(pythonPath, processService, this.fileSystem); | ||
} | ||
|
||
// Not using this function for now because there are breaking issues with conda run (conda 4.8, PVSC 2020.1). | ||
// See https://github.com/microsoft/vscode-python/issues/9490 | ||
public async createCondaExecutionService( | ||
pythonPath: string, | ||
processService?: IProcessService, | ||
|
@@ -144,6 +159,7 @@ export class PythonExecutionFactory implements IPythonExecutionFactory { | |
procService.on('exec', this.logger.logProcess.bind(this.logger)); | ||
this.disposables.push(procService); | ||
} | ||
|
||
return createPythonService( | ||
pythonPath, | ||
procService, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,7 +14,7 @@ export class Flake8 extends BaseLinter { | |
|
||
protected async runLinter(document: TextDocument, cancellation: CancellationToken): Promise<ILintMessage[]> { | ||
const messages = await this.run( | ||
['--format=%(row)d,%(col)d,%(code).1s,%(code)s:%(text)s', document.uri.fsPath], | ||
['--format= %(row)d,%(col)d,%(code).1s,%(code)s:%(text)s', document.uri.fsPath], | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What does adding a space here (and in src/client/linters/pycodestyle.ts) do? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it makes all the value inside "", "--format=%(row)d,%(col)d,%(code).1s,%(code)s:%(text)s" There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It turns the single quote into double quotes? Could you explain how adding a space in the argument does that? I don't understand 😅 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not very sure, but internally when you pass a parameter by array to the run function, if it has any special character or spaces it renders it with "". The same thing happens with path directory, when the name has a space, it appears in the console with "". There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. that happens because we quote arguments if there is a space in them. We have code that adds quote if the path or arguments have some characters. |
||
document, | ||
cancellation, | ||
); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -296,7 +296,7 @@ suite('Installer', () => { | |
} | ||
callback({ stdout: '' }); | ||
}); | ||
await installer.isInstalled(product, resource); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What happens if you do not bypass conda execution here, ideally I would expect the tests to pass even in that case. Can you attempt to fix the test instead of using this option? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The tests were throwing a timeout error, I tried to fix it but it wasn't consistent and it was throwing another error, that's why I put the timeout. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I assume this is on CI as tests seem to be passing locally for me. It's fine to put the timeout or even increase timeout, but I think we shouldn't need to bypass conda execution. It's weird as conda execution should not even be used if we're not using a conda interpreter. |
||
await installer.isInstalled(product, resource, true); | ||
await checkInstalledDef.promise; | ||
} | ||
getNamesAndValues<Product>(Product).forEach((prod) => { | ||
|
@@ -333,7 +333,7 @@ suite('Installer', () => { | |
checkInstalledDef.resolve(); | ||
} | ||
}); | ||
await installer.install(product); | ||
await installer.install(product, undefined, undefined, undefined, true); | ||
await checkInstalledDef.promise; | ||
} | ||
getNamesAndValues<Product>(Product).forEach((prod) => { | ||
|
Uh oh!
There was an error while loading. Please reload this page.