File size: 984 Bytes
cdd65a4
 
 
61352c4
 
 
 
 
cdd65a4
 
 
61352c4
 
 
cdd65a4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import gradio as gr
import subprocess
import sys
import os

# Function to install requirements
def install_requirements():
    subprocess.run([sys.executable, "-m", "pip", "install", "-r", "requirements.txt"])

# Define the function to run the entire script
def run_entsoe_script():
    # Ensure dependencies are installed first
    install_requirements()

    # Run the script as a subprocess
    result = subprocess.run([sys.executable, 'daily_energy_pipeline.py'], capture_output=True, text=True)
    
    # Return the script's output or any errors
    return result.stdout if result.returncode == 0 else result.stderr

# Define Gradio interface (No inputs since we're running the entire script)
interface = gr.Interface(
    fn=run_entsoe_script,
    inputs=[],  # No inputs needed
    outputs="text",  # Output the script's result as text
    title="Energy Load Prediction",
    description="Run the energy load prediction pipeline."
)

# Launch the interface
interface.launch()