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

TaskTemplate offloading and available to task #166

Merged
merged 7 commits into from
Mar 26, 2021
Merged

Conversation

kumare3
Copy link
Contributor

@kumare3 kumare3 commented Mar 20, 2021

Signed-off-by: Ketan Umare [email protected]

TL;DR

this PR updates the TaskReader interface to include a storage.DataReference (path) where the task template can be loaded from by the Container. It also creates helper implementation that lazily uploads the TaskTemplate to a protobuf store at the given reference when it is accessed and does it only once.

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

Tracking Issue

flyteorg/flyte#850

@codecov
Copy link

codecov bot commented Mar 24, 2021

Codecov Report

Merging #166 (3b0a6f6) into master (923466a) will increase coverage by 0.48%.
The diff coverage is 94.96%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #166      +/-   ##
==========================================
+ Coverage   60.72%   61.21%   +0.48%     
==========================================
  Files         131      132       +1     
  Lines        7109     7185      +76     
==========================================
+ Hits         4317     4398      +81     
+ Misses       2364     2359       -5     
  Partials      428      428              
Flag Coverage Δ
unittests 61.21% <94.96%> (+0.48%) ⬆️

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

Impacted Files Coverage Δ
go/tasks/pluginmachinery/ioutils/paths.go 33.33% <0.00%> (+15.15%) ⬆️
...tasks/pluginmachinery/flytek8s/container_helper.go 79.66% <71.42%> (-0.34%) ⬇️
go/tasks/pluginmachinery/flytek8s/pod_helper.go 65.04% <87.50%> (+0.87%) ⬆️
go/tasks/pluginmachinery/core/template/template.go 73.03% <88.00%> (+1.26%) ⬆️
go/tasks/pluginmachinery/ioutils/task_reader.go 100.00% <100.00%> (ø)
go/tasks/plugins/array/awsbatch/transformer.go 77.41% <100.00%> (+2.64%) ⬆️
go/tasks/plugins/array/k8s/task.go 50.39% <100.00%> (+2.03%) ⬆️
go/tasks/plugins/array/k8s/transformer.go 67.64% <100.00%> (+2.02%) ⬆️
go/tasks/plugins/hive/execution_state.go 69.72% <100.00%> (+0.63%) ⬆️
go/tasks/plugins/k8s/container/container.go 79.48% <100.00%> (ø)
... and 8 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 923466a...3b0a6f6. Read the comment docs.

@kumare3 kumare3 changed the title [wip]: TaskTemplate offloading and available to task TaskTemplate offloading and available to task Mar 25, 2021
"github.com/pkg/errors"
)

var (
Copy link
Contributor

Choose a reason for hiding this comment

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

sad... i don't remember my golang. what does this do?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

just to make sure, we do not deviate from the core interface

val = perRetryUniqueKey.ReplaceAllString(val, perRetryKey)

inputs, err := in.Get(ctx)
// For Task template, we will replace only if there is a match. This is because, task template replacement
// may be expensive, as we may offload
Copy link
Contributor

Choose a reason for hiding this comment

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

don't we always offload? r.store.WriteProtobuf? or is store sometimes local?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

no, we offload only when ttt params.Task.Path is invoked! which is only if the taskTemplateRegex match happens.
Again this is done so that its transparent to the templating method?

@@ -50,13 +50,26 @@ func FlyteTaskToBatchInput(ctx context.Context, tCtx pluginCore.TaskExecutionCon
return nil, errors.Errorf(errors.BadTaskSpecification, "config[%v] is missing", DynamicTaskQueueKey)
}

cmd, err := template.ReplaceTemplateCommandArgs(ctx, tCtx.TaskExecutionMetadata(), taskTemplate.GetContainer().GetCommand(), tCtx.InputReader(), tCtx.OutputWriter())
inputReader := array.GetInputReader(tCtx, taskTemplate)
Copy link
Contributor

Choose a reason for hiding this comment

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

is the inputReader the same? previously it was tCtx.InputReader()

Copy link
Contributor

@EngHabu EngHabu left a comment

Choose a reason for hiding this comment

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

Would it be possible to try to either implement or at least go through the mental exercise of writing other plugins based on this? My worry is that exposing just the task template feels like it'll be a short-sight as we try to enrich the FlyteKit-based plugins' writing experience and we will soon want to pass another Blah proto to the pod... Unfortunately, I do not know what that will contain just yet... just a gut feeling..

I would rather have had this implemented as "--task-plugin-data-path" param with a proto that -maybe for today- only has the task template... but tomorrow can add other things (maybe information about available resources or how to allocate resources... etc.)

I'm approving the PR though. Looks good for what it's trying to do.

@kumare3 kumare3 merged commit 93b339a into master Mar 26, 2021
milton0825 pushed a commit to milton0825/flyteplugins that referenced this pull request May 25, 2021
* [wip]: TaskTemplate offloading and available to task

Signed-off-by: Ketan Umare <[email protected]>

* Fixed tests

Signed-off-by: Ketan Umare <[email protected]>

* IOUtils for working with Automated task template uploading

Signed-off-by: Ketan Umare <[email protected]>

* Introduced the simple reader interface

Signed-off-by: Ketan Umare <[email protected]>

* Helper method for TaskTemplate path

Signed-off-by: Ketan Umare <[email protected]>

* updated

Signed-off-by: Ketan Umare <[email protected]>
Signed-off-by: Chao-Han Tsai <[email protected]>
eapolinario pushed a commit that referenced this pull request Sep 6, 2023
* [wip]: TaskTemplate offloading and available to task

Signed-off-by: Ketan Umare <[email protected]>

* Fixed tests

Signed-off-by: Ketan Umare <[email protected]>

* IOUtils for working with Automated task template uploading

Signed-off-by: Ketan Umare <[email protected]>

* Introduced the simple reader interface

Signed-off-by: Ketan Umare <[email protected]>

* Helper method for TaskTemplate path

Signed-off-by: Ketan Umare <[email protected]>

* updated

Signed-off-by: Ketan Umare <[email protected]>
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.

3 participants