-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_complete_workflow.py
More file actions
70 lines (52 loc) · 2.07 KB
/
run_complete_workflow.py
File metadata and controls
70 lines (52 loc) · 2.07 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
60
61
62
63
64
65
66
67
68
69
70
"""Example usage and testing script for the Pyronear spiders."""
import json
import subprocess
from pathlib import Path
def run_spider_filtered_ids():
"""Run the spider_filtered_ids spider to collect and filter camera IDs."""
print("🚀 Starting spider_filtered_ids...")
print("-" * 60)
result = subprocess.run(["scrapy", "crawl", "spider_filtered_ids"], cwd=Path(__file__).parent, capture_output=False)
if result.returncode == 0:
print("\n✅ spider_filtered_ids completed successfully")
# Check if good_ids.json was created
good_ids_path = Path(__file__).parent / "good_ids.json"
if good_ids_path.exists():
with open(good_ids_path, "r") as f:
data = json.load(f)
print(f"\n📊 Found {len(data['camera_ids'])} valid cameras")
print(f"📁 Saved to: {good_ids_path}")
else:
print("\n❌ spider_filtered_ids failed")
return False
return True
def run_spider_get_image():
"""Run the spider_get_image spider to download images for valid cameras."""
print("\n🚀 Starting spider_get_image...")
print("-" * 60)
result = subprocess.run(["scrapy", "crawl", "spider_get_image"], cwd=Path(__file__).parent, capture_output=False)
if result.returncode == 0:
print("\n✅ spider_get_image completed successfully")
else:
print("\n❌ spider_get_image failed")
return False
return True
def main():
"""Run both spiders in sequence."""
print("=" * 60)
print("Pyronear Scraper - Complete Workflow")
print("=" * 60)
# Step 1: Filter cameras
if not run_spider_filtered_ids():
print("\nAborting workflow - filtering step failed")
return
# Step 2: Download images
if not run_spider_get_image():
print("\nDownload step failed, but filtering was successful")
print("You can retry the download step manually")
return
print("\n" + "=" * 60)
print("✅ Complete workflow finished successfully!")
print("=" * 60)
if __name__ == "__main__":
main()