Code Monkey home page Code Monkey logo

Comments (18)

fritzo avatar fritzo commented on August 25, 2024

As a workaround, I'm using --sanitize-with=workaround.txt, where workaround.txt contains

regex: (stream)+
replace: stream

from nbval.

minrk avatar minrk commented on August 25, 2024

I suspect this is related to the number of stream outputs produced by the cell varying (each stdout.flush produces a message. This number can depend on timing). nbval should be merging consecutive stream outputs into one (what we call coalesce_streams in nbconvert), so that the number of messages doesn't affect the output to be compared.

from nbval.

fritzo avatar fritzo commented on August 25, 2024

It looks like my workaround isn't working: the tests are flaky. Does anyone have a better workaround?

from nbval.

vidartf avatar vidartf commented on August 25, 2024

@minrk: Will stream outputs be coalesced in the saved notebook's output, or does nbval need to process those as well?

from nbval.

vidartf avatar vidartf commented on August 25, 2024

I guess we might also have to handle \r. Should all streams with the same name be combined, or only subsequent ones? Are there any other gotchas? Is there a library call for handling these things (should there be)?

from nbval.

vidartf avatar vidartf commented on August 25, 2024

We should also handle backspace characters, according to this code: https://github.com/jupyter/notebook/blob/e77d7ebfb060d7ce45fb85e865a2c6d8e7635900/notebook/static/base/js/utils.js#L467. However, it seems nbconvert does not do this.

from nbval.

vidartf avatar vidartf commented on August 25, 2024

Is this notebook behavior going to be an issue?
stream_coalesce

from nbval.

vidartf avatar vidartf commented on August 25, 2024

To highlight this better, the outputs of this cell are not deterministic:

import time
import numpy as np
print('Bar!', file=sys.stderr)
print('Combo breaker!', file=sys.stdout)
time.sleep(np.random.rand())
print('Foo!', file=sys.stderr)

from nbval.

vidartf avatar vidartf commented on August 25, 2024

PS: The stream vs streamstream means that one cell had one stream, while the other cell had two. This can definitely be improved!

from nbval.

takluyver avatar takluyver commented on August 25, 2024

I think we can only combine consecutive stream outputs from the same stream, to make it more consistent.

I think we had discussed a kernel change so that printing on one stream would effectively flush the other, to make output order more deterministic.

from nbval.

minrk avatar minrk commented on August 25, 2024

@vidartf to answer your question, yes consecutive outputs from the same stream will be merged into one output in the live notebook and in nbconvert during nbconvert --execute. The nbconvert implementation is here.

from nbval.

vidartf avatar vidartf commented on August 25, 2024

Fix suggested in #57.

from nbval.

takluyver avatar takluyver commented on August 25, 2024

Sorry, I thought #57 was the one we already merged.

from nbval.

fritzo avatar fritzo commented on August 25, 2024

Thanks for fixing this! Do you have an ETA on publishing the fix? (I'm still getting flaky errors from nbval 0.5 on pypi.)

from nbval.

takluyver avatar takluyver commented on August 25, 2024

@vidartf is there anything else you want to work on before we cut 0.6?

from nbval.

vidartf avatar vidartf commented on August 25, 2024

I think we should be OK. I actually meant to get a release during PyData, but forgot about it.

from nbval.

takluyver avatar takluyver commented on August 25, 2024

I have released 0.6. :-)

from nbval.

fritzo avatar fritzo commented on August 25, 2024

Thank you! 👍

from nbval.

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.