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

improvement: fallback to jedi interpeter in completion #1559

Merged
merged 6 commits into from
Jun 6, 2024

Conversation

akshayka
Copy link
Contributor

@akshayka akshayka commented Jun 5, 2024

This change improves the responsiveness and coverage of code completion.

  • Fallback to the Jedi Interpreter class when static analysis-based completion turns up empty. (Jedi's static completer fails on some libraries, like ibis.) The Interpreter completer evaluates code, so care is taken to avoid race conditions with the kernel by introducing a lock on the globals dictionary. Acquiring/releasing the lock works in Pyodide, even though Pyodide doesn't support creating threads, so no separate codepath was needed for WASM.
  • Decrease the docstring limit when running locally from 1000 to 80.
  • Add a cumulative timeout across completions, after which we stop computing completion info.

As a result:

  • We now get completions for Ibis, and probably other libraries that we were failing to complete.
  • Pandas and NumPy completions are much faster (due to the docstring limit / timeout); previously, they were so slow as to not really work at all.

Note: While the Interpreter completer is running, the user won't be able to run code / the kernel won't process control requests. For this reason the Interpreter completer has a timeout of 1 second (we can make this even lower if needed). In practice I believe this won't be a problem since the Interpreter completer is only a fallback.

Tested: manually, by playing with a notebook that uses Ibis, Pandas, and NumPy locally.

In the future, we could make docstring fetching lazy, in which case we could remove the docstring limit.

Copy link

vercel bot commented Jun 5, 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 Jun 5, 2024 11:47pm
marimo-storybook ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 5, 2024 11:47pm

@akshayka akshayka marked this pull request as ready for review June 5, 2024 23:51
@akshayka akshayka changed the title improvement: fallback to jedi interpeter improvement: fallback to jedi interpeter in completion Jun 5, 2024
@akshayka akshayka merged commit ba31235 into main Jun 6, 2024
30 checks passed
@akshayka akshayka deleted the aka/completion-fallback branch June 6, 2024 17:25
Copy link

github-actions bot commented Jun 6, 2024

🚀 Development release published. You may be able to view the changes at https://marimo.app?v=0.6.17-dev1

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

Successfully merging this pull request may close these issues.

None yet

2 participants