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

Single task execution (admin-generated workflow implementation) #96

Merged
merged 24 commits into from
May 21, 2020

Conversation

katrogan
Copy link
Contributor

TL;DR

This PR implements single task execution for CreateExecutionRequests with reference entities of type 'TASK'.

Because this is v1 of single task execution this code is compartmentalized and designed to be easy to rip out. Therefore not everything that could necessarily be refactored from the existing CreateExecution, CreateWorfklow and CreateLaunchPlan logic is changed and some duplicate code exists. This is (ugly) by design.

TODO If this overall design looks okay I will add more unit tests to this PR - I just wanted to get an overall approval of the code before investing time in unit tests in case it changes significantly.

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

This code takes an existing, registered task and generates a skeleton workflow definition with a single node referencing the task. The workflow inputs and outputs are mapped to those of the task definition. For UI purposes, a default launch plan with a matching interface is also generated.

Tracking Issue

flyteorg/flyte#256

Follow-up issue

flyteorg/flyte#221

@wild-endeavor
Copy link
Contributor

Is this really "v1". I'd rather not call it that.

@katrogan katrogan changed the title Single task execution (v1 admin implementation) Single task execution (admin-generated workflow implementation) May 12, 2020
@katrogan
Copy link
Contributor Author

@wild-endeavor updated but names are hard. let me know if you have suggestions

@codecov-io
Copy link

Codecov Report

Merging #96 into master will decrease coverage by 2.68%.
The diff coverage is 16.58%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #96      +/-   ##
==========================================
- Coverage   63.14%   60.46%   -2.69%     
==========================================
  Files         100      101       +1     
  Lines        7038     7451     +413     
==========================================
+ Hits         4444     4505      +61     
- Misses       2082     2409     +327     
- Partials      512      537      +25     
Impacted Files Coverage Δ
pkg/manager/impl/util/single_task_execution.go 0.00% <0.00%> (ø)
pkg/manager/impl/validation/execution_validator.go 77.21% <0.00%> (-4.12%) ⬇️
pkg/repositories/config/migrations.go 0.00% <0.00%> (ø)
pkg/workflowengine/impl/propeller_executor.go 52.20% <0.00%> (-27.99%) ⬇️
pkg/repositories/transformers/execution.go 77.93% <25.00%> (-1.65%) ⬇️
pkg/manager/impl/execution_manager.go 68.83% <57.94%> (-1.82%) ⬇️
pkg/manager/impl/validation/validation.go 92.62% <77.77%> (-1.45%) ⬇️

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 0ce1932...751ba84. Read the comment docs.

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.

This is awesome!! Thank you for taking on this project. It just opens endless possibilities :)


func generateNodeNameFromTask(taskName string) string {
if len(taskName) >= maxNodeIDLength {
taskName = taskName[:maxNodeIDLength]
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: python tasks are typically on the form "app.workflows.tasks.......my_module.my_task", I think naming the node "my-task" would make it much easier to use and recognize. no?
if so then maybe taskName[len(taskName)-maxNodeIDLength:] (I might be off by 1 :))

Copy link
Contributor Author

Choose a reason for hiding this comment

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

excellent point! updated

pkg/manager/impl/util/single_task_execution.go Outdated Show resolved Hide resolved
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.

Are you also going to add the automatic filter for System Generated in the ListWF Endpoint?

ctx context.Context, request admin.ExecutionCreateRequest, db repositories.RepositoryInterface,
workflowManager interfaces.WorkflowInterface, namedEntityManager interfaces.NamedEntityInterface, taskIdentifier *core.Identifier,
task *admin.Task) (*models.Workflow, error) {
workflowModel, err := db.WorkflowRepo().Get(ctx, repositoryInterfaces.GetResourceInput{
Copy link
Contributor

Choose a reason for hiding this comment

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

Doesn't this introduce a race condition? if I tried to run the same task twice, both of them go past the "Get" call and realize there isn't an existing WF model, so they will both try to create one... Should the error check for Create() call below exclude "ErrExistingRow" or whatever the error is for that?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, good call. done

@katrogan
Copy link
Contributor Author

katrogan commented May 15, 2020

Are you also going to add the automatic filter for System Generated in the ListWF Endpoint?

Added the filter to the ListNamedEntity endpoint which is what the console uses to list workflows and is the entrypoint for individual workflows

I'm more hesitant about adding it to the existing ListWorkflows endpoint by default because now that will force an additional join and I don't want to add a performance penalty to an endpoint that is really only available in the cli (aka power users who hopefully know what they're doing :) )

@katrogan
Copy link
Contributor Author

friendly ping @EngHabu

EngHabu
EngHabu previously approved these changes May 20, 2020
pkg/manager/impl/util/single_task_execution.go Outdated Show resolved Hide resolved
@codecov-commenter
Copy link

codecov-commenter commented May 20, 2020

Codecov Report

Merging #96 into master will increase coverage by 1.19%.
The diff coverage is 64.73%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #96      +/-   ##
==========================================
+ Coverage   63.14%   64.33%   +1.19%     
==========================================
  Files         100      101       +1     
  Lines        7038     7678     +640     
==========================================
+ Hits         4444     4940     +496     
- Misses       2082     2185     +103     
- Partials      512      553      +41     
Impacted Files Coverage Δ
pkg/manager/impl/validation/execution_validator.go 77.21% <0.00%> (-4.12%) ⬇️
pkg/repositories/config/migrations.go 0.00% <0.00%> (ø)
pkg/workflowengine/impl/propeller_executor.go 52.20% <0.00%> (-27.99%) ⬇️
pkg/repositories/transformers/execution.go 85.49% <33.33%> (+5.91%) ⬆️
pkg/manager/impl/execution_manager.go 74.38% <57.94%> (+3.73%) ⬆️
pkg/manager/impl/named_entity_manager.go 40.69% <75.00%> (+3.79%) ⬆️
pkg/manager/impl/validation/validation.go 92.62% <77.77%> (-1.45%) ⬇️
pkg/manager/impl/util/single_task_execution.go 85.41% <85.41%> (ø)
pkg/manager/impl/util/shared.go 64.23% <0.00%> (+1.45%) ⬆️
... and 2 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 0ce1932...1d9028b. Read the comment docs.

@katrogan
Copy link
Contributor Author

@EngHabu mind reviewing one last time? your suggested commit dismissed your review :)

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.

5 participants