-
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
[flytepropeller][flyteadmin] Streaming Decks V2 #6053
Open
Future-Outlier
wants to merge
13
commits into
master
Choose a base branch
from
streaming-deck-v2
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
54aa165
add tests from Yi-Cheng
Future-Outlier 9ed6b6e
helped by Kevin and Yi-Cheng
Future-Outlier 4b4f6bd
lint
Future-Outlier dd774cb
nit
Future-Outlier 0bb8e91
add comments
Future-Outlier 25fea29
add comments and better solution for backward compativle
Future-Outlier 4e24e91
better comments
Future-Outlier 8d1d0e4
DeckStatus
Future-Outlier 31853bb
rename GetDeckStatus
Future-Outlier 4068043
comments
Future-Outlier 65b6efe
lint
Future-Outlier 137579f
fix
Future-Outlier 04f7fbc
Merge branch 'master' into streaming-deck-v2
Future-Outlier 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,6 +41,13 @@ | |
|
||
const pluginContextKey = contextutils.Key("plugin") | ||
|
||
type DeckStatus int | ||
|
||
const ( | ||
DeckUnknown DeckStatus = iota | ||
DeckEnabled | ||
) | ||
|
||
type metrics struct { | ||
pluginPanics labeled.Counter | ||
unsupportedTaskType labeled.Counter | ||
|
@@ -71,10 +78,47 @@ | |
return taskType + "_" + pluginID | ||
} | ||
|
||
func (p *pluginRequestedTransition) CacheHit(outputPath storage.DataReference, deckPath *storage.DataReference, entry catalog.Entry) { | ||
func (p *pluginRequestedTransition) AddDeckURI(tCtx *taskExecutionContext) { | ||
var deckURI *storage.DataReference | ||
deckURIValue := tCtx.ow.GetDeckPath() | ||
deckURI = &deckURIValue | ||
|
||
if p.execInfo.OutputInfo == nil { | ||
p.execInfo.OutputInfo = &handler.OutputInfo{} | ||
} | ||
|
||
p.execInfo.OutputInfo.DeckURI = deckURI | ||
} | ||
|
||
func (p *pluginRequestedTransition) AddDeckURIIfDeckExists(ctx context.Context, tCtx *taskExecutionContext) error { | ||
reader := tCtx.ow.GetReader() | ||
if reader == nil && p.execInfo.OutputInfo != nil { | ||
p.execInfo.OutputInfo.DeckURI = nil | ||
return nil | ||
} | ||
|
||
exists, err := reader.DeckExists(ctx) | ||
if err != nil { | ||
logger.Errorf(ctx, "Failed to check deck file existence. Error: %v", err) | ||
return regErrors.Wrapf(err, "failed to check existence of deck file") | ||
} | ||
|
||
if p.execInfo.OutputInfo == nil { | ||
p.execInfo.OutputInfo = &handler.OutputInfo{} | ||
} | ||
|
||
if exists { | ||
deckURIValue := tCtx.ow.GetDeckPath() | ||
p.execInfo.OutputInfo.DeckURI = &deckURIValue | ||
} | ||
|
||
return nil | ||
} | ||
|
||
func (p *pluginRequestedTransition) CacheHit(outputPath storage.DataReference, entry catalog.Entry) { | ||
p.ttype = handler.TransitionTypeEphemeral | ||
p.pInfo = pluginCore.PhaseInfoSuccess(nil) | ||
p.ObserveSuccess(outputPath, deckPath, &event.TaskNodeMetadata{CacheStatus: entry.GetStatus().GetCacheStatus(), CatalogKey: entry.GetStatus().GetMetadata()}) | ||
p.ObserveSuccess(outputPath, &event.TaskNodeMetadata{CacheStatus: entry.GetStatus().GetCacheStatus(), CatalogKey: entry.GetStatus().GetMetadata()}) | ||
} | ||
|
||
func (p *pluginRequestedTransition) PopulateCacheInfo(entry catalog.Entry) { | ||
|
@@ -144,10 +188,13 @@ | |
return ToTaskExecutionEvent(input) | ||
} | ||
|
||
func (p *pluginRequestedTransition) ObserveSuccess(outputPath storage.DataReference, deckPath *storage.DataReference, taskMetadata *event.TaskNodeMetadata) { | ||
p.execInfo.OutputInfo = &handler.OutputInfo{ | ||
OutputURI: outputPath, | ||
DeckURI: deckPath, | ||
func (p *pluginRequestedTransition) ObserveSuccess(outputPath storage.DataReference, taskMetadata *event.TaskNodeMetadata) { | ||
if p.execInfo.OutputInfo == nil { | ||
p.execInfo.OutputInfo = &handler.OutputInfo{ | ||
OutputURI: outputPath, | ||
} | ||
} else { | ||
p.execInfo.OutputInfo.OutputURI = outputPath | ||
} | ||
|
||
p.execInfo.TaskNodeInfo = &handler.TaskNodeInfo{ | ||
|
@@ -171,7 +218,8 @@ | |
} | ||
|
||
logger.Debugf(ctx, "Task still running") | ||
return handler.DoTransition(p.ttype, handler.PhaseInfoRunning(nil)), nil | ||
// Here will send the deck uri to flyteadmin | ||
return handler.DoTransition(p.ttype, handler.PhaseInfoRunning(&p.execInfo)), nil | ||
} | ||
|
||
// The plugin interface available especially for testing. | ||
|
@@ -380,6 +428,32 @@ | |
return t.taskMetricsMap[metricNameKey], nil | ||
} | ||
|
||
func GetDeckStatus(ctx context.Context, tCtx *taskExecutionContext) (DeckStatus, error) { | ||
// GetDeckStatus determines whether a task generates a deck based on its execution context. | ||
// | ||
// This function ensures backward compatibility with older Flytekit versions using the following logic: | ||
// 1. For Flytekit > 1.14.3, the task template's metadata includes the `generates_deck` flag: | ||
// - If `generates_deck` is set to true, it indicates that the task generates a deck, and DeckEnabled is returned. | ||
// 2. If `generates_deck` is set to false or is not set (likely from older Flytekit versions): | ||
// - DeckUnknown is returned as a placeholder status. | ||
// - In terminal states, a HEAD request can be made to check if the deck file exists. | ||
// | ||
// In future implementations, a `DeckDisabled` status could be introduced for better performance optimization: | ||
// - This would eliminate the need for a HEAD request in the final phase. | ||
// - However, the tradeoff is that a new field would need to be added to FlyteIDL to support this behavior. | ||
|
||
template, err := tCtx.tr.Read(ctx) | ||
Comment on lines
+432
to
+445
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Better comments! |
||
if err != nil { | ||
return DeckUnknown, regErrors.Wrapf(err, "failed to read task template") | ||
} | ||
|
||
if template.GetMetadata().GetGeneratesDeck() { | ||
return DeckEnabled, nil | ||
} | ||
|
||
return DeckUnknown, nil | ||
} | ||
|
||
func (t Handler) invokePlugin(ctx context.Context, p pluginCore.Plugin, tCtx *taskExecutionContext, ts handler.TaskNodeState) (*pluginRequestedTransition, error) { | ||
pluginTrns := &pluginRequestedTransition{} | ||
|
||
|
@@ -464,8 +538,26 @@ | |
} | ||
} | ||
|
||
// Regardless of the observed phase, we always add the DeckUri to support real-time deck functionality. | ||
// The deck should be accessible even if the task is still running or has failed. | ||
// It's possible that the deck URI may not exist in remote storage yet or will never exist. | ||
// So, it is console's responsibility to handle the case when the deck URI actually does not exist. | ||
deckStatus, err := GetDeckStatus(ctx, tCtx) | ||
if err != nil { | ||
return nil, err | ||
} | ||
if deckStatus == DeckEnabled { | ||
pluginTrns.AddDeckURI(tCtx) | ||
} | ||
|
||
switch pluginTrns.pInfo.Phase() { | ||
case pluginCore.PhaseSuccess: | ||
if deckStatus == DeckUnknown { | ||
err = pluginTrns.AddDeckURIIfDeckExists(ctx, tCtx) | ||
} | ||
if err != nil { | ||
return pluginTrns, err | ||
} | ||
// ------------------------------------- | ||
// TODO: @kumare create Issue# Remove the code after we use closures to handle dynamic nodes | ||
// This code only exists to support Dynamic tasks. Eventually dynamic tasks will use closure nodes to execute | ||
|
@@ -501,25 +593,21 @@ | |
CheckpointUri: tCtx.ow.GetCheckpointPrefix().String(), | ||
}) | ||
} else { | ||
var deckURI *storage.DataReference | ||
if tCtx.ow.GetReader() != nil { | ||
exists, err := tCtx.ow.GetReader().DeckExists(ctx) | ||
if err != nil { | ||
logger.Errorf(ctx, "Failed to check deck file existence. Error: %v", err) | ||
return pluginTrns, regErrors.Wrapf(err, "failed to check existence of deck file") | ||
} else if exists { | ||
deckURIValue := tCtx.ow.GetDeckPath() | ||
deckURI = &deckURIValue | ||
} | ||
} | ||
pluginTrns.ObserveSuccess(tCtx.ow.GetOutputPath(), deckURI, | ||
pluginTrns.ObserveSuccess(tCtx.ow.GetOutputPath(), | ||
&event.TaskNodeMetadata{ | ||
CheckpointUri: tCtx.ow.GetCheckpointPrefix().String(), | ||
}) | ||
} | ||
case pluginCore.PhaseRetryableFailure: | ||
fallthrough | ||
case pluginCore.PhasePermanentFailure: | ||
// This is for backward compatibility with older Flytekit versions. | ||
if deckStatus == DeckUnknown { | ||
err = pluginTrns.AddDeckURIIfDeckExists(ctx, tCtx) | ||
} | ||
if err != nil { | ||
return pluginTrns, err | ||
} | ||
pluginTrns.ObservedFailure( | ||
&event.TaskNodeMetadata{ | ||
CheckpointUri: tCtx.ow.GetCheckpointPrefix().String(), | ||
|
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.
The method signature for
CacheHit
has been modified to remove thedeckPath
parameter, but it seems this parameter may still be needed based on the usage in the code. Consider if this change could cause issues with deck path handling.Code suggestion
Code Review Run #f3ef5e
Is this a valid issue, or was it incorrectly flagged by the Agent?