Skip to content

Fix the gather survey #13086

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

Merged
merged 6 commits into from
Jul 22, 2020
Merged

Fix the gather survey #13086

merged 6 commits into from
Jul 22, 2020

Conversation

DavidKutu
Copy link

@DavidKutu DavidKutu commented Jul 21, 2020

  1. added 'gather stats' telemetry
  2. mention the gather comments to update the python ext
  • Pull request represents a single change (i.e. not fixing disparate/unrelated things in a single PR).
  • Title summarizes what is changing.
  • Has a news entry file (remember to thank yourself!).
  • Appropriate comments and documentation strings in the code.
  • Has sufficient logging.
  • Has telemetry for enhancements.
  • Unit tests & system/integration tests are added/updated.
  • Test plan is updated as appropriate.
  • package-lock.json has been regenerated by running npm install (if dependencies have changed).
  • The wiki is updated with any design decisions/details.

added 'gather stats' telemetry
mention the gather comments to update the python ext
@codecov-commenter
Copy link

codecov-commenter commented Jul 21, 2020

Codecov Report

Merging #13086 into master will decrease coverage by 0.07%.
The diff coverage is 55.55%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #13086      +/-   ##
==========================================
- Coverage   59.84%   59.76%   -0.08%     
==========================================
  Files         671      671              
  Lines       36653    36686      +33     
  Branches     5153     5158       +5     
==========================================
- Hits        21936    21927       -9     
- Misses      13625    13663      +38     
- Partials     1092     1096       +4     
Impacted Files Coverage Δ
src/client/telemetry/index.ts 82.35% <ø> (ø)
src/client/datascience/commands/commandRegistry.ts 34.09% <20.00%> (-0.02%) ⬇️
src/client/common/utils/localize.ts 96.13% <100.00%> (+0.02%) ⬆️
src/client/datascience/constants.ts 99.77% <100.00%> (+<0.01%) ⬆️
...atascience/jupyter/jupyterSessionManagerFactory.ts 29.62% <0.00%> (-12.48%) ⬇️
src/client/common/utils/platform.ts 64.70% <0.00%> (-11.77%) ⬇️
src/client/datascience/crossProcessLock.ts 79.41% <0.00%> (-11.77%) ⬇️
...ient/datascience/jupyter/kernels/kernelSelector.ts 70.45% <0.00%> (-9.42%) ⬇️
...ient/datascience/jupyter/kernels/kernelSwitcher.ts 75.55% <0.00%> (-9.06%) ⬇️
src/client/activation/languageServer/activator.ts 93.93% <0.00%> (-6.07%) ⬇️
... and 26 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 cf4f377...e8a0a9a. Read the comment docs.

package.nls.json Outdated
@@ -474,8 +474,8 @@
"DataScience.findJupyterCommandProgressCheckInterpreter": "Checking {0}.",
"DataScience.findJupyterCommandProgressSearchCurrentPath": "Searching current path.",
"DataScience.gatherError": "Gather internal error",
"DataScience.gatheredScriptDescription": "# This file was generated by the Gather Extension.\n#\n# The intent is that it contains only the code required to produce\n# the same results as the cell originally selected for gathering.\n# Please note that the Python analysis is quite conservative, so if\n# it is unsure whether a line of code is necessary for execution, it\n# will err on the side of including it.\n#\n# Please let us know if you are satisfied with what was gathered here:\n# https://aka.ms/gathersurvey\n\n",
"DataScience.gatheredNotebookDescriptionInMarkdown": "## Gathered Notebook\nGathered from ```{0}```\n\n| | |\n|---|---|\n|&nbsp;&nbsp;&nbsp|This notebook was generated by the Gather Extension. The intent is that it contains only the code and cells required to produce the same results as the cell originally selected for gathering. Please note that the Python analysis is quite conservative, so if it is unsure whether a line of code is necessary for execution, it will err on the side of including it.|\n\n**Are you satisfied with the code that was gathered?**\n\n[Yes](https://command:python.datascience.gatherquality?yes) [No](https://command:python.datascience.gatherquality?no)",
"DataScience.gatheredScriptDescription": "# This file was generated by the Gather Extension.\n# It will not work without the lastest version of the Python Extension.\n#\n# The intent is that it contains only the code required to produce\n# the same results as the cell originally selected for gathering.\n# Please note that the Python analysis is quite conservative, so if\n# it is unsure whether a line of code is necessary for execution, it\n# will err on the side of including it.\n#\n# Please let us know if you are satisfied with what was gathered here:\n# https://aka.ms/gathersurvey\n\n",
Copy link
Member

Choose a reason for hiding this comment

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

Try to keep the sentences positive. So instead of "It will not work..." say "It requires the latest version of the python extension."

I think it would be legitimate to actually state the version number as well, as in "It requires at least version 2020.7.94776 of the Python extension."

Finally, isn't it possible to set a version on the dependency set? I.e. when you install gather can't it be made to fail or force an update to the Python extension if it's not at least a certain version? That would be the best.

Copy link
Author

Choose a reason for hiding this comment

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

its not possible to install a specific version


sendTelemetryEvent(Telemetry.GatherStats, undefined, {
linesAvailable: linesAvailable ? linesAvailable - cell.data.source.length : -1,
linesInGatheredCell: cell.data.source.length,
Copy link
Member

Choose a reason for hiding this comment

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

This is the number of lines in the cell to be gathered? Do we need this? I think knowing:

  1. The total number of source lines being submitted to be analyzed for gather
  2. The total number of cells being submitted to be analyzed for gather
  3. The total number of lines generated for the gathered result
  4. The total number of cells generated for the gathered result

is what I think we're looking for.

sendTelemetryEvent(Telemetry.GatherStats, undefined, {
linesAvailable: linesAvailable ? linesAvailable - cell.data.source.length : -1,
linesInGatheredCell: cell.data.source.length,
gatheredLines: slicedProgram.splitLines().length - cell.data.source.length
Copy link
Member

Choose a reason for hiding this comment

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

Why are we subtracting the cell data source length? If I recall correctly the cell data source is the source for the entire cell being gathered. After gathering this cell may not contain all the same lines it originally had. So subtracting the number of lines that were in the source from the number of lines gathered total will not always be accurate.

let gatherCount: number | undefined = this.context.globalState.get('gatherCount');

if (gatherCount) {
gatherCount += vscCell.data.source.length;
Copy link
Member

Choose a reason for hiding this comment

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

Is vscCell.data.source.length equal to the total number of lines in the program being submitted to be gathered, and not just for the cell? I don't remember.

Copy link
Author

Choose a reason for hiding this comment

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

just of the cell

@@ -2041,6 +2041,11 @@ export interface IEventNamePropertyMapping {
*/
result: 'err' | 'script' | 'notebook' | 'unavailable';
};
[Telemetry.GatherStats]: {
linesAvailable: number; // Code lines before executing gather, does not include the gathered cell.
Copy link
Member

Choose a reason for hiding this comment

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

I don't think this is what we want. See above.

@DavidKutu DavidKutu requested a review from greazer July 22, 2020 08:35
@@ -255,4 +276,17 @@ export class GatherListener implements IInteractiveWindowListener {
editBuilder.insert(new Position(editor.document.lineCount, 0), '\n');
});
}

private getNumberOfCells(program: string): number {
Copy link

Choose a reason for hiding this comment

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

There's a function that can do this already. generateCellsFromString. You'd call that and just return the array lenth.

let gatherLinesCount: number | undefined = this.context.globalState.get('gatherLinesCount');
let gatherCellsCount: number | undefined = this.context.globalState.get('gatherCellsCount');

if (gatherLinesCount) {
Copy link

Choose a reason for hiding this comment

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

Don't these two values start out as zero/undefined? Seems to me it will always make the global state zero for both.

Copy link
Author

Choose a reason for hiding this comment

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

That depends, does the gatherLogger constructor keep getting executed or does it happen once?

Copy link

Choose a reason for hiding this comment

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

It happens once, but if the value is zero, you update the value to zero again.

Copy link
Author

Choose a reason for hiding this comment

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

Nevermind, I see the issue.

@@ -52,8 +53,7 @@ export class LinkProvider implements IInteractiveWindowListener {
this.openFile(href);
} else if (href.startsWith('https://command:')) {
const temp: string = href.split(':')[2];
const params: string[] =
temp.includes('/?') && temp.includes(',') ? temp.split('/?')[1].split(',') : [];
const params: string[] = temp.includes('/?') ? temp.split('/?')[1].split(',') : [];
Copy link

Choose a reason for hiding this comment

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

Does this change break the reason the ',' was looked for before? Did you look to see what originally put this && condition here and make sure that still worked?

Copy link
Author

Choose a reason for hiding this comment

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

I didn't look for the specific case, but I tested having both a single and multiple parameters and that works as expected.

Copy link
Author

Choose a reason for hiding this comment

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

Yeah I just checked it, out of the 3 commands that use this, only the gather survey one uses parameters

Copy link

@rchiodo rchiodo left a comment

Choose a reason for hiding this comment

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

⏲️

@DavidKutu DavidKutu requested a review from rchiodo July 22, 2020 20:32
@sonarqubecloud
Copy link

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

@DavidKutu DavidKutu merged commit 5d21a13 into master Jul 22, 2020
@DavidKutu DavidKutu deleted the david/fixGatherSurvey branch July 22, 2020 21:54
DavidKutu pushed a commit that referenced this pull request Jul 22, 2020
* fix the gather survey
added 'gather stats' telemetry
mention the gather comments to update the python ext

* oops

* fix tests and address comments

* update gather stats when resetting the kernel

* set globalstate vars to 0 when we open vs code

* fix gather stats telemetry
DavidKutu pushed a commit that referenced this pull request Jul 23, 2020
* Fix the gather survey (#13086)

* fix the gather survey
added 'gather stats' telemetry
mention the gather comments to update the python ext

* oops

* fix tests and address comments

* update gather stats when resetting the kernel

* set globalstate vars to 0 when we open vs code

* fix gather stats telemetry

* fix tests

* fix tests for real
karthiknadig added a commit that referenced this pull request Aug 5, 2020
* Update model.isTrusted on trust change (#12820) (#12823)

* Reduce visual complexity of trust prompt (#12839) (#12847)

* Port python 2.7 fix to release (#12877)

* port color fix on collapse all (#12895) (#12897)

* fix a color on collapse all (#12895)

* update changelog

* Merge fixes into July release (#12889)

Co-authored-by: Timothy Ruscica <[email protected]>

* Merge more fixes into july release (#12918)

Co-authored-by: Joyce Er <[email protected]>

* Port trust fixes (#12929)

* Fix regressions in trusted notebooks (#12902)

* Handle trustAllNotebooks selection

* Fix bug where after trusting, UI didn't update

* Recover from ENOENT due to missing parent directory when trusting notebook (#12913)

* Disable keydown on native cells in untrusted notebooks (#12914)

* Hide editor icons when editor is not a notebook (#12934) (#12935)

* Check for hideFromUser before activating current terminal (#12942) (#12956)

* Check for hideFromUser before activating current terminal

* Add tests

* Tweak logic

* Port final trust fixes for release (#12965)

* Only allow Enter / NumpadEnter w/o ctrl/shift/alt (#12939)

* Send telemetry for notebook trust prompt selections (#12964)

* Fixes for persisting trust (#12950)

* Display survey for native notebooks on/after 1st August (#12961) (#12975)

Co-authored-by: Joyce Er <[email protected]>

Co-authored-by: Joyce Er <[email protected]>

* Contains cherry picks, version updates, change log updates (#12983)

* Update version and change log

* Improve detection when LS is fully loaded for IntelliCode (#12853)

* Fix path

* Actually fix settings

* Add news

* Add test

* Format

* Suppress 'jediEnabled' removal

* Drop survey first launch threshold

* Wait for client ready

* Handle async dispose

* Fix the date

Co-authored-by: Mikhail Arkhipov <[email protected]>

* hide the gather button while a cell is executing (#12984)

* Update date (#13002)

* remove release notes from the start page (#13032)

* Cherry pick, version change and change log update (#13079)

* Ensure languageServer value is valid, send event during activate (#13064)

* Update change log and version

* Activate banner prompt for Pylance (#12817)

* Fix path

* Actually fix settings

* Add news

* Add test

* Format

* Suppress 'jediEnabled' removal

* Drop survey first launch threshold

* Remove LS experiments

* Frequency + tests

* Fix test

* Update message to match spec

* Open workspace for extension rather than changing setting

* Fix localization string

* Show banners asynchronously

* Add experiments

* Formatting

* Typo

* Put back verifyAll

* Remove obsolete experiments, add Pylance

* Suppress experiment if Pylance is installed

* PR feedback

Co-authored-by: Jake Bailey <[email protected]>

* Update change log as per comments

Co-authored-by: Jake Bailey <[email protected]>
Co-authored-by: Mikhail Arkhipov <[email protected]>

* Port fix the gather survey (#13086) (#13105)

* Fix the gather survey (#13086)

* fix the gather survey
added 'gather stats' telemetry
mention the gather comments to update the python ext

* oops

* fix tests and address comments

* update gather stats when resetting the kernel

* set globalstate vars to 0 when we open vs code

* fix gather stats telemetry

* fix tests

* fix tests for real

Co-authored-by: Joyce Er <[email protected]>
Co-authored-by: Ian Huff <[email protected]>
Co-authored-by: David Kutugata <[email protected]>
Co-authored-by: Don Jayamanne <[email protected]>
Co-authored-by: Timothy Ruscica <[email protected]>
Co-authored-by: Mikhail Arkhipov <[email protected]>
Co-authored-by: Jake Bailey <[email protected]>
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