|
import streamlit as st |
|
import yaml |
|
from services import ServiceOne, ServiceTwo |
|
import json |
|
from pathlib import Path |
|
|
|
|
|
services = { |
|
"Service One": ServiceOne(), |
|
"Service Two": ServiceTwo() |
|
} |
|
|
|
|
|
selected_services = st.multiselect("Select Services", list(services.keys())) |
|
parameters = {} |
|
|
|
|
|
for service_name in selected_services: |
|
service_instance = services[service_name] |
|
parameters[service_name] = {} |
|
for param_name in service_instance.parameters: |
|
parameters[service_name][param_name] = st.text_input(f"Enter {param_name} for {service_name}") |
|
|
|
|
|
if st.button("Run Workflow"): |
|
input_data = ... |
|
workflow_config = [] |
|
for service_name in selected_services: |
|
service_instance = services[service_name] |
|
service_instance.parameters = parameters[service_name] |
|
output_data = service_instance.execute(input_data) |
|
input_data = output_data |
|
|
|
workflow_config.append({ |
|
"service": service_name, |
|
"parameters": service_instance.parameters |
|
}) |
|
|
|
|
|
st.success("Workflow executed successfully. Output: {}".format(input_data)) |
|
|
|
|
|
export_format = st.radio("Export Format", ["YAML", "JSON"]) |
|
|
|
with open("workflow_config.json", "w") as json_file: |
|
json.dump(workflow_config, json_file, indent=4) |
|
|
|
|
|
st.download_button("Export Config", |
|
data=Path("workflow_config.json").read_text(), |
|
file_name="workflow_config.json", |
|
mime="application/json") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|