Git Product home page Git Product logo

krish-adi / barfi Goto Github PK

View Code? Open in Web Editor NEW
539.0 7.0 62.0 11.61 MB

Python Flow Based Programming environment that provides a graphical programming environment.

Home Page: https://barfi.readthedocs.io

License: MIT License

Python 60.08% JavaScript 1.81% HTML 1.56% Vue 16.05% CSS 19.68% TypeScript 0.41% Makefile 0.41%
python framework flow-based-programming graphical-programming data-science ml jupyter-notebook jupyter streamlit ai-ml

barfi's Introduction

krishadi.com

This repository stores the build files for krishadi.com, my personal blog.

The theme jekyll-book is used here.

w/ Obsidian

I have set this up to se with obsidian. It uses the templater community plugin, and the templates are located inside _templates.

Usage

Posts are within the folder _posts. Use the folder structure based on the category of the post. The mandatory index file 0000-01-01-index.md inside the category folder within posts.

_posts/:category/0000-01-01-index.md

With contents:

---
title: index
date: 0000-01-01
category: code
layout: category-index
---

To build the blog and serve it locally, run bundle exec jekyll serve.

barfi's People

Contributors

fkarg avatar krish-adi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

barfi's Issues

[Feature Request] Add style parameter to barfi.st_barfi

It is impossible, or very difficult, to change the styling of Barfi to fit a specific project.

For example, I wanted to remove the Menu and Execute buttons using css because they don't fit the functionality of my program, but the Barfi graph is locked behind an iframe and I could not find a way around it.

I propose that a new parameter, style, should be added to bf.st_barfi, which is a string of css that is inserted into the iframe (I don't know how this would be done, or if it is feasible).

The below example would create a Barfi graph where the color of the backgrounds of the nodes are red.

bf.st_barfi(
    [],
    style="""
        .node > .__content {
            background: red;
        }
    """,
)

Which looks like this:
Screenshot from 2023-09-21 11-34-02

Variable number of inputs/outputs

Hi. Barfi looks really cool.

I'm trying to let user edit a workflow - how statuses can change for specific job - without any computations, just a graph. Don't really like graphviz (noninteractive and ugly). Thought to try Barfi for this. I'd appreciate a few answers. Docs look a little bit limited. Is it possible to make blocks with any number of input/output connections (well, just a list), so that user could interconnect them however they want? Also, can graphs be cyclic without computations.

[Feature Request] Input/Output decorator with type

Hello,

I'm considering the use of your lib, but i would like to be able to add decorators to the inputs/outputs to have types,
like integer / String / other and to only be able to do connection if the input / output have matching types.
The types could be visually identified by changing the color of the connection dot or something like this.
Do you think it's feasible maybe i can get into the adjustement my self, but i would need some guidance in your code to do it properly (i currently didn't take time to dig in the code too much).
Best regards

set_option problem

hello, with this script I am trying to display the output of the slider block in a result block without result. what is wrong with my script? thanks in advance

from barfi import st_barfi, barfi_schemas, Block
import streamlit as st

slider_block = Block(name='Slider')

slider_block.add_input()
slider_block.add_output()
slider_block.add_option(name='display-option', type='display',value='This is a Block with Slider option.')
slider_block.add_option(name='slider-option-1', type='slider', min=0, max=10, value=2.5)

def slider_block_func(self):
input_1_value = self.get_interface(name='Input 1')

slider_1_value = self.get_option(name='slider-option-1')

self.set_interface(name='Output 1', value=slider_1_value)

slider_block.add_compute(slider_block_func)

result = Block(name='Result')
result.add_input()
result.add_option(name='ValueText', type='display', value='toto')

def result_func(self):
in_1 = self.get_interface(name='Input 1')
self.set_option(name='ValueText',value=str(in_1))
result.add_compute(result_func)

compute_engine = st.checkbox('Activate barfi compute engine', value=True)
barfi_result = st_barfi(base_blocks=[ slider_block, result])
if barfi_result:
st.write(barfi_result)

[Feature Request] Add hidden as a valid type for the build_option function in option_builder.py

