Skip to content

Commit

Permalink
Update stubs for Python frontend.
Browse files Browse the repository at this point in the history
  • Loading branch information
sukritkalra committed Jan 19, 2024
1 parent 4652833 commit 0d0bb52
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 28 deletions.
50 changes: 26 additions & 24 deletions schedulers/tetrisched/python/Expressions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,64 +134,66 @@ void defineSTRLExpressions(py::module_& tetrisched_m) {
tetrisched::Partitions partitions,
uint32_t numRequiredMachines, tetrisched::Time startTime,
tetrisched::Time duration, TETRISCHED_ILP_TYPE utility,
tetrisched::ExpressionStatus status,
std::optional<tetrisched::PriorPlacement> priorPlacements) {
tetrisched::ExpressionStatus status =
tetrisched::ExpressionStatus::EXPR_STATUS_UNKNOWN,
std::optional<tetrisched::PriorPlacement> priorPlacements =
std::nullopt) {
return std::make_shared<tetrisched::ChooseExpression>(
taskName, strategyName, partitions, numRequiredMachines,
startTime, duration, utility, status, priorPlacements);
}),
"Initializes a ChooseExpression for the given task to be placed on "
"`numRequiredMachines` from the given partition at the given "
"Initializes a ChooseExpression for the given task to be placed on \n"
"`numRequiredMachines` from the given partition at the given \n"
"startTime, running for the given duration.\n"
"\nArgs:\n"
" taskName (str): The name of the task to be placed.\n"
" strategyName (str): The name of the strategy of the Choose.\n"
" partitions (Partitions): The Partitions to be placed on.\n"
" numRequiredMachines (int): The number of machines required "
" numRequiredMachines (int): The number of machines required \n"
" for the task.\n"
" startTime (int): The start time of the task.\n"
" duration (int): The duration of the task.\n"
" utility (TETRISCHED_ILP_TYPE): The utility of the task.\n "
" status (ExpressionStatus): The status of the expression in a "
" previous cycle, if available.\n",
" priorPlacements (PriorPlacement): The prior placements of the "
" status (ExpressionStatus): The status of the expression in a \n"
" previous cycle, if available.\n"
" priorPlacements (PriorPlacement): The prior placements of the \n"
" expression in a previous cycle, if available.\n",
py::arg("taskName"), py::arg("strategyName"), py::arg("partitions"),
py::arg("numRequiredMachines"), py::arg("startTime"),
py::arg("duration"), py::arg("utility"),
py::arg("status") = tetrisched::ExpressionStatus::EXPR_STATUS_UNKNOWN,
py::arg("priorPlacements") = std::nullopt)
py::arg("duration"), py::arg("utility"), py::arg("status"),
py::arg("priorPlacements"))
.def(
py::init(
[](std::string taskName, tetrisched::Partitions partitions,
uint32_t numRequiredMachines, tetrisched::Time startTime,
tetrisched::Time duration, TETRISCHED_ILP_TYPE utility,
tetrisched::ExpressionStatus status,
std::optional<tetrisched::PriorPlacement> priorPlacements) {
tetrisched::ExpressionStatus status =
tetrisched::ExpressionStatus::EXPR_STATUS_UNKNOWN,
std::optional<tetrisched::PriorPlacement> priorPlacements =
std::nullopt) {
return std::make_shared<tetrisched::ChooseExpression>(
taskName, partitions, numRequiredMachines, startTime,
duration, utility, status, priorPlacements);
}),
"Initializes a ChooseExpression for the given task to be placed on "
"`numRequiredMachines` from the given partition at the given "
"Initializes a ChooseExpression for the given task to be placed on \n"
"`numRequiredMachines` from the given partition at the given \n"
"startTime, running for the given duration.\n"
"\nArgs:\n"
" taskName (str): The name of the task to be placed.\n"
" partitions (Partitions): The Partitions to be placed on.\n"
" numRequiredMachines (int): The number of machines required "
"for the task.\n"
" numRequiredMachines (int): The number of machines required \n"
" for the task.\n"
" startTime (int): The start time of the task.\n"
" duration (int): The duration of the task.\n"
" utility (TETRISCHED_ILP_TYPE): The utility of the task.\n",
" status (ExpressionStatus): The status of the expression in a "
" previous cycle, if available.\n",
" priorPlacements (PriorPlacement): The prior placements of the "
" utility (TETRISCHED_ILP_TYPE): The utility of the task.\n"
" status (ExpressionStatus): The status of the expression in a \n"
" previous cycle, if available.\n"
" priorPlacements (PriorPlacement): The prior placements of the \n"
" expression in a previous cycle, if available.\n",
py::arg("taskName"), py::arg("partitions"),
py::arg("numRequiredMachines"), py::arg("startTime"),
py::arg("duration"), py::arg("utility"),
py::arg("status") = tetrisched::ExpressionStatus::EXPR_STATUS_UNKNOWN,
py::arg("priorPlacements") = std::nullopt);
py::arg("duration"), py::arg("utility"), py::arg("status"),
py::arg("priorPlacements"));

