Description
I tried to run the below code, but the below error was raised and not outputs (print) were generated.
ValueError: Could not find block: no valid node ID, node, or label was provided
Traceback:
File "/app/python/source_code/.venv/lib/python3.11/site-packages/streamlit/runtime/scriptrunner/exec_code.py", line 88, in exec_func_with_error_handling
result = func()
^^^^^^
File "/app/python/source_code/.venv/lib/python3.11/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 590, in code_to_exec
exec(code, module.dict)
File "/app/python/source_code/app.py", line 92, in
result_block = flow_schema.block(node_label="Result-1")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/python/source_code/.venv/lib/python3.11/site-packages/barfi/flow/schema/types.py", line 158, in block
raise ValueError(
Code (with light modification):
01: These would be the basic imports to get started
import spark
import pyspark
import os
import pandas as pd
from pyspark.sql import SparkSession
import streamlit as st
from barfi.flow import Block, SchemaManager, ComputeEngine
from barfi.flow.streamlit import st_flow
from databricks import sql
from databricks.sdk.core import Config
import streamlit as st
02: The first block you'll create is one where you can set the number
number_block = Block(name="Number")
number_block.add_output(name="Output 1")
number_block.add_option(
name="display-option", type="display", value="This is a Block with Number option."
)
number_block.add_option(name="number-block-option", type="number")
number_block.add_option(name='my_checkbox', type='checkbox', value=True)
number_block.add_option(name='my_text', type='input', value='default text')
number_block.add_option(name='my_number', type='number', value=42.0)
number_block.add_option(name='my_dropdown', type='select', items=['option1', 'option2'], value='option1')
number_block.add_option(name='my_slider', type='slider', min=0, max=100, value=50)
number_block.add_option(name='my_display', type='display', value='Read-only text')
def number_block_func(self):
value = self.get_option(name="my_number")
self.set_interface(name="Output 1", value=value)
# print("testing_number")
number_block.add_compute(number_block_func)
03: The second block will be one that just prints the number
result_block = Block(name="Result")
result_block.add_input(name="Input 1")
result_block.add_option(
name="display-option", type="display", value="This is a Result Block."
)
def result_block_func(self):
value = self.get_interface(name="Input 1")
print(value)
result_block.add_compute(result_block_func)
04: The st_flow takes in the base blocks and returns the schema
base_blocks=[number_block, result_block]
barfi_result = st_flow(base_blocks)
05: You can view the schema here
st.write(barfi_result)
06: Initialize your compute engine with the base_blocks and execute the schema.
compute_engine = ComputeEngine(base_blocks)
07: Reference to the flow_schema from the barfi_result
flow_schema = barfi_result.editor_schema
compute_engine.execute(flow_schema)
08: You can inspect the result of the execution
result_block = flow_schema.block(node_label="Result-1")
result_block_input_interface_value = result_block.get_interface("Input 1")