-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrun.py
More file actions
58 lines (46 loc) · 1.78 KB
/
run.py
File metadata and controls
58 lines (46 loc) · 1.78 KB
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import subprocess
import sys
import argparse
from pathlib import Path
current_dir = Path.cwd()
def run_streamlit():
"""Function to run Streamlit app"""
print("Starting Streamlit...")
try:
subprocess.run([sys.executable, "-m", "streamlit", "run", "streamlit/app.py"])
except KeyboardInterrupt:
print("\nStreamlit stopped gracefully.")
def run_snowflake():
"""Function to run snowflake/main.py script"""
print("Running snowflake main.py...")
try:
subprocess.run([sys.executable, "snowflake/main.py"])
except KeyboardInterrupt:
print("\nKeyboardInterrupted Execution stopped.")
def run_trulens():
"""Function to run trulens/main.py script"""
print("Running trulens main.py...")
try:
subprocess.run([sys.executable, "-u", f"{current_dir}/snowflake/trulens_eval.py"])
except KeyboardInterrupt:
print("\nKeyboardInterrupted Execution stopped.")
def main():
parser = argparse.ArgumentParser(description="Run Streamlit or Snowflake app.")
subparsers = parser.add_subparsers(dest='command', help="Subcommands")
# Subcommand for running Streamlit
subparsers.add_parser('app:streamlit', help="Run Streamlit app")
# Subcommand for running Snowflake main script
subparsers.add_parser('app:main', help="Run snowflake main.py")
# Subcommand for running Trulens main script
subparsers.add_parser('app:trulens', help="Run trulens main.py")
args = parser.parse_args()
if args.command == 'app:streamlit':
run_streamlit()
elif args.command == 'app:main':
run_snowflake()
elif args.command == 'app:trulens':
run_trulens()
else:
print("Invalid command. Use 'app:streamlit' or 'app:main' or 'app:trulens'.")
if __name__ == "__main__":
main()