// Define the WindowedChooseExpression.
py::class_<tetrisched::WindowedChooseExpression, tetrisched::Expression,
Expand Down
65 changes: 61 additions & 4 deletions schedulers/tetrisched/python/stubs/tetrisched_py/strl.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ __all__ = [
"AllocationExpression",
"ChooseExpression",
"Expression",
"ExpressionStatus",
"ExpressionType",
"LessThanExpression",
"MalleableChooseExpression",
Expand Down Expand Up @@ -52,18 +53,27 @@ class ChooseExpression(Expression):
startTime: int,
duration: int,
utility: float,
status: ExpressionStatus,
priorPlacements: list[tuple[tetrisched_py.Partition, int]] | None,
) -> None:
"""
Initializes a ChooseExpression for the given task to be placed on `numRequiredMachines` from the given partition at the given startTime, running for the given duration.
Initializes a ChooseExpression for the given task to be placed on
`numRequiredMachines` from the given partition at the given
startTime, running for the given duration.
Args:
taskName (str): The name of the task to be placed.
strategyName (str): The name of the strategy of the Choose.
partitions (Partitions): The Partitions to be placed on.
numRequiredMachines (int): The number of machines required for the task.
numRequiredMachines (int): The number of machines required
for the task.
startTime (int): The start time of the task.
duration (int): The duration of the task.
utility (TETRISCHED_ILP_TYPE): The utility of the task.
status (ExpressionStatus): The status of the expression in a
previous cycle, if available.
priorPlacements (PriorPlacement): The prior placements of the
expression in a previous cycle, if available.
"""
@typing.overload
def __init__(
Expand All @@ -74,17 +84,26 @@ class ChooseExpression(Expression):
startTime: int,
duration: int,
utility: float,
status: ExpressionStatus,
priorPlacements: list[tuple[tetrisched_py.Partition, int]] | None,
) -> None:
"""
Initializes a ChooseExpression for the given task to be placed on `numRequiredMachines` from the given partition at the given startTime, running for the given duration.
Initializes a ChooseExpression for the given task to be placed on
`numRequiredMachines` from the given partition at the given
startTime, running for the given duration.
Args:
taskName (str): The name of the task to be placed.
partitions (Partitions): The Partitions to be placed on.
numRequiredMachines (int): The number of machines required for the task.
numRequiredMachines (int): The number of machines required
for the task.
startTime (int): The start time of the task.
duration (int): The duration of the task.
utility (TETRISCHED_ILP_TYPE): The utility of the task.
status (ExpressionStatus): The status of the expression in a
previous cycle, if available.
priorPlacements (PriorPlacement): The prior placements of the
expression in a previous cycle, if available.
"""

class Expression:
Expand Down Expand Up @@ -130,6 +149,44 @@ class Expression:
@property
def name(self) -> str: ...

class ExpressionStatus:
"""
Members:
EXPR_STATUS_UNKNOWN
EXPR_STATUS_SATISFIED
EXPR_STATUS_UNSATISFIED
"""

EXPR_STATUS_SATISFIED: typing.ClassVar[
ExpressionStatus
] # value = <ExpressionStatus.EXPR_STATUS_SATISFIED: 1>
EXPR_STATUS_UNKNOWN: typing.ClassVar[
ExpressionStatus
] # value = <ExpressionStatus.EXPR_STATUS_UNKNOWN: 2>
EXPR_STATUS_UNSATISFIED: typing.ClassVar[
ExpressionStatus
] # value = <ExpressionStatus.EXPR_STATUS_UNSATISFIED: 0>
__members__: typing.ClassVar[
dict[str, ExpressionStatus]
] # value = {'EXPR_STATUS_UNKNOWN': <ExpressionStatus.EXPR_STATUS_UNKNOWN: 2>, 'EXPR_STATUS_SATISFIED': <ExpressionStatus.EXPR_STATUS_SATISFIED: 1>, 'EXPR_STATUS_UNSATISFIED': <ExpressionStatus.EXPR_STATUS_UNSATISFIED: 0>}
def __eq__(self, other: typing.Any) -> bool: ...
def __getstate__(self) -> int: ...
def __hash__(self) -> int: ...
def __index__(self) -> int: ...
def __init__(self, value: int) -> None: ...
def __int__(self) -> int: ...
def __ne__(self, other: typing.Any) -> bool: ...
def __repr__(self) -> str: ...
def __setstate__(self, state: int) -> None: ...
def __str__(self) -> str: ...
@property
def name(self) -> str: ...
@property
def value(self) -> int: ...

class ExpressionType:
"""
Members:
Expand Down

0 comments on commit 0d0bb52

Please sign in to comment.