Update app.py
Browse files
app.py
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
import streamlit as st
|
2 |
-
|
3 |
from backend_services import ServiceOne, ServiceTwo
|
4 |
|
5 |
# List of available services
|
@@ -22,11 +22,29 @@ for service_name in selected_services:
|
|
22 |
# User-defined workflow execution
|
23 |
if st.button("Run Workflow"):
|
24 |
input_data = ... # Define your input data
|
|
|
25 |
for service_name in selected_services:
|
26 |
service_instance = services[service_name]
|
27 |
service_instance.parameters = parameters[service_name]
|
28 |
output_data = service_instance.execute(input_data)
|
29 |
input_data = output_data
|
|
|
|
|
|
|
|
|
|
|
30 |
|
31 |
# Display the final output
|
32 |
st.success("Workflow executed successfully. Output: {}".format(input_data))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import streamlit as st
|
2 |
+
import yaml # Import the pyyaml package
|
3 |
from backend_services import ServiceOne, ServiceTwo
|
4 |
|
5 |
# List of available services
|
|
|
22 |
# User-defined workflow execution
|
23 |
if st.button("Run Workflow"):
|
24 |
input_data = ... # Define your input data
|
25 |
+
workflow_config = [] # List to store the workflow configuration
|
26 |
for service_name in selected_services:
|
27 |
service_instance = services[service_name]
|
28 |
service_instance.parameters = parameters[service_name]
|
29 |
output_data = service_instance.execute(input_data)
|
30 |
input_data = output_data
|
31 |
+
# Store the service name and parameters in the workflow configuration
|
32 |
+
workflow_config.append({
|
33 |
+
"service": service_name,
|
34 |
+
"parameters": service_instance.parameters
|
35 |
+
})
|
36 |
|
37 |
# Display the final output
|
38 |
st.success("Workflow executed successfully. Output: {}".format(input_data))
|
39 |
+
|
40 |
+
# Export workflow configuration as YAML or JSON
|
41 |
+
export_format = st.radio("Export Format", ["YAML", "JSON"])
|
42 |
+
if st.button("Export Workflow"):
|
43 |
+
if export_format == "YAML":
|
44 |
+
with open("workflow_config.yaml", "w") as yaml_file:
|
45 |
+
yaml.dump(workflow_config, yaml_file)
|
46 |
+
st.success("Workflow configuration exported as YAML.")
|
47 |
+
elif export_format == "JSON":
|
48 |
+
with open("workflow_config.json", "w") as json_file:
|
49 |
+
json.dump(workflow_config, json_file, indent=4)
|
50 |
+
st.success("Workflow configuration exported as JSON.")
|