-
Notifications
You must be signed in to change notification settings - Fork 674
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Correctly handle resource overrides in KF plugins #4467
Merged
Merged
Changes from 11 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
886dd84
wip - mpi tests failing
jeevb e1e1838
get mpi tests passing
jeevb 28ebc38
Update pytorch and tensorflow plugins
jeevb b4587c2
cleanup
jeevb 34ff26f
cleanup
jeevb 236846e
cleanup
jeevb f684b0d
cleanup
jeevb cfc2f24
fixes
jeevb 78832e2
Merge branch 'master' into jeev/fix-kfplugins
jeevb ca1a839
Add tests for resource tolerations
jeevb 1d29e02
PR comments
jeevb 1bb70a6
Merge branch 'master' into jeev/fix-kfplugins
jeevb 307bead
Merge branch 'master' into jeev/fix-kfplugins
jeevb 2116ec2
Revert forcing non-interruptibility on kfoperator masters
jeevb 7df36cf
Merge branch 'master' into jeev/fix-kfplugins
jeevb File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
35 changes: 0 additions & 35 deletions
35
flyteplugins/go/tasks/pluginmachinery/flytek8s/non_interruptible.go
This file was deleted.
Oops, something went wrong.
123 changes: 123 additions & 0 deletions
123
flyteplugins/go/tasks/pluginmachinery/flytek8s/plugin_exec_context.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
package flytek8s | ||
|
||
import ( | ||
v1 "k8s.io/api/core/v1" | ||
|
||
"github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/core" | ||
pluginsCore "github.com/flyteorg/flyte/flyteplugins/go/tasks/pluginmachinery/core" | ||
) | ||
|
||
type pluginTaskOverrides struct { | ||
pluginsCore.TaskOverrides | ||
resources *v1.ResourceRequirements | ||
extendedResources *core.ExtendedResources | ||
} | ||
|
||
func (to *pluginTaskOverrides) GetResources() *v1.ResourceRequirements { | ||
if to.resources != nil { | ||
return to.resources | ||
} | ||
return to.TaskOverrides.GetResources() | ||
} | ||
|
||
func (to *pluginTaskOverrides) GetExtendedResources() *core.ExtendedResources { | ||
if to.extendedResources != nil { | ||
return to.extendedResources | ||
} | ||
return to.TaskOverrides.GetExtendedResources() | ||
} | ||
|
||
type pluginTaskExecutionMetadata struct { | ||
pluginsCore.TaskExecutionMetadata | ||
interruptible *bool | ||
overrides *pluginTaskOverrides | ||
} | ||
|
||
func (tm *pluginTaskExecutionMetadata) IsInterruptible() bool { | ||
if tm.interruptible != nil { | ||
return *tm.interruptible | ||
} | ||
return tm.TaskExecutionMetadata.IsInterruptible() | ||
} | ||
|
||
func (tm *pluginTaskExecutionMetadata) GetOverrides() pluginsCore.TaskOverrides { | ||
if tm.overrides != nil { | ||
return tm.overrides | ||
} | ||
return tm.TaskExecutionMetadata.GetOverrides() | ||
} | ||
|
||
type pluginTaskExecutionContext struct { | ||
pluginsCore.TaskExecutionContext | ||
metadata *pluginTaskExecutionMetadata | ||
} | ||
|
||
func (tc *pluginTaskExecutionContext) TaskExecutionMetadata() pluginsCore.TaskExecutionMetadata { | ||
if tc.metadata != nil { | ||
return tc.metadata | ||
} | ||
return tc.TaskExecutionContext.TaskExecutionMetadata() | ||
} | ||
|
||
type PluginTaskExecutionContextOption func(*pluginTaskExecutionContext) | ||
|
||
func WithInterruptible(v bool) PluginTaskExecutionContextOption { | ||
return func(tc *pluginTaskExecutionContext) { | ||
if tc.metadata == nil { | ||
tc.metadata = &pluginTaskExecutionMetadata{ | ||
TaskExecutionMetadata: tc.TaskExecutionContext.TaskExecutionMetadata(), | ||
} | ||
} | ||
tc.metadata.interruptible = &v | ||
} | ||
} | ||
|
||
func WithResources(r *v1.ResourceRequirements) PluginTaskExecutionContextOption { | ||
return func(tc *pluginTaskExecutionContext) { | ||
if tc.metadata == nil { | ||
tc.metadata = &pluginTaskExecutionMetadata{ | ||
TaskExecutionMetadata: tc.TaskExecutionContext.TaskExecutionMetadata(), | ||
} | ||
} | ||
if tc.metadata.overrides == nil { | ||
tc.metadata.overrides = &pluginTaskOverrides{ | ||
TaskOverrides: tc.metadata.TaskExecutionMetadata.GetOverrides(), | ||
} | ||
} | ||
tc.metadata.overrides.resources = r | ||
} | ||
} | ||
|
||
func WithExtendedResources(er *core.ExtendedResources) PluginTaskExecutionContextOption { | ||
return func(tc *pluginTaskExecutionContext) { | ||
if tc.metadata == nil { | ||
tc.metadata = &pluginTaskExecutionMetadata{ | ||
TaskExecutionMetadata: tc.TaskExecutionContext.TaskExecutionMetadata(), | ||
} | ||
} | ||
if tc.metadata.overrides == nil { | ||
tc.metadata.overrides = &pluginTaskOverrides{ | ||
TaskOverrides: tc.metadata.TaskExecutionMetadata.GetOverrides(), | ||
} | ||
} | ||
tc.metadata.overrides.extendedResources = er | ||
} | ||
} | ||
|
||
func NewPluginTaskExecutionContext(tc pluginsCore.TaskExecutionContext, options ...PluginTaskExecutionContextOption) pluginsCore.TaskExecutionContext { | ||
tm := tc.TaskExecutionMetadata() | ||
to := tm.GetOverrides() | ||
ctx := &pluginTaskExecutionContext{ | ||
TaskExecutionContext: tc, | ||
metadata: &pluginTaskExecutionMetadata{ | ||
TaskExecutionMetadata: tm, | ||
overrides: &pluginTaskOverrides{ | ||
TaskOverrides: to, | ||
}, | ||
}, | ||
} | ||
for _, o := range options { | ||
o(ctx) | ||
} | ||
return ctx | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that "master" pods will be tagged as non-interruptible. Currently this is set for PyTorch masters and MPI launchers.