Spaces:
Configuration error
Configuration error
Download message_generators.py from Prabha-AIMLOPS/async-framework-test: direct link, hf CLI and curl.
- Browser
- Download file 1.53 kB
-
https://huggingface.co/spaces/Prabha-AIMLOPS/async-framework-test/resolve/main/message_generators.py
- Command line
-
hf download hf://spaces/Prabha-AIMLOPS/async-framework-test/message_generators.py
-
curl -L -o message_generators.py https://huggingface.co/spaces/Prabha-AIMLOPS/async-framework-test/resolve/main/message_generators.py
1.53 kB
| from abc import ABC, abstractmethod | |
| from typing import Dict, Any | |
| import random | |
| import time | |
| class MessageGenerator(ABC): | |
| def generate_message(self) -> Dict[str, Any]: | |
| pass | |
| class OrderMessageGenerator(MessageGenerator): | |
| def generate_message(self) -> Dict[str, Any]: | |
| order_id = f"ORD-{random.randint(1000, 9999)}" | |
| return { | |
| "order_id": order_id, | |
| "customer_id": f"CUST-{random.randint(100, 999)}", | |
| "amount": round(random.uniform(10.0, 1000.0), 2), | |
| "items": random.randint(1, 10), | |
| "timestamp": time.time() | |
| } | |
| class NotificationMessageGenerator(MessageGenerator): | |
| def generate_message(self) -> Dict[str, Any]: | |
| return { | |
| "notification_id": f"NOTIF-{random.randint(1000, 9999)}", | |
| "user_id": f"USER-{random.randint(100, 999)}", | |
| "type": random.choice(["email", "sms", "push"]), | |
| "priority": random.choice(["high", "medium", "low"]), | |
| "timestamp": time.time() | |
| } | |
| class AnalyticsMessageGenerator(MessageGenerator): | |
| def generate_message(self) -> Dict[str, Any]: | |
| return { | |
| "event_id": f"EVT-{random.randint(1000, 9999)}", | |
| "event_type": random.choice(["page_view", "click", "purchase", "login"]), | |
| "user_id": f"USER-{random.randint(100, 999)}", | |
| "session_id": f"SESSION-{random.randint(1000, 9999)}", | |
| "timestamp": time.time() | |
| } | |