# Barfi : Flow Based Programming for Data Science (New Component)

**URL:** <https://discuss.streamlit.io/t/barfi-flow-based-programming-for-data-science-new-component/23237>\
**Category:** Custom Components\
**Created:** [March 17, 2022, 11:24am UTC](https://discuss.streamlit.io/t/barfi-flow-based-programming-for-data-science-new-component/23237 "2022-03-17T11:24:19Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![krishadi](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/krishadi/32/3959_2.png) [@krishadi](https://discuss.streamlit.io/u/krishadi)\
**Post date:** [March 17, 2022, 11:24am UTC](https://discuss.streamlit.io/t/barfi-flow-based-programming-for-data-science-new-component/23237/1 "2022-03-17T11:24:19Z")

</div>

I wanted a Flow Based Programming tool to be integrated within my workflow. So, built [barfi](https://github.com/krish-adi/barfi), which provides a **streamlit** component. Still work in progress, would appreciate feedback and ideas. Have uses cases? Would be great to know them 🙂

[Here is a demo app.](https://share.streamlit.io/krish-adi/barfi-demo/app.py)

Repository here: [https://github.com/krish-adi/barfi](https://github.com/krish-adi/barfi)

_Quickstart_

```auto
pip install barfi

```

```python
from barfi import st_barfi, Block

my_block = Block(name='My Block')
my_block.add_input()
my_block.add_output()

st_barfi(base_blocks=[my_block])

```

![demo](https://global.discourse-cdn.com/streamlit/original/2X/e/e4bd4d09e7ecb6b979b4f3086a39a016d2fb0e01.gif)

---

<div class="post-metadata">

**Author:** ![AvratanuBiswas](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/avratanubiswas/32/50384_2.png) [@AvratanuBiswas](https://discuss.streamlit.io/u/AvratanuBiswas)\
**Post date:** [March 17, 2022, 12:40pm UTC](https://discuss.streamlit.io/t/barfi-flow-based-programming-for-data-science-new-component/23237/2 "2022-03-17T12:40:07Z")

</div>

Hey @krishadi ,

Welcome to the Streamlit community Forum 🥳 🎈

This is a pretty cool implementation. Love the idea. Great work ! 🤗

Best  
Avra

---

<div class="post-metadata">

**Author:** ![andfanilo](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/andfanilo/32/1040_2.png) [@andfanilo](https://discuss.streamlit.io/u/andfanilo)\
**Post date:** [March 17, 2022, 2:40pm UTC](https://discuss.streamlit.io/t/barfi-flow-based-programming-for-data-science-new-component/23237/3 "2022-03-17T14:40:36Z")

</div>

Welcome @krishadi,

Nice work! I wanted to build a graph-based Pandas query builder one day, maybe I can use this for it 🙂

Feel free to add it to the [Streamlit Components - Community Tracker - Show the Community! - Streamlit](https://discuss.streamlit.io/t/streamlit-components-community-tracker/4634) so we don’t lose track of it.

Have a nice day,  
Fanilo

---

<div class="post-metadata">

**Author:** ![krishadi](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/krishadi/32/3959_2.png) [@krishadi](https://discuss.streamlit.io/u/krishadi)\
**Post date:** [March 17, 2022, 4:09pm UTC](https://discuss.streamlit.io/t/barfi-flow-based-programming-for-data-science-new-component/23237/4 "2022-03-17T16:09:27Z")

</div>

That sounds like an interesting use-case. Let me know if you need some particular UI components to pull it off.

---

<div class="post-metadata">

**Author:** ![chris\_klose](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/chris_klose/32/226_2.png) [@chris\_klose](https://discuss.streamlit.io/u/chris_klose)\
**Post date:** [March 18, 2022, 10:28am UTC](https://discuss.streamlit.io/t/barfi-flow-based-programming-for-data-science-new-component/23237/5 "2022-03-18T10:28:55Z")

</div>

Welcome @krishadi 🎈,

This component could be very promising. A few thoughts and ideas:

- Could it be used to represent an ML process? First I have a loader (specification option of the file path, then I pass the data to a preprocessor e.g. SentenceSplitter or similar, then to the model for training (selection model possible, etc.).
- Another idea could be to use it to model the architecture neural networks? That is, first input layer (with modification options of the neurons, then other layers).

A small demo of how to use the component (maybe with one of my suggestions?) in practice would emphasize the usefulness of the component for me and increase the barrier to use the component.

Best regards  
Chris

---

<div class="post-metadata">

**Author:** ![krishadi](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/krishadi/32/3959_2.png) [@krishadi](https://discuss.streamlit.io/u/krishadi)\
**Post date:** [March 18, 2022, 12:51pm UTC](https://discuss.streamlit.io/t/barfi-flow-based-programming-for-data-science-new-component/23237/6 "2022-03-18T12:51:53Z")

</div>

Hey @chris_klose !

Both the use-cases are definitely possible. For

Case 1: You would need a text input box in the 1st Block (I am building that as we I write this) and the other Blocks you can specify the logic. Do you some parts of the SentenceSplitter and the Model implemented somewhere?

Case 2: You would need an a number input or a dropdown to select the specifics of the layer in the Block. I’ll implement this as well. Do you have an example neural network use-case that I can implement this for?

Thanks for the idea! 😃

Adithya

---

<div class="post-metadata">

**Author:** ![chris\_klose](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/chris_klose/32/226_2.png) [@chris\_klose](https://discuss.streamlit.io/u/chris_klose)\
**Post date:** [March 18, 2022, 3:27pm UTC](https://discuss.streamlit.io/t/barfi-flow-based-programming-for-data-science-new-component/23237/7 "2022-03-18T15:27:25Z")

</div>

Case 1: I guess something super simple would do e.g. tf-idf-transformer, label-encoder etc. from sklearn ( [sklearn.preprocessing.LabelEncoder — scikit-learn 1.0.2 documentation](https://scikit-learn.org/stable/modules/generated/sklearn.preprocessing.LabelEncoder.html)) .  
Would be a cheap version of ML Azure Studio’s interface 😃 .

 ![](https://global.discourse-cdn.com/streamlit/original/2X/e/ed3b516d9c913491a40e6c7f5770f3bf549aaa93.png)

Cas 2: Maybe a simple NN for MNIST with keras? ([The Functional API (keras.io)](https://keras.io/guides/functional_api/)) It would also require to allow other params such as activation by selecting it from a dropdown too.

![image](https://global.discourse-cdn.com/streamlit/original/2X/6/6dbe962430ec6a1caa6c59a832e8364c76030706.png)

---

<div class="post-metadata">

**Author:** ![krishadi](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/krishadi/32/3959_2.png) [@krishadi](https://discuss.streamlit.io/u/krishadi)\
**Post date:** [March 23, 2022, 2:10pm UTC](https://discuss.streamlit.io/t/barfi-flow-based-programming-for-data-science-new-component/23237/8 "2022-03-23T14:10:39Z")

</div>

Hey @chris_klose ,

Now the blocks have input-options.

1. Here is the sample app for Case 1: [https://share.streamlit.io/krish-adi/barfi-cklose/app.py](https://share.streamlit.io/krish-adi/barfi-cklose/app.py) . The docs are not yet updated, but you can use the code [here](https://github.com/krish-adi/barfi-cklose) and [here](https://github.com/krish-adi/barfi-blocks) to understand how to further implement this.

 ![Screenshot 2022-03-23 at 15.07.19](https://global.discourse-cdn.com/streamlit/original/2X/3/3d7e83bf7fd7a366132ff5c7a4bfb442bb6d93bd.png)

1. Now the **Blocks** have various input options you can make use of. Here is a playground of all the inputs: [https://share.streamlit.io/krish-adi/barfi-blocks/app.py](https://share.streamlit.io/krish-adi/barfi-blocks/app.py) . The documentation is not complete for this, but you can use the code of the blocks to understand how to implement it for your use-case. Check it here: [barfi-blocks/blocks at master · krish-adi/barfi-blocks · GitHub](https://github.com/krish-adi/barfi-blocks/tree/master/blocks)

Let me know if you run into any trouble.

Happy coding 🙂

---

<div class="post-metadata">

**Author:** ![Matt\_Marcus](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/matt_marcus/32/21171_2.png) [@Matt\_Marcus](https://discuss.streamlit.io/u/Matt_Marcus)\
**Post date:** [December 19, 2022, 5:33pm UTC](https://discuss.streamlit.io/t/barfi-flow-based-programming-for-data-science-new-component/23237/9 "2022-12-19T17:33:43Z")

</div>

Great work. My use case is a multi-modal AI workflow. Static LLM prompts that kick off multiple responses that can flow into their own workflows and connect with additional models like image gen platforms.

---

<div class="post-metadata">

**Author:** ![Graeme\_Pillemer](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/graeme_pillemer/32/23612_2.png) [@Graeme\_Pillemer](https://discuss.streamlit.io/u/Graeme_Pillemer)\
**Post date:** [March 2, 2023, 9:46am UTC](https://discuss.streamlit.io/t/barfi-flow-based-programming-for-data-science-new-component/23237/10 "2023-03-02T09:46:50Z")

</div>

Hi @Matt_Marcus this is great component!  
Thanks for creating!

A quick question, is it possible to use the compute engine to get\_result from a saved schema without loading the component in to UI?

---

<div class="post-metadata">

**Author:** ![Tushaar](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/tushaar/32/29150_2.png) [@Tushaar](https://discuss.streamlit.io/u/Tushaar)\
**Post date:** [February 4, 2024, 1:16pm UTC](https://discuss.streamlit.io/t/barfi-flow-based-programming-for-data-science-new-component/23237/11 "2024-02-04T13:16:53Z")

</div>

It’s great, thanks a lot. Suggestion: It would be great if it was mobile friendly

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/streamlit/original/3X/c/f/cf4c2ee0d938358f82448c5fe4b9c3c91d7ce19c.svg) [@system](https://discuss.streamlit.io/u/system)\
**Post date:** [February 3, 2025, 1:17pm UTC](https://discuss.streamlit.io/t/barfi-flow-based-programming-for-data-science-new-component/23237/12 "2025-02-03T13:17:36Z")

</div>

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
