Giter Site home page Giter Site logo

Comments (3)

JohanMabille avatar JohanMabille commented on May 27, 2024

Hi,

You can call the publish_stream method of the interpreter.

from xeus.

edgarcosta avatar edgarcosta commented on May 27, 2024

Thank you very much. We tried publish_stream, and we got to some more questions:

In Xeus, there are two functions to output results:

  • publish_execution_result adds Out[]: and adds a new line at the end.
  • publish_stream() does not add a new line and does not add Out[]: either.

What should we use if we want to display the results progressively as they are computed?

Then the issue is with something like this in python

from time import sleep
import sys
for i in range(5):
    sleep(1)
    sys.stdout.write(f"{i} ")

which should display

Out[1]: 1

updated one second later to

Out[1]: 1 2

updated one second later to

Out[1]: 1 2 3

In case you are interested, here is the kernel we are developing:
https://pari.math.u-bordeaux.fr/cgi-bin/gitweb.cgi?p=xeus-gp.git;a=blob;f=src/xinterpreter.cpp;h=7e4517ec9f4eb7e5b4d6487fb83c26ef0064d090;hb=refs/heads/bill-2.17

from xeus.

JohanMabille avatar JohanMabille commented on May 27, 2024

Hi, sorry for the late reply. I'm not 100% sure how the frontend handles this, but I would try the folowing:

  • either publish_execution_result for sending the first output, and the publish_stream to update; this assumes the frontend appends the outputs to the current one.
  • or maintain a string in the kernel, update it by appending a new result when it become available and immediately send it with publish_execution_result. This assumes that the frontend replaces the current output with the new one.

Thanks for the pointer!

from xeus.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.