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

Support for Python libraries like numpy #7678

Merged
merged 7 commits into from Aug 30, 2023

Conversation

JaroslavTulach
Copy link
Member

@JaroslavTulach JaroslavTulach commented Aug 28, 2023

Pull Request Description

Fixes #7388 by describing steps to create Enso project that can use numpy library.

Checklist

Please ensure that the following checklist has been satisfied before submitting the PR:

  • The documentation has been updated: Read the documentation!
  • All code follows the
    Scala,
    Java,
  • All code has been tested:
    • Unit tests have been written where possible.

Copy link
Contributor

@hubertp hubertp left a comment

Choose a reason for hiding this comment

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

I'm having some issues with running the example

docs/polyglot/python.md Show resolved Hide resolved
docs/polyglot/python.md Show resolved Hide resolved
docs/polyglot/python.md Show resolved Hide resolved
@radeusgd
Copy link
Member

radeusgd commented Aug 29, 2023

This is unlikely to be in scope of this PR, but do we have plans on allowing most common Python libraries in the Enso Cloud?

In the cloud version, I don't think the user has access to create the virtual environment in the polyglot directory, so we may need to provide some kind of this capability for the users. Maybe we could preinstall some most common libs, like numpy?

(For longer term, I guess ideally we should expose some kind of UI to allow the user to install any custom library available in pip, but for starters pre-installing the basics could work well)

@somebody1234
Copy link
Collaborator

it might also be possible to do some static analysis, to extract all the import statements from the python code.

depending on where the code is coming from though, i think version conflicts might be an issue though. for example, if copy-pasting code and having it Just Work is an intended usecase, if someone pastes code from a really old numpy version they might be using some deprecated functions

@JaroslavTulach
Copy link
Member Author

Maybe we could preinstall some most common libs, like numpy?

That will probably happen in the future.

expose some kind of UI to allow the user to install any custom library available in pip

Maybe.

The goal of this PR is to allow James, Sylwia & other colleagues to install and use numpy & co. without recompiling the engine. The simpler API the better - that's the reason why the API is just an existence of polyglot/python/bin/graalpy file. That's also the reason why the instructions to create that file are so "hardcore" and require direct use of GraalVM.

@JaroslavTulach JaroslavTulach merged commit 198ab7f into develop Aug 30, 2023
27 checks passed
@JaroslavTulach JaroslavTulach deleted the wip/jtulach/NumPyInEnso_7388 branch August 30, 2023 04:10
@JaroslavTulach
Copy link
Member Author

Here is the output of the integration test that installs numpy and uses it.

@JaroslavTulach
Copy link
Member Author

it might also be possible to do some static analysis, to extract all the import statements from the python code.
depending on where the code is coming from though, i think version conflicts might be an issue though.

The Enso solution to versioning is based on editions. The Python equivalent of that is virtual environment. Hence I opted for using it and required it to be part of the project for the sake of simplicity.

it might also be possible to do some static analysis, to extract all the import statements from the python code.

In my opinion this is an interactive task and thus a task for the IDE. Component browser could offer functions from Python libraries and then handle the version resolution, installation via pip & necessary imports. I have no idea how the UI should look like, but I believe good UI will deliver way better results than letting user type and then try static analysis.

Btw. I imagine following personas:

  • skilled analyst using pandas daily - they should have no problem using pip from command line and resolving version conflicts
  • analyst knowing nothing about Python - they would not benefit from static analysis anyway - they need IDE help

The goal of this PR is to ... colleagues to install and use numpy & co. without recompiling the engine.

In any case your idea aims far beyond the goal of this simple PR. However the topic of using numpy and pandas & co. easily will come back, so continue to think about these issues!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Investigate usage of Python libraries
5 participants