-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_examples.py
More file actions
executable file
·59 lines (50 loc) · 2.19 KB
/
run_examples.py
File metadata and controls
executable file
·59 lines (50 loc) · 2.19 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
58
59
#!/usr/bin/env python3
"""
Simple script to run the SaF memory examples.
"""
import sys
import argparse
import subprocess
from pathlib import Path
def main():
parser = argparse.ArgumentParser(description='Run SaF Memory examples')
parser.add_argument('example', choices=['story', 'interactive'],
help='Which example to run: "story" for story_memory.py, "interactive" for interactive_memory.py')
args = parser.parse_args()
# Get the directory of this script
script_dir = Path(__file__).parent.absolute()
examples_dir = script_dir / 'examples'
if args.example == 'story':
script_path = examples_dir / 'story_memory.py'
print("Running the Story Memory example...")
run_examples([script_path], "Story Memory")
elif args.example == 'interactive':
script_path = examples_dir / 'interactive_memory.py'
print("Running the Interactive Memory Demo...")
run_examples([script_path], "Interactive Memory")
def run_examples(script_paths, example_name):
"""Run the specified example scripts."""
success = True
for script_path in script_paths:
print(f"\nExecuting {script_path.name}...")
try:
subprocess.run([sys.executable, script_path], check=True)
except subprocess.CalledProcessError:
print(f"❌ Example execution failed for {script_path.name}. Please check the error messages above.")
success = False
except FileNotFoundError:
print(f"❌ Error: Could not find the example script at {script_path}")
success = False
if success and len(script_paths) > 1:
print(f"\n✅ All examples completed successfully!")
elif success:
print(f"\n✅ {example_name} example completed successfully!")
else:
print(f"\n❌ Some examples failed. Please check the error messages above.")
if __name__ == "__main__":
if len(sys.argv) == 1:
print("Please specify which example to run:")
print(" python run_examples.py story - Run the Story Memory example")
print(" python run_examples.py interactive - Run the Interactive Memory Demo")
sys.exit(1)
main()