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 459d4bb commit 5789ace
Show file tree
Hide file tree
Showing 8 changed files with 71 additions and 26 deletions.
24 changes: 16 additions & 8 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)
}
Binary file modified proto/buf.image.bin
Binary file not shown.
28 changes: 19 additions & 9 deletions proto/pkg/experimentv1/searcher.pb.go

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

6 changes: 4 additions & 2 deletions proto/src/determined/experiment/v1/searcher.proto
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,10 @@ message CloseTrialOperation {

// Shut down custom searcher method.
message ShutDownOperation {
// Cannot have an empty message type.
int32 placeholder = 1;
// Defines whether the Searcher was cancelled
bool cancel = 1;
// Defines whether the Searcher failed
bool failure = 2;
}

// SearcherOperation is an operation issued by the custom searcher.
Expand Down
12 changes: 9 additions & 3 deletions webui/react/src/services/api-ts-sdk/api.ts

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

0 comments on commit 5789ace

Please sign in to comment.