Download libs/adaptive/queue_manager.py from QPromaQ/Docking_project: direct link, hf CLI and curl.
- Browser
- Download file 1.04 kB
-
https://huggingface.co/datasets/QPromaQ/Docking_project/resolve/main/libs/adaptive/queue_manager.py
- Command line
-
hf download hf://datasets/QPromaQ/Docking_project/libs/adaptive/queue_manager.py
-
curl -L -o queue_manager.py https://huggingface.co/datasets/QPromaQ/Docking_project/resolve/main/libs/adaptive/queue_manager.py
1.04 kB
| from __future__ import annotations | |
| from dataclasses import dataclass | |
| from typing import Dict, Iterable, List | |
| from .state import QueueItem | |
| VALID_STATUSES = {"active", "deprioritized", "frozen", "completed"} | |
| class QueueManager: | |
| items: Dict[str, QueueItem] | |
| def from_items(cls, items: Iterable[QueueItem]) -> "QueueManager": | |
| return cls(items={item.ligand_id: item for item in items}) | |
| def set_status(self, ligand_id: str, status: str) -> None: | |
| if status not in VALID_STATUSES: | |
| raise ValueError(f"Invalid status: {status}") | |
| self.items[ligand_id].status = status | |
| def active_items(self) -> List[QueueItem]: | |
| return [item for item in self.items.values() if item.status == "active"] | |
| def completed_items(self) -> List[QueueItem]: | |
| return [item for item in self.items.values() if item.status == "completed"] | |
| def ordered_active(self) -> List[QueueItem]: | |
| return sorted(self.active_items(), key=lambda item: item.priority, reverse=True) | |