Spaces:
Sleeping
Sleeping
Download my_env/tasks.py from SheSync/meta-hackathon-project: direct link, hf CLI and curl.
- Browser
- Download file 1.98 kB
-
https://huggingface.co/spaces/SheSync/meta-hackathon-project/resolve/main/my_env/tasks.py
- Command line
-
hf download hf://spaces/SheSync/meta-hackathon-project/my_env/tasks.py
-
curl -L -o tasks.py https://huggingface.co/spaces/SheSync/meta-hackathon-project/resolve/main/my_env/tasks.py
1.98 kB
| # tasks.py — defines all 3 tasks and their action schema | |
| TASKS = [ | |
| { | |
| "task_id": 1, | |
| "name": "Basic Moisture Control", | |
| "difficulty": "easy", | |
| "description": "Keep soil moisture between 40–70% for 7 days.", | |
| "max_steps": 7, | |
| "goal": "moisture_in_range", | |
| "reward_hint": "Maintain soil moisture within the optimal range." | |
| }, | |
| { | |
| "task_id": 2, | |
| "name": "Weather Adaptive Irrigation", | |
| "difficulty": "medium", | |
| "description": "Manage irrigation across 14 days with changing weather.", | |
| "max_steps": 14, | |
| "goal": "handle_weather", | |
| "reward_hint": "Maintain soil moisture within the optimal range." | |
| }, | |
| { | |
| "task_id": 3, | |
| "name": "Full Season Management", | |
| "difficulty": "hard", | |
| "description": "Manage a full 30-day crop season across Seedling, Growing, and Mature stages.", | |
| "max_steps": 30, | |
| "goal": "full_season", | |
| "reward_hint": "Maintain soil moisture within the optimal range." | |
| } | |
| ] | |
| ACTION_SCHEMA = { | |
| "type": "discrete", | |
| "n": 4, | |
| "actions": { | |
| 0: "no_water", | |
| 1: "low_water", | |
| 2: "medium_water", | |
| 3: "high_water" | |
| }, | |
| "description": "Choose how much water to give the crop each day." | |
| } | |
| def get_all_tasks(): | |
| """Returns the list of all tasks with action schema.""" | |
| return { | |
| "tasks": TASKS, | |
| "action_schema": ACTION_SCHEMA | |
| } | |
| def get_task_by_id(task_id): | |
| """Returns a single task by its ID.""" | |
| for task in TASKS: | |
| if task["task_id"] == task_id: | |
| return task | |
| return None | |
| # Quick test | |
| if __name__ == "__main__": | |
| print("All tasks:") | |
| result = get_all_tasks() | |
| for task in result["tasks"]: | |
| print(f" Task {task['task_id']}: {task['name']} ({task['difficulty']})") | |
| print("\nAction schema:") | |
| for k, v in result["action_schema"]["actions"].items(): | |
| print(f" {k} = {v}") |