"""
Algorithm presents the abstract base class for any Scheduling algorithm.
"""
from abc import ABC, abstractmethod
from topsim.core.cluster import Cluster
from topsim.core.planner import Planner, WorkflowPlan
[docs]
class Scheduling(ABC):
"""
Abstract base class for all Scheduling Algorithms (used in the dynamic
allocation by the 'scheduler').
The Algorithm base class only requires the single `run()` method to be
implemented; the `to_df` may simply be used as a stubb.
Attributes
----------
Notes
-----
It is important to note that the simulation will run with an 'incorrect' algorithm.
An algorithm is 'incorrect' if it attempts to:
- Allocate to a machine that is already occupied
- Schedule a task to a machine that has already been scheduled.
These will raise RuntimeErrors.
It is also important for the algorithm to take into account
"""
# The below constants have been derived from the SDP parametric model.
# TODO these should be set up in the simulation configuration
LOW_REALTIME_RESOURCES = 164
MID_REALTIME_RESOURCES = 281
LOW_MAX_RESOURCES = 896
MID_MAX_RESOURCES = 786
def __init__(self):
self.name = "AbstractAlgorithm"
self.ingest_requirements = 0
@abstractmethod
def to_string(self):
"""
Return the string name of the implemenation of this class
"""
pass
@abstractmethod
def run(self,
cluster: Cluster,
planner: Planner,
clock, plan: WorkflowPlan,
schedule,
task_pool,
**kwargs):
"""
Parameters
----------
cluster: :py:obj:`~topsim.core.cluster.Cluster`
The cluster object for the simulation.
clock: int
Current simulation time (usually generated by)
plan
schedule
children : direct children of task-nodes stored in schedule
# children : direct children of task-nodes stored in schedule
Returns
-------
"""
pass
@abstractmethod
def to_df(self):
"""
Produce a Pandas DataFrame object to return current state of the
scheduling algorithm
Returns
-------
df : pandas.DataFrame
DataFrame with current state
"""