-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into noklam/track-command-usage-with-68
Signed-off-by: Nok Lam Chan <[email protected]>
- Loading branch information
Showing
12 changed files
with
208 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import subprocess | ||
import sys | ||
from pathlib import Path | ||
|
||
def install_dependencies(extension_root_dir): | ||
""" | ||
Install dependencies required for the Kedro extension. | ||
Args: | ||
extension_root_dir (str): The root directory of the extension. | ||
Raises: | ||
ImportError: If the required dependencies are not found. | ||
""" | ||
... | ||
libs_path = Path(extension_root_dir) / "bundled" / "libs" | ||
requirements_path = Path(extension_root_dir) / "kedro-viz-requirements.txt" | ||
|
||
try: | ||
import fastapi | ||
import orjson | ||
except ImportError: | ||
subprocess.check_call( | ||
[ | ||
sys.executable, | ||
"-m", | ||
"pip", | ||
"install", | ||
"-r", | ||
Path(requirements_path), | ||
"-t", | ||
Path(libs_path), | ||
"--no-cache-dir", | ||
] | ||
) | ||
|
||
|
||
if __name__ == "__main__": | ||
if len(sys.argv) > 1: | ||
extension_root_dir = sys.argv[1] | ||
else: | ||
extension_root_dir = None | ||
install_dependencies(extension_root_dir) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
fastapi>=0.100.0,<0.200.0 | ||
pydantic>=2.0.0 # In case of FastAPI installs pydantic==1 | ||
orjson>=3.9, <4.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,5 +11,7 @@ | |
# Required packages | ||
pygls | ||
packaging | ||
networkx>=2.5 | ||
sqlalchemy>=1.4, <3 | ||
|
||
# TODO: Add your tool here |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,30 @@ | ||
# | ||
# This file is autogenerated by pip-compile with Python 3.12 | ||
# This file is autogenerated by pip-compile with Python 3.10 | ||
# by the following command: | ||
# | ||
# pip-compile ./requirements.in | ||
# | ||
attrs==23.2.0 | ||
attrs==24.2.0 | ||
# via | ||
# cattrs | ||
# lsprotocol | ||
cattrs==23.2.3 | ||
cattrs==24.1.0 | ||
# via | ||
# lsprotocol | ||
# pygls | ||
exceptiongroup==1.2.2 | ||
# via cattrs | ||
lsprotocol==2023.0.1 | ||
# via pygls | ||
networkx==3.3 | ||
# via -r ./requirements.in | ||
packaging==24.1 | ||
# via -r ./requirements.in | ||
pygls==1.3.1 | ||
# via -r ./requirements.in | ||
sqlalchemy==2.0.32 | ||
# via -r ./requirements.in | ||
typing-extensions==4.12.2 | ||
# via | ||
# cattrs | ||
# sqlalchemy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import * as cp from 'child_process'; | ||
import { getInterpreterDetails } from './python'; | ||
|
||
/** | ||
* Calls a Python script with the specified arguments. | ||
* | ||
* @param pathToScript - The path to the Python script. | ||
* @param scriptArgv - The arguments to pass to the script. | ||
* @param context - The context object. | ||
* @returns A promise that resolves when the script execution is complete. | ||
*/ | ||
export async function callPythonScript(pathToScript: string, scriptArgv: string, context: any): Promise<string> { | ||
return new Promise<string>(async (resolve, reject) => { | ||
const script = context.asAbsolutePath(pathToScript); | ||
const interpreterDetails = await getInterpreterDetails(); | ||
const pythonPath = interpreterDetails['path'] && interpreterDetails['path'][0]; | ||
|
||
cp.exec(`${pythonPath} ${script} ${scriptArgv}`, (error, stdout, stderr) => { | ||
if (error) { | ||
console.error(stderr); | ||
reject(error); | ||
} else { | ||
console.log(stdout); | ||
resolve(stdout); | ||
} | ||
}); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,24 @@ | ||
# | ||
# This file is autogenerated by pip-compile with Python 3.12 | ||
# This file is autogenerated by pip-compile with Python 3.10 | ||
# by the following command: | ||
# | ||
# pip-compile ./src/test/python_tests/requirements.in | ||
# | ||
exceptiongroup==1.2.2 | ||
# via pytest | ||
iniconfig==2.0.0 | ||
# via pytest | ||
packaging==24.1 | ||
# via pytest | ||
pluggy==1.5.0 | ||
# via pytest | ||
pyhamcrest==2.1.0 | ||
# via -r requirements.in | ||
# via -r ./src/test/python_tests/requirements.in | ||
pytest==8.3.2 | ||
# via -r requirements.in | ||
# via -r ./src/test/python_tests/requirements.in | ||
python-jsonrpc-server==0.4.0 | ||
# via -r requirements.in | ||
# via -r ./src/test/python_tests/requirements.in | ||
tomli==2.0.1 | ||
# via pytest | ||
ujson==5.10.0 | ||
# via python-jsonrpc-server |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.