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

Python: Support module objects in the Variables pane #1788

Open
seeM opened this issue Nov 6, 2023 · 5 comments
Open

Python: Support module objects in the Variables pane #1788

seeM opened this issue Nov 6, 2023 · 5 comments

Comments

@seeM
Copy link
Contributor

seeM commented Nov 6, 2023

As of Positron Version: 2023.11.0 (Universal) build 1142, we do not show any module objects in the environment pane.

For example, run:

import builtins
import numpy as np
import pandas as pd

and the environment pane will not update.

I believe this was intentional, since having lots of modules shown could become noisy. However, it was suggested in #1369 (comment) that we could group modules as we've grouped other kinds of variables.

We'll need to add support for module types on the Python side. We may want to still hide it behind a feature flag until we've grouped modules in the Environment pane as suggested above.

@seeM seeM added this to the Internal Preview milestone Nov 6, 2023
@seeM seeM self-assigned this Nov 6, 2023
@seeM seeM added the blocked label Nov 9, 2023
@seeM seeM removed the blocked label Nov 20, 2023
@seeM
Copy link
Contributor Author

seeM commented Dec 18, 2023

Unassigning myself, I made a quick PR with an implementation of this but realised we needed to discuss and agree on whether we would like to display Python modules in the environment pane, and whether/how we'd like to group them. The same questions go for all non-data types i.e. classes, functions, etc.

@seeM seeM removed their assignment Dec 18, 2023
@jgutman jgutman changed the title Python: Support module objects in the Environment pane Python: Support module objects in the Variables pane Jan 18, 2024
@jgutman
Copy link
Contributor

jgutman commented Jan 18, 2024

One other comment here: I find it somewhat odd that if I import a module, it doesn't show up in the Variables pane, but if I import a class, it does. For example, if I do

from great_tables import data
from great_tables import GT

from numpy import random
from numpy import ndarray

GT and ndarray show up in the Variables pane, while data and random do not (since they are modules). And the classes show up under VALUES. My vote would be that as functions are grouped together, classes should be grouped together and modules should be grouped together. And perhaps the MODULES section should be collapsed by default. I don't think putting classes under VALUES makes a lot of sense to most people

@jgutman
Copy link
Contributor

jgutman commented Jan 18, 2024

#1391 (comment)

Another point -- currently, hitting the "Delete all objects" button also clears away any loaded modules/submodules. This is reasonable, but a bit unexpected since 1) those modules are not displayed anywhere in the Variables pane 2) the tooltip text "Delete all objects" doesn't indicate to me my modules will be unloaded and 3) the modal pop-up (Are you sure you want to delete all variables?) also doesn't indicate to me that my modules will be unloaded.

@isabelizimm
Copy link
Contributor

Ah, if nothing else we should definitely update the "Delete all objects" modal. I thought the same thing when clearing variables.

I don't think putting classes under VALUES makes a lot of sense to most people

++ to this. I think having objects under VALUES and classes elsewhere would be more clear

@jgutman
Copy link
Contributor

jgutman commented Jan 19, 2024

My other concern here: In R, "Delete all objects" does not unload packages from the namespace. You have to restart your kernel for that (which is also true in RStudio, so I think that will be familiar to RStudio users). In Python, "Delete all objects" DOES unload all modules and imports. If we maintain this distinct behavior between R and Python, then we'd need to figure out a way to have slightly different language/verbiage on the frontend for these two languages to make it clear to the user whether or not their packages/modules will be cleared, and that seems a bit tricky. Or, we force the two languages to behave the same way, even if that is unintuitive to the respective users of those languages...

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

No branches or pull requests

5 participants