Coder Social home page Coder Social logo

Comments (3)

ramedina86 avatar ramedina86 commented on June 19, 2024 1

If you have something that you want to store in state but avoid serialising, you can prefix them with an underscore. More info here.

Numpy arrays are serialisable, however you may have something inside them that's preventing serialisation. For example, complex numbers.

Here's an example of a non-serialisable Numpy array that can be kept in state, but isn't serialised (nor send to the frontend).

initial_state = ss.init_state({
    "_k": np.array([1+2j, 2, 3])
})

def print_k(state):
    print(state["_k"])

Hope this helps!

from streamsync.

ramedina86 avatar ramedina86 commented on June 19, 2024

Hello, I'm glad to hear you're enjoying this library and that it's working well for you.

I have good news, I've just released a new version which runs all event handlers asynchronously to better support long-running tasks. It seems to be perfectly in line with what you were requesting. There's also other new features targeting background/long-running tasks.

It seems like you're building something interesting by the way.

from streamsync.

sarim-zafar avatar sarim-zafar commented on June 19, 2024

Yes I can see that however I can't seem to put some of the variables in the state dict as they are non serialisable (numpy arrays). What's the proposed way of tackling this issue as I want to avoid using global variables. Is there anyway I can send in other variables with events?

from streamsync.

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.