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

Implement signal service for human-in-the-loop workflow orchestration #423

Merged
merged 30 commits into from
Dec 13, 2022

Conversation

hamersaw
Copy link
Contributor

@hamersaw hamersaw commented May 12, 2022

TL;DR

Adds SignalService implementation to support manual signals to trigger GateNodes in workflows.

Type

  • Bug Fix
  • Feature
  • Plugin

Are all requirements met?

  • Code completed
  • Smoke tested
  • Unit tests added
  • Code documentation added
  • Any pending items have an associated Issue

Complete description

^^^

Tracking Issue

flyteorg/flyte#208

Follow-up issue

NA

hamersaw added 4 commits May 10, 2022 13:05
Signed-off-by: Daniel Rammer <daniel@union.ai>
Signed-off-by: Daniel Rammer <daniel@union.ai>
Signed-off-by: Daniel Rammer <daniel@union.ai>
Signed-off-by: Daniel Rammer <daniel@union.ai>
@hamersaw hamersaw changed the title Feature/gate nodes Implement signal service for human-in-the-loop workflow orchestration May 12, 2022
hamersaw added 14 commits May 13, 2022 10:34
Signed-off-by: Daniel Rammer <daniel@union.ai>
Signed-off-by: Daniel Rammer <daniel@union.ai>
Signed-off-by: Daniel Rammer <daniel@union.ai>
Signed-off-by: Daniel Rammer <daniel@union.ai>
Signed-off-by: Daniel Rammer <daniel@union.ai>
Signed-off-by: Daniel Rammer <daniel@union.ai>
Signed-off-by: Daniel Rammer <daniel@union.ai>
Signed-off-by: Daniel Rammer <daniel@union.ai>
Signed-off-by: Daniel Rammer <daniel@union.ai>
Signed-off-by: Daniel Rammer <daniel@union.ai>
Signed-off-by: Daniel Rammer <daniel@union.ai>
Signed-off-by: Daniel Rammer <daniel@union.ai>
Signed-off-by: Daniel Rammer <daniel@union.ai>
Signed-off-by: Daniel Rammer <daniel@union.ai>
@hamersaw hamersaw marked this pull request as ready for review June 14, 2022 23:57
pkg/manager/mocks/signal.go Outdated Show resolved Hide resolved
pkg/repositories/models/signal.go Show resolved Hide resolved

