obsei commited on
Commit
fe2c49a
β€’
1 Parent(s): 9b5f7cf

Adding logs panel

Browse files
Files changed (1) hide show
  1. app.py +52 -53
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.error(
 
 
 
 
 
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.\n
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
- source_col, analyzer_col, sink_col = st.columns([1, 1, 1])
30
-
31
- source_list = [k for k in configuration["source"].keys()]
32
- selected_source = source_col.selectbox("Select Observer", source_list)
33
 
34
- analyzer_list = [k for k in configuration["analyzer"].keys()]
35
- selected_analyzer = analyzer_col.selectbox("Select Analyzer", analyzer_list)
36
 
37
- sink_list = [k for k in configuration["sink"].keys()]
38
- selected_sink = sink_col.selectbox("Select Informer", sink_list)
 
39
 
40
- src_icon = get_icon_name(None, configuration["source"][selected_source]["_icon_"])
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:** {src_icon} ➑➑ {analyzer_icon} ➑➑ {sink_icon}",
47
  unsafe_allow_html=True,
48
  )
49
 
50
- src_config = configuration["source"][selected_source]["config"]
51
- render_config(
52
- src_config, source_col, configuration["source"][selected_source]["_help_"]
53
- )
54
-
55
- analyzer_type_config = configuration["analyzer"][selected_analyzer]
56
- analyzer_type_list = []
57
- for k in analyzer_type_config.keys():
58
- if k != "_icon_":
59
- analyzer_type_list.append(k)
60
- selected_analyzer_type = analyzer_col.selectbox(f"analyzer type", analyzer_type_list)
61
- analyzer_config = None
62
- if "config" in analyzer_type_config[selected_analyzer_type]:
63
- analyzer_config = analyzer_type_config[selected_analyzer_type]["config"]
64
- render_config(
65
- analyzer_config,
66
- analyzer_col,
67
- analyzer_type_config[selected_analyzer_type]["_help_"],
68
- )
69
- if len(analyzer_type_config[selected_analyzer_type]["analyzer"]) > 1:
70
- render_config(
71
- analyzer_type_config[selected_analyzer_type]["analyzer"], analyzer_col
72
- )
73
-
74
- sink_config = configuration["sink"][selected_sink]["config"]
75
- render_config(sink_config, sink_col, configuration["sink"][selected_sink]["_help_"])
76
-
77
- generate_config = {
78
- "source": configuration["source"][selected_source]["source"],
79
- "source_config": src_config,
80
- "analyzer_config": analyzer_config,
81
- "analyzer": analyzer_type_config[selected_analyzer_type]["analyzer"],
82
- "sink": configuration["sink"][selected_sink]["sink"],
83
- "sink_config": sink_config,
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)")