Repository navigation
Some fixes for nightly - #11802
Some fixes for nightly#11802
Conversation
Fix functional tests to always use a valid interpreter (instead of just one with jupyter)
| - script: | | ||
| call activate base | ||
| conda install --quiet -y --file build/ci/conda_base.yml | ||
| call conda install --quiet -y --file build/ci/conda_base.yml |
There was a problem hiding this comment.
call [](start = 6, length = 4)
Seems that on windows, conda will create a new command shell if you call it directly. This actually prevents the other commands after this point from running. This was the first bug in our flake tests.
| jupyter | ||
| numpy | ||
| matplotlib | ||
| pip |
There was a problem hiding this comment.
Making sure pip comes from the conda directory
| yapf | ||
| pylint | ||
| pycodestyle | ||
| prospector |
There was a problem hiding this comment.
I don't believe this is used anywhere and it was failing to install anyway.
| public async createTemporaryFile(suffix: string): Promise<TemporaryFile> { | ||
| return this.utils.tmp.createFile(suffix); | ||
| public async createTemporaryFile(suffix: string, mode?: number): Promise<TemporaryFile> { | ||
| return this.utils.tmp.createFile(suffix, mode); |
There was a problem hiding this comment.
added an optional mode parameter to try and fix problems with the direct kernel on windows
| ? await this.notebookProvider.getOrCreateNotebook({ identity: identity.resource, metadata }) | ||
| ? await this.notebookProvider.getOrCreateNotebook({ | ||
| identity: identity.resource, | ||
| resource, |
There was a problem hiding this comment.
Seems we weren't passing in the resource for creating the notebook. This is what broke picking an interpreter based on a resource.
There was a problem hiding this comment.
If I'm reading this right it seems like this would have been broken for a while for both raw and jupyter then. I'm having trouble mapping this to the actual user scenario that would trigger this issue. Just surprised we've not run into this at all.
There was a problem hiding this comment.
Yes it would have been broken.
The user scenario is you
- Open multiroot workspace
- Open interactive window. It uses current interpreter for whatever folder you have open
- Close interactive window.
- Switch to another file
- Open interactive window. It would continue to use the first interpreter. It shouldn't
That's what the test was supposed to verify.
In reply to: 424795255 [](ancestors = 424795255)
There was a problem hiding this comment.
Glad we had a test for it then. Maybe I need to play around with multiroot more often.
| sendTelemetryEvent(Telemetry.OpenedInteractiveWindow); | ||
|
|
||
| // Start the server as soon as we open | ||
| this.ensureConnectionAndNotebook().ignoreErrors(); |
There was a problem hiding this comment.
Additionally this was breaking the create notebook with a resource because for the interactive window, it frequently can't compute the resource until after a user submits code. So starting the notebook before showing the window makes this a race. Moved this to 'show' and now it will always happen after the user adds code.
| (variable as any).frameId | ||
| ); | ||
| if (results) { | ||
| if (results && results.result) { |
There was a problem hiding this comment.
This was unnecessarily crashing sometimes (when debugpy doesn't return anything because the value may not evaluate). Checking this here lets the value just exist as is.
|
|
||
| private async createAndUpdateConnectionFile() { | ||
| this.connectionFile = await this.file.createTemporaryFile('.json'); | ||
| this.connectionFile = await this.file.createTemporaryFile('.json', 0o777); |
There was a problem hiding this comment.
I should put a comment here. Not sure if this fixes the direct kernel problem or not, but going to wait and see.
There was a problem hiding this comment.
That's odd. So the permission on the temp connection file were preventing the delete and recreate?
There was a problem hiding this comment.
Not sure. But the failure point was when it attempted to open it with a restricted set of permissions. After I made this change I haven't seen the failure again, but it could be just luck
In reply to: 424792220 [](ancestors = 424792220)
| suppressShutdownErrors(session.kernel); | ||
| // Shutdown may fail if the process has been killed | ||
| await waitForPromise(session.shutdown(), 1000); | ||
| if (!session.isDisposed) { |
There was a problem hiding this comment.
Not necessary to wait for shutdown if the session is already disposed
| const disposable = this.sessionTerminatedEvent.event(() => response.resolve()); | ||
| this.protocolParser.once(`response_${command}`, (resp: any) => { | ||
| this.sendToTrackers(resp); | ||
| traceInfo(`Received response from debugger: ${JSON.stringify(args)}`); |
There was a problem hiding this comment.
Added this to trace random failures in debugging. Still working on this.
| try { | ||
| await fsextra.remove(filename); | ||
| } catch (err) { | ||
| if (!(await fsextra.pathExists(filename))) { |
There was a problem hiding this comment.
I think this is causing random failures on windows for functional tests. But it's not necessary.
| return ''; | ||
| } | ||
|
|
||
| private async hasJupyter(interpreter: PythonInterpreter): Promise<boolean | undefined> { |
There was a problem hiding this comment.
Turns out having jupyter is too lenient. When testing we want only those interpreters that have everything installed that we need. (Seems azure machines can have jupyter in other environments too).
|
|
||
| if (pythonService) { | ||
| // Skip test for older python and on windows. Getting E_PROTO on windows. | ||
| if (pythonService && os.platform() !== 'win32') { |
There was a problem hiding this comment.
For now self certs seems to always fail on windows.
|
It should be noted: this will not fix all of the flake tests. Just some of them (like 7 or so). I'm going to continue working on fixing the other failures. |
| interpreter, | ||
| allowEnvironmentFetchExceptions: true | ||
| }); | ||
| return pythonProcess.isModuleInstalled('livelossplot'); // Should we check all dependencies? |
There was a problem hiding this comment.
I'm guessing the comment here is since livelossplot is standing in for everything in conda-functional-requirements.txt? Seems ok for test code, having to check them all seems like a bit of overkill.
There was a problem hiding this comment.
Yeah. Livelossplot seemed uncommon for other things to install, so seemed like a good candidate for checking.
This does mean that if you run the functional tests locally, you'll have to install livelossplot into a least one environment for most of the tests to pass with real jupyter.
In reply to: 424793927 [](ancestors = 424793927)
There was a problem hiding this comment.
Since we're on the topic, what do you do for setting up your local test env to run all the real python tests? Just this:
conda install --quiet -y --file build/ci/conda_base.yml
python -m pip install --upgrade -r build/conda-functional-requirements.txt
in a Conda env? Wasn't as sure since there were multiple conda envs getting set up as well in the test steps.
There was a problem hiding this comment.
No I do it more manually.
- conda create --name newEnvName python=3.7 jupyter pip
- conda activate newEnvName
- python -m pip install --upgrade -r build/conda-functional-requirements.txt
In reply to: 424799830 [](ancestors = 424799830)
Codecov Report
@@ Coverage Diff @@
## master #11802 +/- ##
==========================================
- Coverage 60.65% 60.43% -0.22%
==========================================
Files 628 631 +3
Lines 33954 34155 +201
Branches 4781 4798 +17
==========================================
+ Hits 20594 20641 +47
- Misses 12363 12512 +149
- Partials 997 1002 +5
Continue to review full report at Codecov.
|
|
Kudos, SonarCloud Quality Gate passed!
|
Submitting nightly test fixes before they get too big.
Actually found some bugs here too.