In option_builder (https://github.com/krish-adi/barfi/blob/main/barfi/option_builder.py), the build_option function sets the option and valid types.

When we associate a function to a block e.g.

my_function_name(self):
     do_something
     
my_block.add_compute(my_function_name)

There is no way to pass custom params to the associated function that are not exposed to the user. It's beneficial to be able to pass params to the block's associated function without exposing them to the user.

If we try to do something like add a new param e.g.

my_function_name(self, my_custom_param):
     do_something
     
my_block.add_compute(my_function_name(my_custom_param=my_custom_param))

It won't work because there's no way to provide for both self and my_custom_param.

There are several use cases for this but one is using the streamlit session_state and modifying it based upon which block is running.

Let's say we want a message (streamlit.info) that shows users which block is currently running. We can pass the session state to each block's function and modify the message to output which block is running. This is helpful for blocks with long running tasks and general error messaging to the user when something went wrong.

Parameterize the location of saved schemas

Currently the schemas saved from the widget on streamlit ends up in the root of the application and itsnt customizeable. It would be great if we could configure a prefix for this path with the default option being the root of the application.

Need more documentation!

Hey @krish-adi ,
The package was really helpful,
I think it will be help full to add more details on classes

  • Blocks
  • Computation engine
    and also about functions and its parameters

I had hard time finding it from code

Asynchronous execution

Hi. Thanks for the great product.
Does Barfi support asynchronous execution?
As far as I have tried, all nodes seem to be executed in sequence.

[Bug]Use same type component multiple times

Scene: Use same type component multiple times
Bug: When call get_interface() , the result is wrong
image

image
image

image
image

the right result:
barfi_result['Noop-1"]['block'].get_interface(name='Output')
image
barfi_result['Noop-2"]['block'].get_interface(name='Output')
image

Enhancement Request: Categorize Blocks

The submenu for new blocks gets really long if you have quite a few blocks. Wondering if it is possible to categorize blocks so that in the JS frontend when you create a new block, you see the main category and then the blocks that fall under that specific category.

a non backend coupled version, like an open API version

Hey krish-adi,

would it be thinkable to have a decoupled version of barfi with no strings attached to streamlit or nodejs?
I understand there is the backend which need to be present in some way, how you would document the backend API and one could setup his own backend? Once the build backend is working it could be shared too, maybe that way more implementations show up.

We try to use your or any similar system but they all come bound to some kind of a server which I dont need or dont like. I would like to have a totaly open system where I could implement my own backend. Yes thats additional work on my side but at least I would have more control about how and where I implement the system. Like there is a way to have a browser only barfi but the backend has to be build by providing APIs which provide what ever barfi needs in the backend to work.

Sounds weired but might be an idea after all ;)

Thanks for your time and also thanks for all the effort you spend building barfi, we already have plenty of fun with it even with the "limitations" of being nailed to use streamlit for now.

Cheers
Werner

"hidden" inputs/outputs?

Is there an option for hidden inputs or outputs? meaning a default input/output that is carried down each block without the user interaction?

Migrate to baklavajs v2

It would be wonderful to try baklavajs v2, which is now in beta. Would it be possible to create a branch of barfi that is updated to work with baklavajs v2? There are some nice features like subgrouping that would be very helpful.

Here is the beta announcement:
newcat/baklavajs#219

many thanks!

Enhancment (with code): Add a delete_schema function in schema_loader.py

In my testing I have many schemas and needed a way to allow users to delete and manage schemas without coding.

Schemas get somewhat unwieldy if there are many in barfi.schema. I have a multi-page streamlit app (barfi is the first page) and one of the other pages is a schema manager that utilizes barfi's schema_loader.py to allow users to view, add, or clone existing pickled schemas in the schemas.barfi file. I could write my own utility module but I'm using barfi's own schema loader functions since they already manage schema.barfi.

You don't have a contribution guide in this repo so I am adding the code here instead of making a pull request.

def delete_schema(schema_name: str):
    try:
        with open('schemas.barfi', 'rb') as handle_read:
            schemas = pickle.load(handle_read)
    except FileNotFoundError:
        schemas = {}
    if schema_name in schemas:
        del schemas[schema_name]
    else:
        raise ValueError(
            f'Schema :{schema_name}: not found in the saved schemas')
    with open('schemas.barfi', 'wb') as handle_write:
        pickle.dump(schemas, handle_write, protocol=pickle.HIGHEST_PROTOCOL)

Type Error in compute_engine.py After Upgrading to v0.6.0

Love the new feature with block categorization - everything works as expected until you hit the Execute button.

To Re-Create:

  1. Use the new base_blocks_category dict
  2. Add at least 2 blocks
  3. hit the execute button

Versions:

  • Python 3.8
  • barfi v0.6.0

relative code:

base_blocks = [logic_filter, to_dataframe, use_cached_data, save_to_cache, barchart_output, excel_output]
base_blocks_category = {
                        'Logic and Filter Blocks': [logic_filter],
                        'Data Conversion Blocks': [to_dataframe],
                        'Input Blocks':[use_cached_data],
                        'Output Blocks':[json_output, excel_output, barchart_output, save_to_cache]
                        }

barfi_result = st_barfi(
                base_blocks=base_blocks_category,
                compute_engine=True,
                load_schema=load_schema)

Error

  File "/Users/zach.brewer/Dev/pythonprojects/.virtualenvs/test-nodepython/lib/python3.8/site-packages/barfi/__init__.py", line 87, in st_barfi
    _ce._map_block_link()
  File "/Users/zach.brewer/Dev/pythonprojects/.virtualenvs/test-nodepython/lib/python3.8/site-packages/barfi/compute_engine.py", line 47, in _map_block_link
    _parent_block = next(
  File "/Users/zach.brewer/Dev/pythonprojects/.virtualenvs/test-nodepython/lib/python3.8/site-packages/barfi/compute_engine.py", line 48, in <genexpr>
    _b for _b in self._blocks if _b._type == _block['type'])
AttributeError: 'str' object has no attribute '_type'

A few features : )

Hi!
I've started using barfi in streamlit with stable diffusion. It will be a great tool for node based ai generation I think.
I have a few things I'm missing, and wondering if it was possible to implement the following:

Image/Video output on the node, slider step adjustment.

Also, id like cycles. Do you have a recommendation how it would be possible?
I have built a quick function that would stop my iterations when goal is reached. In my understanding its the id's that are problematic, but we could check for "first and last" blocks, and increment id's when a loop is reached. What do you think?

First ones to occur, but surely more to come. : ))

Looks like we are going to use it very intensly, given, some features can be updated : )

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.