Spaces:
Runtime error
Runtime error
Adding logs panel
Browse files
app.py
CHANGED
|
@@ -10,11 +10,15 @@ st.title("Obsei Demo").markdown(
|
|
| 10 |
get_icon_name("Obsei Demo", logo_url, 60, 35), unsafe_allow_html=True
|
| 11 |
)
|
| 12 |
|
| 13 |
-
st.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
"""
|
| 15 |
**Note:** Demo run will require some secure information based on source or sink selected,
|
| 16 |
-
if you don't trust this environment please close the app
|
| 17 |
-
Do not share and commit generated file as it may contains secure information.
|
| 18 |
"""
|
| 19 |
)
|
| 20 |
|
|
@@ -26,69 +30,64 @@ Do not share and commit generated file as it may contains secure information.
|
|
| 26 |
download_yaml_col,
|
| 27 |
) = st.columns([2, 2, 1, 1, 1])
|
| 28 |
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
source_list = [k for k in configuration["source"].keys()]
|
| 32 |
-
selected_source = source_col.selectbox("Select Observer", source_list)
|
| 33 |
|
| 34 |
-
|
| 35 |
-
|
| 36 |
|
| 37 |
-
|
| 38 |
-
|
|
|
|
| 39 |
|
| 40 |
-
|
| 41 |
-
analyzer_icon = get_icon_name(
|
| 42 |
-
None, configuration["analyzer"][selected_analyzer]["_icon_"]
|
| 43 |
-
)
|
| 44 |
-
sink_icon = get_icon_name(None, configuration["sink"][selected_sink]["_icon_"])
|
| 45 |
pipeline_col.header("Pipeline").markdown(
|
| 46 |
-
f"**Pipeline:** {
|
| 47 |
unsafe_allow_html=True,
|
| 48 |
)
|
| 49 |
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
)
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
"
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
|
| 86 |
python_code = generate_python(generate_config)
|
| 87 |
yaml_code = generate_yaml(generate_config)
|
| 88 |
|
| 89 |
execute_button = execute_col.button("π Execute")
|
| 90 |
if execute_button:
|
| 91 |
-
execute_workflow(generate_config, spinner_col)
|
| 92 |
|
| 93 |
with download_python_col:
|
| 94 |
download_button(python_code, "generated-code.py", "π Download (.py)")
|
|
|
|
| 10 |
get_icon_name("Obsei Demo", logo_url, 60, 35), unsafe_allow_html=True
|
| 11 |
)
|
| 12 |
|
| 13 |
+
st.success(
|
| 14 |
+
"""
|
| 15 |
+
Please β the repo and share the feedback at https://github.com/obsei/obsei
|
| 16 |
+
"""
|
| 17 |
+
)
|
| 18 |
+
st.warning(
|
| 19 |
"""
|
| 20 |
**Note:** Demo run will require some secure information based on source or sink selected,
|
| 21 |
+
if you don't trust this environment please close the app.
|
|
|
|
| 22 |
"""
|
| 23 |
)
|
| 24 |
|
|
|
|
| 30 |
download_yaml_col,
|
| 31 |
) = st.columns([2, 2, 1, 1, 1])
|
| 32 |
|
| 33 |
+
col_map = dict()
|
| 34 |
+
col_map["source"], col_map["analyzer"], col_map["sink"] = st.columns([1, 1, 1])
|
|
|
|
|
|
|
| 35 |
|
| 36 |
+
selected = {}
|
| 37 |
+
name_map = {"source": "Observer", "analyzer": "Analyzer", "sink": "Informer"}
|
| 38 |
|
| 39 |
+
for node_name, col in col_map.items():
|
| 40 |
+
item_list = [k for k in configuration[node_name].keys()]
|
| 41 |
+
selected[node_name] = col.selectbox(f"Select {name_map[node_name]}", item_list)
|
| 42 |
|
| 43 |
+
icons = [get_icon_name(None, configuration[k][v]["_icon_"]) for k, v in selected.items()]
|
|
|
|
|
|
|
|
|
|
|
|
|
| 44 |
pipeline_col.header("Pipeline").markdown(
|
| 45 |
+
f"**Pipeline:** {icons[0]} β‘β‘ {icons[1]} β‘β‘ {icons[2]}",
|
| 46 |
unsafe_allow_html=True,
|
| 47 |
)
|
| 48 |
|
| 49 |
+
generate_config = {}
|
| 50 |
+
log_component = {}
|
| 51 |
+
for node_name, node_value in selected.items():
|
| 52 |
+
type_config = configuration[node_name][node_value]
|
| 53 |
+
if node_name == "analyzer":
|
| 54 |
+
type_list = []
|
| 55 |
+
for config_key in type_config.keys():
|
| 56 |
+
if config_key != "_icon_":
|
| 57 |
+
type_list.append(config_key)
|
| 58 |
+
selected_type = col_map[node_name].selectbox(f"{name_map[node_name]} Type", type_list)
|
| 59 |
+
type_config = type_config[selected_type]
|
| 60 |
+
|
| 61 |
+
config = None
|
| 62 |
+
if "config" in type_config:
|
| 63 |
+
config = type_config["config"]
|
| 64 |
+
if type_config["_help_"] is not None:
|
| 65 |
+
with col_map[node_name].expander("Config Help Info", False):
|
| 66 |
+
help_area = "\n".join(type_config["_help_"])
|
| 67 |
+
st.code(f"{help_area}")
|
| 68 |
+
|
| 69 |
+
config_expander = None
|
| 70 |
+
if config is not None:
|
| 71 |
+
config_expander = col_map[node_name].expander(f"Configure {name_map[node_name]}", False)
|
| 72 |
+
render_config(config, config_expander)
|
| 73 |
+
|
| 74 |
+
if node_name == "analyzer" and node_name in type_config and len(type_config[node_name]) > 1:
|
| 75 |
+
config_expander = config_expander or col_map[node_name].expander(f"Configure {name_map[node_name]}", False)
|
| 76 |
+
render_config(type_config["analyzer"], config_expander)
|
| 77 |
+
|
| 78 |
+
generate_config[node_name] = type_config[node_name]
|
| 79 |
+
generate_config[f"{node_name}_config"] = config
|
| 80 |
+
|
| 81 |
+
log_expander = col_map[node_name].expander(f"{name_map[node_name]} Logs", False)
|
| 82 |
+
log_component[node_name] = log_expander.empty()
|
| 83 |
+
log_component[node_name].write("Run \"π Execute\" first")
|
| 84 |
|
| 85 |
python_code = generate_python(generate_config)
|
| 86 |
yaml_code = generate_yaml(generate_config)
|
| 87 |
|
| 88 |
execute_button = execute_col.button("π Execute")
|
| 89 |
if execute_button:
|
| 90 |
+
execute_workflow(generate_config, spinner_col, log_component)
|
| 91 |
|
| 92 |
with download_python_col:
|
| 93 |
download_button(python_code, "generated-code.py", "π Download (.py)")
|