marimo-team / marimo

A reactive notebook for Python — run reproducible experiments, execute as a script, deploy as an app, and version with git.
https://marimo.io
Apache License 2.0
7.99k stars 284 forks source link

module_name_to_pypi_name to support matching modules like "azure.identity" or "azure.storage.blob" #2841

Open ahjulstad opened 2 weeks ago

ahjulstad commented 2 weeks ago

Description

It would be great if marimo could determine the pypi package to be installed for the various azure packages that use a "azure.xxx" type of module name. As of now, it seems to only support looking at the part before the first dot. In the current version it tries to download "azure-storage" (which is currently deprecated, btw).

Suggested solution

Enable the specification of heuristics like: (in marimo/_runtime/packages/module_name_to_pypi_name.py)

        "azure.identity": "azure-identity",
        "azure.storage.blob": "azure-storage-blob",

Alternative

No response

Additional context

Of course, one could argue that this does not belong in marimo, but it is a really useful feature to have.

mscolnick commented 2 weeks ago

We can add this. You are right we don't currently support the full import, but rather just the top-level namespace. We should expand this and fallback some known nested package names.

Is this something you'd be interested in helping with? Otherwise maybe something we can get to in the next couple weeks.

I think the heuristic could be:

  1. Look for namespace in the module_name_to_pypi_name
  2. Look for nested import in another mapping
  3. Fallback to the default, which is just: module.replace("_", "-")
ahjulstad commented 2 weeks ago

When I looked at it (before filing is), I was not able to figure out how to get access to the complete module name, it seems it is trimmed away in an earlier. Without detailed guidance I wouldn’t be able to do this, I am afraid.


The information contained in this message may be CONFIDENTIAL and is intended for the addressee only. Any unauthorized use, dissemination of the information or copying of this message is prohibited. If you are not the addressee, please notify the sender immediately by return e-mail and delete this message. Thank you