Skip to content
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

feat: package installation from pypi #961

Merged
merged 24 commits into from
Mar 20, 2024
Merged

feat: package installation from pypi #961

merged 24 commits into from
Mar 20, 2024

Conversation

akshayka
Copy link
Contributor

@akshayka akshayka commented Mar 16, 2024

This PR adds a basic UI to install packages using pip from the frontend. When packages are detected as missing (we use a ModuleNotFoundError as a heuristic), a list of missing packages is presented to the user, along with an option to install them using pip.

This is mostly for convenience -- it can be helpful when you spin up a new environment for prototyping or for testing a notebook someone shared with you, by eliminating the need to quit a marimo notebook, install the missing packages, and restart it.

If the user chooses to install, the UI starts installing the packages one by one, showing which package is currently being installed, which failed to install, and which succeeded. Installation of a package triggers re-running of the cell that imports it

Some notes:

  • If an install of a module fails (perhaps the "package" was actually just a missing local module), the user won't be re-prompted to install it.
  • We use a heuristic to convert from module names to package names, but this won't ever be perfect.
  • We refuse to install packages if we detect the user has installed marimo in system Python.

Room for improvement:

  • Specifying package versions
  • Specifying package manager
  • Sending console logs to the log viewer (they just print to the terminal)

image
image
image

Copy link

vercel bot commented Mar 16, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
marimo-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 19, 2024 9:08pm
marimo-storybook ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 19, 2024 9:08pm

@akshayka akshayka marked this pull request as draft March 16, 2024 00:05
@akshayka akshayka changed the title [WIP] Package Installation feat: package installation from pypi Mar 19, 2024
@akshayka akshayka marked this pull request as ready for review March 19, 2024 16:59
...

@abc.abstractmethod
async def install(self, package: str) -> bool:
Copy link
Contributor

@mscolnick mscolnick Mar 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it worth installing multiple at once? its more performant and possibly more correct because the package manager can find the right versions compatible across all the packages requested to be installed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

possibly more correct because the package manager can find the right versions compatible across all the packages requested to be installed

Good point regarding correctness. Unfortunately we may lose the progress notifications in the UI, though, if we install multiple at once.



@router.post("/install_missing_packages")
@requires("edit")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we do this on read too when in pyodide?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added a TODO

@mscolnick mscolnick merged commit d9fbeb8 into main Mar 20, 2024
29 checks passed
@mscolnick mscolnick deleted the aka/packages branch March 20, 2024 01:24
@github-actions github-actions bot locked and limited conversation to collaborators Mar 20, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants