Skip to content

Commit

Permalink
feat: Support "cancelled" and "failed" Shutdown operations [MLG-468]
Browse files Browse the repository at this point in the history
  • Loading branch information
tayritenour committed Apr 25, 2023
1 parent 7131b48 commit 9a24973
Show file tree
Hide file tree
Showing 7 changed files with 151 additions and 77 deletions.
16 changes: 16 additions & 0 deletions harness/determined/common/api/bindings.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions harness/determined/searcher/_search_method.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,15 @@ class Shutdown(Operation):
Operation shutting the experiment down
"""

def __init__(self) -> None:
def __init__(self, cancel: bool = False, failure: bool = False) -> None:
super().__init__()
self.cancel = cancel
self.failure = failure

def _to_searcher_operation(self) -> bindings.v1SearcherOperation:
return bindings.v1SearcherOperation(shutDown=bindings.v1ShutDownOperation())
return bindings.v1SearcherOperation(
shutDown=bindings.v1ShutDownOperation(cancel=self.cancel, failure=self.failure)
)


class Create(Operation):
Expand Down
7 changes: 6 additions & 1 deletion master/internal/experiment.go
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,12 @@ func (e *experiment) Receive(ctx *actor.Context) error {
ops = append(ops, *op)
}
case *experimentv1.SearcherOperation_ShutDown:
ops = append(ops, searcher.NewShutdown())
op, err := searcher.ShutdownFromProto(concreteOperation)
if err != nil {
ctx.Log().Error(err)
} else {
ops = append(ops, *op)
}
case *experimentv1.SearcherOperation_TrialOperation:
switch sub := concreteOperation.TrialOperation.GetUnion().(type) {
case *experimentv1.TrialOperation_ValidateAfter:
Expand Down
12 changes: 11 additions & 1 deletion master/pkg/searcher/operations.go
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,16 @@ func NewShutdown() Shutdown {
return Shutdown{}
}

// ShutdownFromProto creates a Shutdown from its protobuf representation.
func ShutdownFromProto(
op *experimentv1.SearcherOperation_ShutDown,
) (*Shutdown, error) {
return &Shutdown{
Cancel: op.ShutDown.Cancel,
Failure: op.ShutDown.Failure,
}, nil
}

func (shutdown Shutdown) String() string {
return "{Shutdown}"
return fmt.Sprintf("{Shutdown Cancel: %v Failure: %v}", shutdown.Cancel, shutdown.Failure)
}
166 changes: 94 additions & 72 deletions proto/pkg/experimentv1/searcher.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions proto/src/determined/experiment/v1/searcher.proto
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,12 @@ message CloseTrialOperation {
// Shut down custom searcher method.
message ShutDownOperation {
// Cannot have an empty message type.
// Deprecated: But maintained here for backwards compatibility
int32 placeholder = 1;
// Defines whether the Searcher was cancelled
bool cancel = 2;
// Defines whether the Searcher failed
bool failure = 3;
}

// SearcherOperation is an operation issued by the custom searcher.
Expand Down
Loading

0 comments on commit 9a24973

Please sign in to comment.