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

Browse Functionality #6

Closed
cocopops17 opened this issue Feb 23, 2023 · 11 comments
Closed

Browse Functionality #6

cocopops17 opened this issue Feb 23, 2023 · 11 comments
Assignees
Labels
enhancement New feature or request

Comments

@cocopops17
Copy link

Is it possible to get "browse" to work as it did with stata_kernel (i.e. open Stata's native browser in a new window)? I'm still using the Hydrogen package in Atom to run my code, so the currently-implemented %browse magic doesn't work for me.

@hugetim
Copy link
Owner

hugetim commented Feb 23, 2023

In short: it may be possible, but it looks to be pretty involved, if so.

Stata's pystata api doesn't allow for it. So we'd have to try the completely separate route of Stata Automation that stata_kernel uses--and I'm not sure that separate approach can be made to play nicely with pystata.

To confirm my understanding, are you using Windows, or MacOS? If Windows, you did that extra install step for stata_kernel, right?

Currently, I'm only vaguely familiar with how this part of stata_kernel works, so it would be a steep climb for me to attempt adding this functionality personally. I'd be quick to pull it in if someone else codes it, though.

Another possibility would be to petition StataCorp to add this functionality to pystata, but I'm not sure they will see that as in their interest.

I'd also really like to have this feature. In practice, I myself currently go back and forth between working in Jupyter Lab and the normal Stata application, largely to be able to use browse. As long as the data you're working with isn't too big, it is relatively quick to save a .dta file in the notebook and then open it in normal Stata. But it would be really nice to streamline that workflow further somehow.

%head and %tail should work for you, at least, though I recognize they are nowhere near the same. (Another imperfect substitute: there may be a way to get nbstata's %browse plug-in to work with Atom, maybe starting from here, but that's definitely beyond my own aspirations.)

@gaksaray
Copy link

This is also my biggest gripe with using Jupyter Notebooks for Stata with the current pystata API, which prevents me from fully embracing the workflow for exploratory analysis. @hugetim inspired by your call for petition, I posted this on Statalist.

In the meantime, I had experimented with various third-party data viewers for Python and I believe the best one is D-Tale. Would it ever be possible to have something like this integrated into %browse magic?

@hugetim
Copy link
Owner

hugetim commented Feb 26, 2023

Great, I'll go upvote you on Statalist!

And thanks for finding D-Tale! I think that looks better (and much easier to install) than the thing I had been using, so I expect I'll replace that with this very soon.

@hugetim hugetim self-assigned this Feb 28, 2023
@hugetim hugetim added the enhancement New feature or request label Feb 28, 2023
@hugetim
Copy link
Owner

hugetim commented Mar 8, 2023

Ok, I spent several hours trying to get D-tale to work reliably, and I couldn't. (And that's not even considering the difficulties campus folks would have trying to get it to work on JupyterHub.) Instead, I'm going with a much simpler and more robust option in ipydatagrid.

@hugetim
Copy link
Owner

hugetim commented Mar 9, 2023

But I'm thinking to add a %%python magic (someday) that would let you access dtale on your own if you want..

@gaksaray
Copy link

I tried the new %browse magic in v0.5.0 and I like the fact that it's plain and requires no other packages to be installed. However, I experience sluggishness on my MacBook M1 (Safari). Please see the screen capture. Is this normal? I'd expect it to be buttery smooth as it's seemingly a very simple applet.

Also, two minor questions: Would it be possible to have an option to move this to a separate window (as in Data Editor in Stata)? And is it possible to change the font within the view (from Courier to something else)?

Screen.Recording.2023-03-10.at.9.24.49.PM.mov

@hugetim
Copy link
Owner

hugetim commented Mar 10, 2023

Right click on it in JupyterLab and select "Create New View for Output." That gives you a separate tab within JupyterLab. But if you meant moving it to a separate browser tab, I don't know if that's possible.

On the sluggishness, I wasn't able to replicate that, trying it just now, so I'm not sure what to suggest. There's no sluggishness for me (albeit on a powerful Windows desktop, using Chrome).

I'm reluctant to change the default font because that's deliberately matching Stata's default look. I could make it configurable if that's important to you though. I guess maybe it's easier to see long strings with a different font?

@gaksaray
Copy link

gaksaray commented Mar 24, 2023

This is what I see on classic Notebook:

Screen Shot 2023-03-24 at 10 39 56 PM

There is no way to resize that browse window.

Then I switch to Lab. Datagrid looks fine, but the choppiness is real (mind you this is the tiny auto dataset):

Screen.Recording.2023-03-24.at.10.44.02.PM.mov

I'm on M1 Mac with macOS Monterey and Safari so I don't know if this is specific to Apple setup.

@hugetim
Copy link
Owner

hugetim commented Mar 25, 2023

As a workaround while we try to address those issues, you can use %head [N] or %tail [N] as an alternative to %browse (replacing [N] with a number at least as large as your observation count). That should give you output equivalent to pystata_kernel's %browse magic.

@hugetim
Copy link
Owner

hugetim commented Oct 26, 2024

Narrow %browse widget addressed by v0.8.1

@hugetim
Copy link
Owner

hugetim commented Oct 28, 2024

Are you still seeing choppiness, @gaksaray?

I think I'm done working on this for now, in any case. FYI, my longer-term plan is to work toward integration with Positron's Data Explorer: https://positron.posit.co/data-explorer.html But that may be a while, as Positron's extension API is still experimental and undocumented.

Also... is it possible to change the font within the view (from Courier to something else)?

v0.8.1 also changed the %browse font (in line with Stata 18's change).

@hugetim hugetim closed this as completed Oct 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants