jupyterlab / jupyter-ai

A generative AI extension for JupyterLab
https://jupyter-ai.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
3.13k stars 308 forks source link

jupyter-ai 0.6.0 breaks sagemaker studio #124

Closed remziduzagac closed 1 year ago

remziduzagac commented 1 year ago

Description

After installing jupyter-ai 0.6.0 on sagemaker studio (jupyterlab 3.6.1) UI is not opening properly constantly showing this message

Screenshot 2023-04-27 at 23 47 19

welcome[bot] commented 1 year ago

Thank you for opening your first issue in this project! Engagement like this is essential for open source projects! :hugs:
If you haven't done so already, check out Jupyter's Code of Conduct. Also, please try to follow the issue template as it helps other other community members to contribute more effectively. welcome You can meet the other Jovyans by joining our Discourse forum. There is also an intro thread there where you can stop by and say Hi! :wave:
Welcome to the Jupyter community! :tada:

JasonWeill commented 1 year ago

Hi @remziduzagac ! Sorry for the delay in getting back to you.

Using SageMaker Studio with the "TensorFlow 2.10.0 Python 3.9 CPU Optimized" image, I was able to install Jupyter AI 0.7.1, and the appropriate related packages (openai, anthropic, etc), and after setting environment variables using the %env magic command, I could issue %ai magic commands. What image are you using with your JupyterLab setup? I recommend using one with Python 3.9 or Python 3.10, as 3.11 is known not to work and there are open issues concerning full compatibility with 3.7 and 3.8.

Thanks for opening this issue!

remziduzagac commented 1 year ago

Hello Jason,

I've tested version 0.7.1 on a fresh installation of SageMaker Studio, but unfortunately, I'm still encountering the same issue. Let me provide further clarification: SageMaker Studio differs from SageMaker Notebooks as it consists of two types of instances: the server app and the kernel gateway apps. You can find more information about this distinction in the following link: https://aws.amazon.com/blogs/machine-learning/dive-deep-into-amazon-sagemaker-studio-notebook-architecture/ To enable the chat interface, I'm installing jupyter-ai on the server app instance, which has Python version 3.9.12.

Best

aws-khatria commented 1 year ago

I also faced the same issue after installing jupyter-ai extension on JupyterServer app. The %ai commands work seamlessly on Kernel Gateway app.

Found this error related to react compatibility of jupyter/ai-core package on JupyterServer app:

(jupyter-ai) sagemaker-user@studio$ jupyter labextension list
JupyterLab v3.6.3
/opt/conda/envs/jupyter-ai/share/jupyter/labextensions
        jupyterlab_pygments v0.2.2 enabled OK (python, jupyterlab_pygments)
        @jupyter-ai/core v0.6.1 enabled  X (python, jupyter_ai)

"@jupyter-ai/core@0.6.1" is not compatible with the current JupyterLab
Conflicting Dependencies:
JupyterLabExtension        Package
>=17.0.1 <18.0.0>=18.2.0 <19.0.0 react
>=17.0.1 <18.0.0>=18.2.0 <19.0.0 react-dom
JasonWeill commented 1 year ago

The "not compatible with the current JupyterLab" issue was fixed in #157, although we don't yet have a release that incorporates this fix. See #130.

JasonWeill commented 1 year ago

@aws-khatria Release 0.7.2, just cut this afternoon, includes a fix for #130.

anupam-dewan commented 1 year ago

Yes looks like 0.7.2 works. Thanks.

aws-khatria commented 1 year ago

Thanks Jason! Release 0.7.2 fixes the "not compatible" error. I can now see that the @jupyter-ai/core v0.7.2 extension is enabled.

@jupyter-ai/core v0.7.2 enabled OK (python, jupyter_ai)

However, I observed this error log after installing jupyter-ai in the app container log

[W 2023-05-19 23:18:03.828 ServerApp] jupyter_ai | error adding extension (enabled: True): The module 'jupyter_ai' could not be found (cannot import name 'CursorResult' from 'sqlalchemy' (/opt/conda/envs/studio/lib/python3.9/site-packages/sqlalchemy/__init__.py)). Are you sure the extension is installed?

I was able to fix this error by upgrading sqlalchemy (pip install sqlalchemy --upgrade). I could see in the logs that the extension is successfully linked.

[I 2023-05-19 23:32:28.012 AiExtension] Registered jupyter_ai server extension
[I 2023-05-19 23:32:28.390 ServerApp] jupyter_ai | extension was successfully loaded.

However, I still don't see the chat interface icon. The Studio also doesn't load if I refresh the page. It's just stuck (see screenshot). Let me know the next steps here. Screenshot 2023-05-19 at 4 47 15 PM

anupam-dewan commented 1 year ago

+1 it is stuck at loading for me too.

anupam-dewan commented 1 year ago

I tried deleting my studio apps and restarting; reinstalling the jupyter_Ai kernel. I think this issue comes on creating the new build in Studio after installing this from the Extension manager

remziduzagac commented 1 year ago

I looked into version 0.7.2 and it seems like they've addressed the bug that made it incompatible with the current JupyterLab. But even after the fix, I'm still facing the same problem where the user interface doesn't load.

studio) sagemaker-user@studio$ jupyter labextension list
JupyterLab v3.6.1
/opt/conda/envs/studio/share/jupyter/labextensions
        nbdime-jupyterlab v2.1.1 enabled OK
        sagemaker_datawrangler v0.3.11 enabled OK (python, sagemaker_datawrangler)
        sagemaker_datawrangler_discovery v0.4.0 enabled OK (python, sagemaker_datawrangler_discovery)
        @jupyter-widgets/jupyterlab-manager v3.1.0 enabled OK (python, jupyterlab_widgets)
        @jupyterlab/git v0.41.0 enabled OK (python, jupyterlab-git)
        @jupyterlab/server-proxy v3.2.1 enabled OK
        @jupyterlab/scheduler v1.1.4 enabled OK
        @jupyter-ai/core v0.7.2 enabled OK (python, jupyter_ai)
        @amzn/aws-hil-axis-jupyter-lab-extension v5.0.8 enabled OK (python, amzn_aws_hil_axis_jupyter_lab_extension)
        @amzn/sagemaker-ui v5.1008.2 enabled OK (python, amzn_sagemaker_ui)
        @amzn/sagemaker-ui-canvas-collaboration v0.0.0 enabled OK (python, @amzn/sagemaker-ui-canvas-collaboration)
        @amzn/sagemaker-ui-theme-dark-jupyterlab v5.1008.2 enabled OK (python, amzn_sagemaker_ui_theme_dark_jupyterlab)
        @unfolded/jupyter-map-sdk v1.5.1 enabled OK (python, unfolded.map_sdk)
3coins commented 1 year ago

@anupam-dewan @remziduzagac @aws-khatria Thanks for trying out Jupyter AI in SageMaker Studio. We are still working on making this work within Studio; I concur at this time installing the extension within Studio causes UI to hang. I would recommend not to attempt this until we provide more updates on the installation.

3coins commented 1 year ago

Compiled a list of tasks to fix the errors in Studio. See https://github.com/jupyterlab/jupyter-ai/issues/187 for more info.

3coins commented 1 year ago

Fixed in 0.7.3.