marimo icon indicating copy to clipboard operation
marimo copied to clipboard

[wip] implement standard in (backend)

Open akshayka opened this issue 1 year ago • 2 comments

This change implements support for reading from standard in on the backend.

This is achieved by adding a new queue to each session/kernel pair, the input_queue. The input() builtin and sys.stdin.readline function are patched to send a control message to the frontend, requesting input. They then pull an input from the input queue, blocking until an input is available.

A new route is added, /api/kernel/stdin, that just accepts text and puts it in the input queue.

akshayka avatar Jan 16 '24 22:01 akshayka

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 Jan 17, 2024 2:20am
marimo-storybook ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 17, 2024 2:20am

vercel[bot] avatar Jan 16 '24 22:01 vercel[bot]

Codecov Report

Attention: 46 lines in your changes are missing coverage. Please review.

Comparison is base (cb6fbd8) 64.25% compared to head (3384f8d) 64.27%. Report is 3 commits behind head on main.

Files Patch % Lines
marimo/_messaging/streams.py 64.81% 19 Missing :warning:
marimo/_server/sessions.py 0.00% 11 Missing :warning:
marimo/_runtime/runtime.py 42.85% 4 Missing :warning:
marimo/_server/api/stdin.py 78.57% 3 Missing :warning:
marimo/_runtime/context.py 50.00% 1 Missing :warning:
marimo/_server/api/code_complete.py 0.00% 1 Missing :warning:
marimo/_server/api/delete.py 0.00% 1 Missing :warning:
marimo/_server/api/function_call.py 0.00% 1 Missing :warning:
marimo/_server/api/instantiate.py 0.00% 1 Missing :warning:
marimo/_server/api/run.py 0.00% 1 Missing :warning:
... and 3 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #587      +/-   ##
==========================================
+ Coverage   64.25%   64.27%   +0.01%     
==========================================
  Files         130      132       +2     
  Lines        6370     6440      +70     
  Branches     1285     1293       +8     
==========================================
+ Hits         4093     4139      +46     
- Misses       2096     2121      +25     
+ Partials      181      180       -1     

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar Jan 16 '24 23:01 codecov[bot]