Closed oscar6echo closed 1 year ago
Thanks a lot for proposing this one @oscar6echo
A couple of comments:
Does those comments make sense? Where would you see this moved?
First thx for the fast reply :+1:
Re the location:
Re how to make it work in a stand alone repo:
Finally deleting the env and starting from scratch again using the jupyterlab-extension-examples conda env, it finally worked. I also deleted all gitignored files/folders.
The building process seems quite complex and I have no idea what residual state provoked the error before...
For now I put the code in a personal repo: https://github.com/oscar6echo/sa-react-auth-google
For ref here are the commands:
[olivier]jupyterlab-explo/oscar6echo-lab/sa-react-auth-google [π¦ v0.1.0][ξ ][π v3.8.17]
β― conda activate jupyterlab-extension-examples
[olivier]jupyterlab-explo/oscar6echo-lab/sa-react-auth-google [π¦ v0.1.0][ξ v18.16.1][π v3.11.4][π
jupyterlab-extension-examples]
β― touch yarn.lock
[olivier]jupyterlab-explo/oscar6echo-lab/sa-react-auth-google [π¦ v0.1.0][ξ v18.16.1][π v3.11.4][π
jupyterlab-extension-examples]
β― node -v
v18.16.1
[olivier]jupyterlab-explo/oscar6echo-lab/sa-react-auth-google [π¦ v0.1.0][ξ v18.16.1][π v3.11.4][π
jupyterlab-extension-examples]
β― python -m pip install -e .
Obtaining file:///home/olivier/GDrive/dev/jupyterlab-explo/oscar6echo-lab/sa-react-auth-google
Installing build dependencies ... done
Checking if build backend supports build_editable ... done
Getting requirements to build editable ... done
Installing backend dependencies ... done
Preparing editable metadata (pyproject.toml) ... done
Building wheels for collected packages: jupyterlab_examples_react_auth_google
Building editable for jupyterlab_examples_react_auth_google (pyproject.toml) ... done
Created wheel for jupyterlab_examples_react_auth_google: filename=jupyterlab_examples_react_auth_google-0.1.0-py3-none-any.whl size=136803 sha256=280156e472c9f36790c147b39baf83d6067ba387df87cd4ef084b132c0b7068b
Stored in directory: /tmp/pip-ephem-wheel-cache-msc25sav/wheels/44/2c/d4/6645e3815bb8d3fc94f7e40db55455c4dddaca334c8ac32ff2
Successfully built jupyterlab_examples_react_auth_google
Installing collected packages: jupyterlab_examples_react_auth_google
Successfully installed jupyterlab_examples_react_auth_google-0.1.0
[olivier]jupyterlab-explo/oscar6echo-lab/sa-react-auth-google [π¦ v0.1.0][ξ v18.16.1][π v3.11.4][π
jupyterlab-extension-examples][β± 48s]
β― jupyter labextension develop . --overwrite
Installing /home/olivier/GDrive/dev/jupyterlab-explo/oscar6echo-lab/sa-react-auth-google/jupyterlab_examples_react_auth_google/labextension -> @jupyterlab-examples/react-auth-google
Removing: /home/olivier/miniconda3/envs/jupyterlab-extension-examples/share/jupyter/labextensions/@jupyterlab-examples/react-auth-google
Symlinking: /home/olivier/miniconda3/envs/jupyterlab-extension-examples/share/jupyter/labextensions/@jupyterlab-examples/react-auth-google -> /home/olivier/GDrive/dev/jupyterlab-explo/oscar6echo-lab/sa-react-auth-google/jupyterlab_examples_react_auth_google/labextension
[olivier]jupyterlab-explo/oscar6echo-lab/sa-react-auth-google [π¦ v0.1.0][ξ v18.16.1][π v3.11.4][π
jupyterlab-extension-examples]
β― jlpm build
Building extension in .
Compilation startingβ¦
Compilation finished
asset vendors-node_modules_dexie_dist_modern_dexie_mjs.af12ad285eb0bc686b59.js 192 KiB [emitted] [immutable] (id hint: vendors) 1 related asset
asset style_index_js.256547e127ecadb0d4e8.js 31.4 KiB [emitted] [immutable] 1 related asset
asset lib_index_js.f9ca5b2bf02e271ef7cb.js 30.7 KiB [emitted] [immutable] 1 related asset
asset remoteEntry.f3bb4475bf4986c6e95b.js 28.3 KiB [emitted] [immutable] (name: @jupyterlab-examples/react-auth-google) 1 related asset
runtime modules 19.1 KiB 13 modules
javascript modules 228 KiB
modules by path ./lib/ 17.5 KiB 11 modules
modules by path ./node_modules/ 199 KiB 9 modules
modules by path ./style/ 11 KiB 5 modules
container entry 42 bytes [built] [code generated]
consume-shared-module modules 210 bytes
modules by path consume shared module (default) @jupyterlab/*.3 (singleton) 126 bytes
consume shared module (default) @jupyterlab/apputils@^4.1.3 (singleton) 42 bytes [built] [code generated]
+ 2 modules
consume shared module (default) react@^18.2.0 (singleton) 42 bytes [built] [code generated]
consume shared module (default) dexie@^3.2.4 (strict) (fallback: ./node_modules/...(truncated) 42 bytes [built] [code generated]
provide-module modules 84 bytes
provide shared module (default) @jupyterlab-examples/react-auth-google@0.1.0 = ...(truncated) 42 bytes [built] [code generated]
provide shared module (default) dexie@3.2.4 = ./node_modules/dexie/dist/mo...(truncated) 42 bytes [built] [code generated]
webpack 5.88.2 compiled successfully in 483 ms
[olivier]jupyterlab-explo/oscar6echo-lab/sa-react-auth-google [π¦ v0.1.0][ξ v18.16.1][π v3.11.4][π
jupyterlab-extension-examples][β± 8s]
β―
The jupyterlab-contrib
org would likely be a good place. Maybe the name of the repo could have the -example
suffix to indicate this is an example repo and not an extension that can be installed directly.
Thanks @oscar6echo for putting that together and sharing it :+1:
Agree there should be a dedicated page in the JupyterLite docs to give it more visibility.
Re repo name, what about jupyterlab-extension-example-react-auth-google
?
With more info in the README to explain how it was build (as a folder in jupyterlab/extension-examples) and where it is meant to be used (mostly jupyterlite) and its main components (non trivial jupyterlab extension react widget, Google auth js lib, write to IDB from extension, read IDB from kernel(s)).
Anyway, whatever name you think is appropriate will do, whatever disclaimer you think are needed are fine with me.
Hey @oscar6echo
so let's move it to jupyterlab-contrib. Would you mind opening an issue requesting ownership transfer? In parallel, you should receive an invitation to become an owner on that org. So you can proceed with the transfer (I will reduce your rights on the org - but not the repo afterwards).
Regarding the naming, let's go with react-auth-google-example
to avoid something too long :wink:
Done by your (clear) instructions.
You can now restrict the rights as you see fit.
Thanks a lot @oscar6echo
I guess we can close this issue and the associated PR.
The pleasure was mine.
Closing.
I created a new example to manage authentication and picked Google as an example as it offers serveral userful backend services (sheets, drive) and their auth lib for SPA is self contained and well documented.
See PR 241
It comes with several questions:
Is it appropriate for the official jupyterlab/extension-examples repo ?
If not (and in general) how can I host a jupyterlab extension in its own repo (for example I plan to write a similar extension for a corporate auth) ? Can I just take folder "react-auth-google" in a separate repo ? Will the building & config work the same ? any subtle change to make ? It would be useful to explain how to to do that in a section of jupyterlab/extension-examples repo I think. See errors below.
The extension is designed primarily for JupyterLite: It writes data into the IndexedDB browser storage. It also works in JupyterLab of course, but the user workflow is a bit manual as they must copy the token (using a button in the extention scree) and paste it into a notebook variable to be able to use it. In JupyterLite it is simpler: any notebook can just read the IndexedDB - see demo notebook. Maybe this could be improved for non JupyterLite env: Is there a simple way to list all living kernels and write a variable into them from an extension ? I read the Kernel Messaging example but I could not find the code snippets I was looking for..
What do you think ? Any advice much appreciated.
EDIT:
re point 2/ I tested by moving the folder in another location and the
pip install -e .
failed with the following msg.Then I deleted the labextension folder in
jupyterlab_examples_react_auth_google
and reran. Other error...It looks like the standalone folder misses some config to build...?