Skip to content

Some fixes for nightly - #11802

Merged
Rich Chiodo (rchiodo) merged 10 commits into
masterfrom
rchiodo/nightly_fix
May 14, 2020
Merged

Rich Chiodo (rchiodo) merged 10 commits into
masterfrom
rchiodo/nightly_fix

Conversation

@rchiodo

Copy link
Copy Markdown

Submitting nightly test fixes before they get too big.

Actually found some bugs here too.

  • Multiple interpreter test was catching a bug. Looks like we regressed switching the interactive window to a different interpreter in between openings

- 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

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

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.

Comment thread build/ci/conda_base.yml
jupyter
numpy
matplotlib
pip

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Making sure pip comes from the conda directory

yapf
pylint
pycodestyle
prospector

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

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,

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Seems we weren't passing in the resource for creating the notebook. This is what broke picking an interpreter based on a resource.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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.

@rchiodo Rich Chiodo (rchiodo) May 13, 2020 •

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

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)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I should put a comment here. Not sure if this fixes the direct kernel problem or not, but going to wait and see.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

That's odd. So the permission on the temp connection file were preventing the delete and recreate?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Added this to trace random failures in debugging. Still working on this.

try {
await fsextra.remove(filename);
} catch (err) {
if (!(await fsextra.pathExists(filename))) {

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

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> {

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

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') {

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

For now self certs seems to always fail on windows.

@rchiodo

Copy link
Copy Markdown
Author

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?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

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)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

No I do it more manually.

  1. conda create --name newEnvName python=3.7 jupyter pip
  2. conda activate newEnvName
  3. python -m pip install --upgrade -r build/conda-functional-requirements.txt

In reply to: 424799830 [](ancestors = 424799830)

@codecov-io

Codecov (codecov-io) commented May 13, 2020 •

Copy link
Copy Markdown

Codecov Report

Merging #11802 into master will decrease coverage by 0.21%.
The diff coverage is 50.00%.

Impacted file tree graph

@@            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     
Impacted Files Coverage Δ
src/client/common/platform/types.ts 100.00% <ø> (ø)
.../datascience/interactive-common/interactiveBase.ts 5.57% <0.00%> (+0.01%) ⬆️
...atascience/interactive-window/interactiveWindow.ts 15.62% <0.00%> (ø)
src/client/datascience/types.ts 100.00% <ø> (ø)
src/client/datascience/baseJupyterSession.ts 52.94% <50.00%> (-0.32%) ⬇️
...datascience/interactive-common/notebookProvider.ts 48.14% <50.00%> (ø)
src/client/common/platform/fileSystem.ts 80.97% <100.00%> (ø)
src/client/common/platform/fs-temp.ts 100.00% <100.00%> (ø)
src/datascience-ui/react-common/arePathsSame.ts 75.00% <0.00%> (-12.50%) ⬇️
src/client/common/utils/platform.ts 64.70% <0.00%> (-11.77%) ⬇️
... and 14 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update db62755...3052fcf. Read the comment docs.

@sonarqubecloud

Copy link
Copy Markdown

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities (and Security Hotspot 0 Security Hotspots to review)
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@rchiodo
Rich Chiodo (rchiodo) merged commit 1c5080e into master May 14, 2020
@rchiodo
Rich Chiodo (rchiodo) deleted the rchiodo/nightly_fix branch May 14, 2020 16:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-changelog No news entry required

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants