-
Notifications
You must be signed in to change notification settings - Fork 2
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
Install fastapi
, pydantic
and orjson
during extension activation & bundle kedro-viz into extension
#83
Conversation
Signed-off-by: Jitendra Gundaniya <jitendra_gundaniya@mckinsey.com>
Signed-off-by: Jitendra Gundaniya <jitendra_gundaniya@mckinsey.com>
Signed-off-by: Jitendra Gundaniya <jitendra_gundaniya@mckinsey.com>
Signed-off-by: Jitendra Gundaniya <jitendra_gundaniya@mckinsey.com>
"py", | ||
"--no-deps", | ||
"--upgrade", | ||
"kedro-viz", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For viz, do we have a particular version that we need to pin? (I think it's the next release version, so we need to wait until it is released, but I just want to confirm this).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mostly it would be next release 10.0.0
. later we willl pin it
src/extension.ts
Outdated
export async function activate(context: vscode.ExtensionContext): Promise<void> { | ||
const alreadyInstalled = context.globalState.get('dependenciesInstalled', false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this globalState? Does that mean it only install if the dependency is not there? I couldn't find the code where this state is set.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In a VSCode extension, globalState
is an API provided by the VSCode framework that allows you to store and retrieve global state info. This state is persisted across VS Code sessions, it remains available even after VS Code is closed and reopened.
globalState
does not have .set
method.
Does that mean it only install if the dependency is not there?
No it just check if await installPythonDependencies(context);
is called before with alreadyInstalled
flag.
Signed-off-by: Jitendra Gundaniya <jitendra_gundaniya@mckinsey.com>
@noklam you mentioned in slack
Could you please elaborate more this, so that I can make changes accordingly. |
I think it's mainly just a refactoring, you have this now: export async function installPythonDependencies(context: any): Promise<void> {
return new Promise<void>(async (resolve, reject) => {
const script = context.asAbsolutePath('bundled/tool/install_dependencies.py');
const interpreterDetails = await getInterpreterDetails();
const pythonPath = interpreterDetails['path'] && interpreterDetails['path'][0];
cp.exec(`${pythonPath} ${script} ${EXTENSION_ROOT_DIR}`, (error, stdout, stderr) => {
if (error) {
console.error(stderr);
reject(error);
} else {
console.log(stdout);
resolve();
}
});
});
} I was thinking something more like this to make it slightly generic. Frankly it is fine to keep it as is as well. export async function callPythonScript(context: any, path_to_script: str): Promise<void> {
return new Promise<void>(async (resolve, reject) => {
const script = context.asAbsolutePath(path_to_script);
const interpreterDetails = await getInterpreterDetails();
const pythonPath = interpreterDetails['path'] && interpreterDetails['path'][0];
cp.exec(`${pythonPath} ${script} ${EXTENSION_ROOT_DIR}`, (error, stdout, stderr) => {
if (error) {
console.error(stderr);
reject(error);
} else {
console.log(stdout);
resolve();
}
});
});
}
callPythonScript('bundled/tool/install_dependencies.py') The reason I was thinking this because it is common for extension/LSP to call tools to perform different actions (think |
Signed-off-by: Jitendra Gundaniya <jitendra_gundaniya@mckinsey.com>
Signed-off-by: Jitendra Gundaniya <jitendra_gundaniya@mckinsey.com>
@noklam created generic |
fastapi
, pydantic
and orjson
during extension activationfastapi
, pydantic
and orjson
during extension activation & bundle kedro-viz into extension
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated the title, all looks good!
Is there anything left to be done here? If not I can merge the PR. |
@noklam Most of the things are done under this PR. we can merge now. |
Resolves #72
As
pydantic
andorjson
depends on platform and python version, So it cant be packaged with extension so those dependencies are installed during extension activation in Kedro extension env (bundled/libs)