YAML Metadata Warning:empty or missing yaml metadata in repo card
Check out the documentation for more information.
import json from datetime import datetime, timedelta
Define machine schedule
schedule = [] start_time = datetime(2024, 11, 19, 9, 0) task_duration = timedelta(minutes=30) downtime = {"start_time": "12:00", "end_time": "12:30", "reason": "Lunch break"}
tasks = [ {"task_type": "production", "priority": "high", "resources": ["operator_1", "tool_A"], "notes": "Start with batch 101."}, {"task_type": "maintenance", "priority": "medium", "resources": ["technician_2", "wrench_set"], "notes": "Check for wear and tear."}, {"task_type": "calibration", "priority": "low", "resources": ["operator_3"], "notes": "Recalibrate sensors before production resumes."} ]
for i, task in enumerate(tasks): task_entry = { "task_id": i + 1, "start_time": start_time.strftime('%H:%M'), "end_time": (start_time + task_duration).strftime('%H:%M'), "status": "pending", "dependencies": [] if i == 0 else [i], **task } schedule.append(task_entry) start_time += task_duration
Add notifications
notifications = { "enable_email_alerts": True, "recipients": ["manager@example.com", "techlead@example.com"] }
Final JSON structure
schedule_json = { "date": "2024-11-19", "machine_schedule": schedule, "downtime": downtime, "notifications": notifications }
Save to JSON file
output_file = "enhanced_machine_schedule.json" with open(output_file, "w") as file: json.dump(schedule_json, file, indent=4)
print(f"Enhanced schedule saved to {output_file}.")