-
Notifications
You must be signed in to change notification settings - Fork 170
Implement Jupyter kernel #2756
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
Closed
Closed
Implement Jupyter kernel #2756
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
b1567d8
Implement Jupyter kernel
Vipul-Cariappa 8eda48b
Test Kernel; presently it only builds, we should add tests later
Vipul-Cariappa 627ba51
fix CI
Vipul-Cariappa 3e85b2f
fix CI
Vipul-Cariappa 217343a
fix CI
Vipul-Cariappa 732b5ed
fix CI
Vipul-Cariappa 66f8fc3
CI fix
Vipul-Cariappa 89ba508
CI: Do not modify other jobs
certik 3a55d86
Hide python_kernel behind ifdef
certik ec94d15
Keep xeus in ci/environment.yml
certik 16f00af
Use micromamba
certik 506a6be
Add xeus-zmq
certik 8362c91
Disable conda info
certik 91eb84e
CI: update Windows build commands
certik File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
---|---|---|
|
@@ -26,38 +26,36 @@ jobs: | |
with: | ||
fetch-depth: 0 | ||
|
||
- name: Cache conda | ||
uses: actions/cache@v3 | ||
env: | ||
CACHE_NUMBER: 0 | ||
with: | ||
path: ~/conda_pkgs_dir | ||
key: | ||
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-${{ hashFiles('ci/environment.yml') }} | ||
|
||
- uses: conda-incubator/setup-miniconda@v2 | ||
# - name: Cache conda | ||
# uses: actions/cache@v3 | ||
# env: | ||
# CACHE_NUMBER: 0 | ||
# with: | ||
# path: ~/conda_pkgs_dir | ||
# key: | ||
# ${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-${{ hashFiles('ci/environment.yml') }} | ||
|
||
- uses: mamba-org/setup-[email protected] | ||
with: | ||
miniconda-version: "latest" | ||
auto-update-conda: true | ||
environment-file: ci/environment.yml | ||
python-version: ${{ matrix.python-version }} | ||
use-only-tar-bz2: true | ||
create-args: >- | ||
python=${{ matrix.python-version }} | ||
|
||
- name: Install Windows Conda Packages | ||
if: contains(matrix.os, 'windows') | ||
shell: bash -e -l {0} | ||
run: conda install m2-bison=3.0.4 cmake=3.21.1 | ||
run: micromamba install m2-bison=3.0.4 m2-filesystem cmake=3.21.1 | ||
|
||
- name: Install Linux / macOS Conda Packages | ||
if: contains(matrix.os, 'ubuntu') || contains(matrix.os, 'macos') | ||
shell: bash -e -l {0} | ||
run: conda install bison=3.4 nodejs=18 | ||
run: micromamba install bison=3.4 nodejs=18 | ||
|
||
- name: Conda info | ||
shell: bash -e -l {0} | ||
run: | | ||
conda info | ||
conda list | ||
# - name: Conda info | ||
# shell: bash -e -l {0} | ||
# run: | | ||
# conda info | ||
# conda list | ||
|
||
- name: Setup Platform (Linux) | ||
if: contains(matrix.os, 'ubuntu') | ||
|
@@ -87,9 +85,9 @@ jobs: | |
if: contains(matrix.os, 'windows') | ||
shell: cmd | ||
run: | | ||
set CONDA_INSTALL_LOCN=C:\\Miniconda3 | ||
call %CONDA_INSTALL_LOCN%\Scripts\activate.bat | ||
call conda activate test | ||
set MAMBA_INSTALL_LOCN=C:\\Users\runneradmin\micromamba | ||
call %MAMBA_INSTALL_LOCN%\Scripts\activate.bat | ||
call micromamba activate test | ||
set LFORTRAN_CMAKE_GENERATOR=Ninja | ||
set WIN=1 | ||
set MACOS=0 | ||
|
@@ -497,6 +495,51 @@ jobs: | |
cd integration_tests | ||
./run_tests.py -b cpython c_py | ||
|
||
build_jupyter_kernel: | ||
name: Build Jupyter Kernel | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- uses: mamba-org/setup-micromamba@v1 | ||
with: | ||
environment-file: ci/environment.yml | ||
create-args: >- | ||
jupyter | ||
nlohmann_json | ||
python=3.10 | ||
bison=3.4 | ||
xeus=5.1.0 | ||
xeus-zmq=3.0.0 | ||
|
||
- uses: hendrikmuhs/ccache-action@main | ||
with: | ||
variant: sccache | ||
key: ${{ github.job }}-${{ matrix.os }} | ||
|
||
- name: Build LPython with Kernel | ||
shell: bash -e -l {0} | ||
run: | | ||
./build0.sh | ||
export CXXFLAGS="-Werror" | ||
cmake . -GNinja \ | ||
-DCMAKE_BUILD_TYPE=Debug \ | ||
-DWITH_LLVM=yes \ | ||
-DWITH_XEUS=yes \ | ||
-DCMAKE_PREFIX_PATH="$CONDA_PREFIX" \ | ||
-DCMAKE_INSTALL_PREFIX="$CONDA_PREFIX" | ||
|
||
ninja install | ||
ctest --output-on-failure | ||
jupyter kernelspec list --json | ||
|
||
- name: Test Kernel | ||
shell: bash -e -l {0} | ||
run: | | ||
ctest --output-on-failure | ||
|
||
upload_tarball: | ||
name: Upload Tarball | ||
runs-on: ubuntu-latest | ||
|
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,67 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "c86338ac-53ca-4115-8c5a-8bf8a5c7113e", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"%%showast\n", | ||
"def add(x: i32, y: i32) -> i32:\n", | ||
" return x + y" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "23834b08-2f3f-45e7-a1ce-21a9fd4e5117", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"%%showasr\n", | ||
"def add(x: i32, y: i32) -> i32:\n", | ||
" return x + y" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "ec7426b4-e2e5-416c-bcae-9bb9c8926c9b", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"%%showllvm\n", | ||
"def sub(x: i32, y: i32) -> i32:\n", | ||
" return add(x, -y)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "716c56ef-8210-4daf-aa23-96b385801014", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"%%showasm\n", | ||
"def mul(x: i32, y: i32) -> i32:\n", | ||
" return x * y" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "LPython", | ||
"language": "python", | ||
"name": "lpython" | ||
}, | ||
"language_info": { | ||
"file_extension": ".f90", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"version": "2018" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 5 | ||
} |
This file contains hidden or 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,134 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 1, | ||
"id": "e87300c2-64ed-4636-8448-591f36faba29", | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"Hello, LPython\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"print(\"Hello, LPython\")" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 2, | ||
"id": "dfcac851-7b49-4065-8c64-4a31658249f7", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"def add(x: i32, y: i32) -> i32:\n", | ||
" return x + y" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 3, | ||
"id": "09213386-84d5-4e7c-83ba-c3b027f765dd", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"def sub(x: i32, y: i32) -> i32:\n", | ||
" return x - y" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 4, | ||
"id": "a4b49fd3-bf17-4287-9d5e-60f14ebc9a0f", | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"data": { | ||
"text/plain": [ | ||
"5" | ||
] | ||
}, | ||
"execution_count": 4, | ||
"metadata": {}, | ||
"output_type": "execute_result" | ||
} | ||
], | ||
"source": [ | ||
"add(2, 3)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 5, | ||
"id": "d6f4961f-7f0c-45a6-9bf8-e549e97098b0", | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"data": { | ||
"text/plain": [ | ||
"-1" | ||
] | ||
}, | ||
"execution_count": 5, | ||
"metadata": {}, | ||
"output_type": "execute_result" | ||
} | ||
], | ||
"source": [ | ||
"sub(2, 3)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 6, | ||
"id": "398fd4be-d7cc-4912-8aa1-880aa58b37ab", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"@dataclass\n", | ||
"class MyClass:\n", | ||
" x: i32\n", | ||
" y: f64\n", | ||
" z: str" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 7, | ||
"id": "628f0b7d-09a6-49de-a0e6-2f6c664f2ba2", | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"12 2.45000000000000000e+01 LPython\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"x: MyClass = MyClass(12, 24.5, \"LPython\")\n", | ||
"print(x)" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "LPython", | ||
"language": "python", | ||
"name": "lpython" | ||
}, | ||
"language_info": { | ||
"file_extension": ".f90", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"version": "2018" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 5 | ||
} |
This file contains hidden or 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,10 @@ | ||
{ | ||
"display_name": "LPython", | ||
"argv": [ | ||
"@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_BINDIR@/lpython", | ||
"kernel", | ||
"-f", | ||
"{connection_file}" | ||
], | ||
"language": "python" | ||
} |
This file contains hidden or 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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Migration to
xeus
5 and above allows us to drop the dependency onxtl
andcppzmq
for all downstream projects (mostly kernels) so you have remove them and also we should pinnlohmann_json
to3.11.3
wherever possible