Skip to content
This repository has been archived by the owner on Nov 1, 2023. It is now read-only.

Commit

Permalink
removing duplicated class
Browse files Browse the repository at this point in the history
  • Loading branch information
chkeita committed Oct 16, 2020
1 parent 0da31d3 commit 61f40d2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 30 deletions.
23 changes: 4 additions & 19 deletions src/api-service/__app__/onefuzzlib/tasks/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,8 @@
from onefuzztypes.enums import ErrorCode, TaskState
from onefuzztypes.models import Error
from onefuzztypes.models import Task as BASE_TASK
from onefuzztypes.models import (
TaskConfig,
TaskVm,
TaskHeartbeatEntry,
TaskHeartbeat
)
from onefuzztypes.models import TaskConfig, TaskHeartbeat, TaskHeartbeatEntry, TaskVm
from pydantic import ValidationError

from ..azure.creds import get_fuzz_storage
from ..azure.image import get_os
Expand All @@ -25,8 +21,6 @@
from ..pools import Node, Pool, Scaleset
from ..proxy_forward import ProxyForward

from pydantic import ValidationError


class Task(BASE_TASK, ORMMixin):
def ready_to_schedule(self) -> bool:
Expand Down Expand Up @@ -280,28 +274,19 @@ def key_fields(cls) -> Tuple[str, str]:
def try_add_heartbeat(cls, raw: Dict) -> bool:
now = datetime.utcnow()

# class TaskHeartbeatEntry(BaseModel):
# task_id: UUID
# machine_id: UUID
# data: List[Dict[str, HeartbeatType]]

# class TaskHeartbeatSummary(BaseModel):
# machine_id: UUID
# timestamp: Optional[datetime]

try:
entry = TaskHeartbeatEntry.parse_obj(raw)
task = cls.try_get_by_task_id(entry.task_id)
# heartbeats: Optional[Dict[UUID, List[TaskHeartbeatSummary]]]
if task:

if not task.heartbeats:
task.heartbeats = {}
summary = task.heartbeats
for hb in entry.data:
for key in hb:
hb_type = hb[key]

summary[entry.machine_id, hb_type] = TaskHeartbeat(
machine_id=entry.machine_id, timestamp=now, type=hb_type
)
Expand Down
11 changes: 0 additions & 11 deletions src/pytypes/onefuzztypes/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -435,17 +435,6 @@ class TaskHeartbeat(BaseModel):
type: HeartbeatType


# class TaskHeartbeatSummary(BaseModel):
# summary:


class TaskHeartbeat(BaseModel):
task_id: UUID
heartbeat_id: str
machine_id: UUID
heartbeat_type: HeartbeatType


class NodeHeartbeatEntry(BaseModel):
node_id: UUID
data: List[Dict[str, HeartbeatType]]
Expand Down

0 comments on commit 61f40d2

Please sign in to comment.