Git Product home page Git Product logo

Comments (4)

krish-adi avatar krish-adi commented on May 17, 2024

How would you use this? Could you give me an example usage?

from barfi.

zabrewer avatar zabrewer commented on May 17, 2024

Sure. One of the use cases is that the compute blocks go one by one and if there is a non-standard error that is not captured in logging for the app itself, streamlit, or another library the user never sees see what block was executing. Once the execute button is run, everything just kind of runs in the background...

Here's one example.

At the top of the page, initiate a streamlit placeholder with st.empty(). This is overly simplified but should get the point across... The user gets a streamlit info message at the top of the page for every block when it is executing.

execution_block_placeholder = st.empty()

# begin compute engine functions
def my_compute_engine(self):
    # compute logic for input_block_1
    block_name = self.get_blockname(self) # <--- need to think through this, we don't know the name of the block
    block_execution_message = f('Now executing block {block_name}')
    execution_execution_block_placeholder.info(block_execution_message)
   # we could also have warning, error and other messages here and either re-use execution_block_message 
   # OR add a new placeholder e.g. warning_block_placeholder = st.empty

input_block_1 = Block(name='Input Block 1')
input_block_1 .add_input(name='Save Orgs and Networks to Local Cache')
input_block_1 .add_compute(my_compute_engine)

from barfi.

zabrewer avatar zabrewer commented on May 17, 2024

@krish-adi - I don't know if this should be filed under a new enhancement req or this one but it would be nice to also get the last block or have an array where we could say block X of Y blocks. Case is to notify the user of which block is currently running and to let them know when all blocks have run successfully (or not). Some blocks may take some time to run with large API datasets. If something goes wrong, need to know where and notify the user in addition to internally with logger.

from barfi.

krish-adi avatar krish-adi commented on May 17, 2024

In v 0.7.0, now each block can store a private state. This state can store anything you want to access after execution. All the errors during the compute function execution of the block are stored in the state. When a block fails, only the blocks dependent on it are skipped, and the rest of the schema is executed.

This rather is the better way of keeping track of the errors and the status when compared to st.empty() or session_state. I didn't want this to rely too much on streamlit's workflow. For the st.empty() the update did not accur as the placeholder object is bounced around from one function to the other.

from barfi.

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.