func CreateSignalModel(signalID *core.SignalIdentifier, signalType *core.LiteralType, signalValue *core.Literal) (models.Signal, error) {
signalModel := models.Signal{}
if signalID != nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when would this ever be nil?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should never be, a signal without an ID is invalid. Included it for completeness. Perhaps throwing an error would be better here?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure that sounds good

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder since many of these fields are already validated at this point if we can reduce all the nil/empty checks in the body of this method? Your call of course!

pkg/repositories/transformers/signal.go Outdated Show resolved Hide resolved
Signed-off-by: Daniel Rammer <daniel@union.ai>
katrogan
katrogan previously approved these changes Jun 16, 2022
Signed-off-by: Daniel Rammer <daniel@union.ai>
hamersaw added 2 commits June 17, 2022 09:37
Signed-off-by: Daniel Rammer <daniel@union.ai>
Signed-off-by: Daniel Rammer <daniel@union.ai>
@codecov
Copy link

codecov bot commented Jun 17, 2022

Codecov Report

Merging #423 (c71d021) into master (fce143d) will increase coverage by 0.36%.
The diff coverage is 71.29%.

@@            Coverage Diff             @@
##           master     #423      +/-   ##
==========================================
+ Coverage   60.16%   60.52%   +0.36%     
==========================================
  Files         158      163       +5     
  Lines       14074    14492     +418     
==========================================
+ Hits         8467     8771     +304     
- Misses       4866     4955      +89     
- Partials      741      766      +25     
Flag Coverage Δ
unittests 60.52% <71.29%> (+0.36%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
pkg/manager/impl/util/filters.go 67.74% <ø> (ø)
pkg/repositories/config/migrations.go 3.20% <0.00%> (-0.08%) ⬇️
pkg/repositories/gorm_repo.go 0.00% <0.00%> (ø)
pkg/repositories/gormimpl/common.go 62.85% <ø> (ø)
pkg/rpc/signal_service.go 66.66% <66.66%> (ø)
pkg/manager/impl/signal_manager.go 66.99% <66.99%> (ø)
pkg/repositories/gormimpl/signal_repo.go 69.11% <69.11%> (ø)
pkg/manager/impl/validation/signal_validator.go 79.31% <79.31%> (ø)
pkg/repositories/transformers/signal.go 83.87% <83.87%> (ø)
...implementations/workflow_execution_event_writer.go 68.42% <0.00%> (+31.57%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

hamersaw added 6 commits June 22, 2022 08:41
Signed-off-by: Daniel Rammer <daniel@union.ai>
Signed-off-by: Daniel Rammer <daniel@union.ai>
Signed-off-by: Daniel Rammer <daniel@union.ai>
Signed-off-by: Daniel Rammer <daniel@union.ai>
Signed-off-by: Dan Rammer <daniel@union.ai>
Signed-off-by: Dan Rammer <daniel@union.ai>
katrogan
katrogan previously approved these changes Dec 5, 2022
pkg/rpc/signal_service.go Outdated Show resolved Hide resolved
@@ -0,0 +1,147 @@
package rpc
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for all this cruft, this rpc layer is admittedly pretty useless boilerplate, we could move the basic nil request validation, panic deferral and error transformation to just the manager layer (or get crafty with request middleware) not worth changing up in yourPR since you've already implemented this. Thank you for adding


func CreateSignalModel(signalID *core.SignalIdentifier, signalType *core.LiteralType, signalValue *core.Literal) (models.Signal, error) {
signalModel := models.Signal{}
if signalID != nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder since many of these fields are already validated at this point if we can reduce all the nil/empty checks in the body of this method? Your call of course!

func FromSignalModel(signalModel models.Signal) (admin.Signal, error) {
signal := admin.Signal{}

var executionID *core.WorkflowExecutionIdentifier
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: maybe just init this once?

SignalKey: input,
}).Take(&signal)
timer.Stop()
if errors.Is(tx.Error, gorm.ErrRecordNotFound) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this should no longer be necessary after our gorm v2 upgrade, the error transformer call below should catch this: https://github.com/flyteorg/flyteadmin/blob/master/pkg/repositories/errors/postgres.go#L56

(flyteorg/flyte#1958)

@@ -390,6 +390,16 @@ var Migrations = []*gormigrate.Migration{
return tx.Model(&models.Execution{}).Migrator().DropIndex(&models.Execution{}, "idx_executions_created_at")
},
},
// Create signals table.
{
ID: "2022-04-11-signals",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:D

"failed to validate that signal [%v] exists, err: [%+v]",
signalModel.SignalKey, err)
}
valueType := propellervalidators.LiteralTypeForLiteral(request.Value)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh this is tedious, it's too bad we can't store the valueType in the db as a column but I'm guessing it's not possible to statically capture the list of castable types so we we can bake in the validation into the UpdateSignal database call as a where clause?

Co-authored-by: Katrina Rogan <katroganGH@gmail.com>
Signed-off-by: Yee Hing Tong <wild-endeavor@users.noreply.github.com>
Signed-off-by: Eduardo Apolinario <eapolinario@users.noreply.github.com>
@wild-endeavor wild-endeavor enabled auto-merge (squash) December 13, 2022 19:17
@wild-endeavor wild-endeavor merged commit a1804d5 into master Dec 13, 2022
@wild-endeavor wild-endeavor deleted the feature/gate-nodes branch December 13, 2022 20:05
eapolinario pushed a commit that referenced this pull request Sep 6, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants