Skip to content

Conversation

rchiodo
Copy link

@rchiodo rchiodo commented Oct 2, 2019

For #4441, #7688

Support different variables for the root working directory. If not already set, use the first file that runs to determine the folder for an interactive session. For notebooks use the file that the notebook is in.

@rchiodo rchiodo self-assigned this Oct 2, 2019
@codecov-io
Copy link

codecov-io commented Oct 2, 2019

Codecov Report

Merging #7724 into master will increase coverage by 0.08%.
The diff coverage is 40.35%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #7724      +/-   ##
==========================================
+ Coverage   58.72%   58.81%   +0.08%     
==========================================
  Files         494      496       +2     
  Lines       22027    22115      +88     
  Branches     3541     3558      +17     
==========================================
+ Hits        12935    13006      +71     
- Misses       8281     8297      +16     
- Partials      811      812       +1
Impacted Files Coverage Δ
...ascience/jupyter/liveshare/guestJupyterNotebook.ts 15.15% <ø> (ø) ⬆️
src/client/datascience/types.ts 100% <ø> (ø) ⬆️
...atascience/jupyter/liveshare/guestJupyterServer.ts 16% <ø> (ø) ⬆️
...tascience/jupyter/liveshare/hostJupyterNotebook.ts 10.4% <0%> (ø) ⬆️
...datascience/jupyter/liveshare/hostJupyterServer.ts 17.1% <0%> (-0.23%) ⬇️
.../datascience/interactive-common/interactiveBase.ts 6.26% <0%> (-0.02%) ⬇️
...lient/datascience/jupyter/liveshare/serverCache.ts 50.9% <0%> (-1.93%) ⬇️
.../extension/configuration/providers/djangoLaunch.ts 90.9% <100%> (+4.24%) ⬆️
...client/datascience/jupyter/jupyterServerFactory.ts 32.25% <100%> (ø) ⬆️
src/client/common/configSettings.ts 58.06% <100%> (+0.46%) ⬆️
... and 13 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 83efa1f...8d9d385. Read the comment docs.

break;

case '${cwd}':
return process.cwd();

Choose a reason for hiding this comment

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

This might not be correct.
The execution context in vscode is vscode extension or vscode.
However here the execution context is jupyter or python and cwd is something completely different.

Choose a reason for hiding this comment

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

Today we do something very similar in the src/client/common/variables/systemVariables.ts file.

Can I suggest we modify SystemVariables class to optionally accept a new argument file, this way we have everything we need in there. We can then create properties that match the new variables and it will work with other variables as well.
E.g. there are some variables that are missing, such as ${workspaceFolderBasename} and a few others (see the class).

Choose a reason for hiding this comment

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

This way the extension also gets this new functionality.
FYI -- this has been requested in extension issues.
See here #2341 (I believe we have a few others as well, some old ones).

Copy link
Author

Choose a reason for hiding this comment

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

Sounds like a good idea.


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

Copy link
Author

Choose a reason for hiding this comment

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

According to this, cwd is kind of ambiguous. It says this: ${cwd} - the task runner's current working directory on startup. I would think that would be the directory you started VS code from. Not the workspace folder.


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

Choose a reason for hiding this comment

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

Possibly something that could then be controlled via a ctor argument.
I guess that would also solve https://github.com/microsoft/vscode-python/issues/3612

return this.changeDirectoryIfPossible(this._workingDirectory);
} else if (launchingFile && await fs.pathExists(launchingFile)) {
// Combine the working directory with this file if possible.
this._workingDirectory = expandFileVariable(this.launchInfo.workingDir, launchingFile, this.workspace);

Choose a reason for hiding this comment

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

What if workingDir = ${cwd}/temp.
Users enter such paths in settings.json and launch.json when using python extension.
And also in tasks.json in VS Code.

Using SystemVariables will solve this (it handles multiple variables).

private _execPath: string;

constructor(workspaceFolder?: string) {
constructor(fileOrFolder: Uri | string | undefined, workspace?: IWorkspaceService, documentManager?: IDocumentManager) {
Copy link
Author

Choose a reason for hiding this comment

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

fileOrFolder [](start = 16, length = 12)

Sorry hold on a bit. The config settings are now trumping the values. I have to skip resolving when the result is undefined.

Copy link
Author

Choose a reason for hiding this comment

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

Okay should be fixed now. I sent in a file for the config settings. I should have passed in a folder.


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

Copy link
Author

Choose a reason for hiding this comment

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

Maybe I should make these separate. It would be less easy to mess up.


In reply to: 330679865 [](ancestors = 330679865,330657034)

Copy link
Member

@IanMatthewHuff IanMatthewHuff left a comment

Choose a reason for hiding this comment

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

:shipit:

@rchiodo rchiodo merged commit ec2f179 into master Oct 2, 2019
@rchiodo rchiodo deleted the rchiodo/root_startup branch October 2, 2019 19:32
@lock lock bot locked as resolved and limited conversation to collaborators Oct 9, 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.

4 participants