Skip to content

Commit

Permalink
Update boilerplate and github tag action (flyteorg#74)
Browse files Browse the repository at this point in the history
* Update github tag action

Signed-off-by: Katrina Rogan <[email protected]>

* Update boilerplate

Signed-off-by: Katrina Rogan <[email protected]>
  • Loading branch information
katrogan authored Apr 25, 2022
1 parent a21404a commit d6771a3
Show file tree
Hide file tree
Showing 7 changed files with 148 additions and 81 deletions.
7 changes: 4 additions & 3 deletions boilerplate/flyte/end2end/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@

.PHONY: end2end_execute
end2end_execute:
./boilerplate/flyte/end2end/end2end.sh

# TODO: These arguments could come from environment variables
./boilerplate/flyte/end2end/end2end.sh ./boilerplate/flyte/end2end/functional-test.config --return_non_zero_on_failure

.PHONY: k8s_integration_execute
k8s_integration_execute:
echo "pass"
echo "pass"
6 changes: 4 additions & 2 deletions boilerplate/flyte/end2end/end2end.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@
# TO OPT OUT OF UPDATES, SEE https://github.com/flyteorg/boilerplate/blob/master/Readme.rst
set -e

CONFIG_FILE=$1; shift
EXTRA_FLAGS=( "$@" )

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"

LATEST_VERSION=$(curl --silent "https://api.github.com/repos/flyteorg/flytesnacks/releases/latest" | jq -r .tag_name)

FLYTE_SDK_USE_STRUCTURED_DATASET=TRUE python ./boilerplate/flyte/end2end/run-tests.py $LATEST_VERSION P0,P1 ./boilerplate/flyte/end2end/functional-test.config core

python ./boilerplate/flyte/end2end/run-tests.py $LATEST_VERSION P0,P1 $CONFIG_FILE ${EXTRA_FLAGS[@]}
108 changes: 75 additions & 33 deletions boilerplate/flyte/end2end/run-tests.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@

#!/usr/bin/env python3

import click
import json
import sys
import time
import traceback
import requests
from pathlib import Path
from typing import List, Mapping, Tuple, Dict
from flytekit.remote import FlyteRemote
from flytekit.models.core.execution import WorkflowExecutionPhase
from flytekit.configuration import Config, ImageConfig, SerializationSettings


WAIT_TIME = 10
MAX_ATTEMPTS = 60
Expand All @@ -35,9 +36,9 @@
("core.control_flow.subworkflows.parent_wf", {"a": 3}),
("core.control_flow.subworkflows.nested_parent_wf", {"a": 3}),
("core.flyte_basics.basic_workflow.my_wf", {"a": 50, "b": "hello"}),
# Getting a 403 for the wikipedia image
# TODO: enable new files and folders workflows
# ("core.flyte_basics.files.rotate_one_workflow", {"in_image": "https://upload.wikimedia.org/wikipedia/commons/d/d2/Julia_set_%28C_%3D_0.285%2C_0.01%29.jpg"}),
("core.flyte_basics.folders.download_and_rotate", {}),
# ("core.flyte_basics.folders.download_and_rotate", {}),
("core.flyte_basics.hello_world.my_wf", {}),
("core.flyte_basics.lp.my_wf", {"val": 4}),
("core.flyte_basics.lp.go_greet", {"day_of_week": "5", "number": 3, "am": True}),
Expand All @@ -60,7 +61,12 @@ def run_launch_plan(remote, version, workflow_name, inputs):
return remote.execute(lp, inputs=inputs, wait=False)


def schedule_workflow_group(tag: str, workflow_group: str, remote: FlyteRemote) -> bool:
def schedule_workflow_group(
tag: str,
workflow_group: str,
remote: FlyteRemote,
terminate_workflow_on_failure: bool,
) -> bool:
"""
Schedule all workflows executions and return True if all executions succeed, otherwise
return False.
Expand All @@ -74,7 +80,7 @@ def schedule_workflow_group(tag: str, workflow_group: str, remote: FlyteRemote)
# Wait for all launch plans to finish
attempt = 0
while attempt == 0 or (
not all([lp.is_complete for lp in launch_plans]) and attempt < MAX_ATTEMPTS
not all([lp.is_done for lp in launch_plans]) and attempt < MAX_ATTEMPTS
):
attempt += 1
print(
Expand Down Expand Up @@ -105,6 +111,8 @@ def schedule_workflow_group(tag: str, workflow_group: str, remote: FlyteRemote)
# Report failing cases
for lp in non_succeeded_lps:
print(f" workflow={lp.spec.launch_plan.name}, execution_id={lp.id.name}")
if terminate_workflow_on_failure:
remote.terminate(lp, "aborting execution scheduled in functional test")
return False


Expand All @@ -116,35 +124,49 @@ def valid(workflow_group):
return workflow_group in FLYTESNACKS_WORKFLOW_GROUPS.keys()


def run(release_tag: str, priorities: List[str], config_file_path) -> List[Dict[str, str]]:
remote = FlyteRemote.from_config(
def run(
flytesnacks_release_tag: str,
priorities: List[str],
config_file_path,
terminate_workflow_on_failure: bool,
) -> List[Dict[str, str]]:
remote = FlyteRemote(
Config.auto(config_file=config_file_path),
default_project="flytesnacks",
default_domain="development",
config_file_path=config_file_path,
)

# For a given release tag and priority, this function filters the workflow groups from the flytesnacks manifest file. For
# example, for the release tag "v0.2.224" and the priority "P0" it returns [ "core" ].
manifest_url = f"https://raw.githubusercontent.com/flyteorg/flytesnacks/{release_tag}/cookbook/flyte_tests_manifest.json"
# For a given release tag and priority, this function filters the workflow groups from the flytesnacks
# manifest file. For example, for the release tag "v0.2.224" and the priority "P0" it returns [ "core" ].
manifest_url = "https://raw.githubusercontent.com/flyteorg/flytesnacks/" \
f"{flytesnacks_release_tag}/cookbook/flyte_tests_manifest.json"
r = requests.get(manifest_url)
parsed_manifest = r.json()

workflow_groups = [group["name"] for group in parsed_manifest if group["priority"] in priorities]
workflow_groups = [
group["name"] for group in parsed_manifest if group["priority"] in priorities
]
results = []
for workflow_group in workflow_groups:
if not valid(workflow_group):
results.append({
"label": workflow_group,
"status": "coming soon",
"color": "grey",
})
results.append(
{
"label": workflow_group,
"status": "coming soon",
"color": "grey",
}
)
continue

try:
workflows_succeeded = schedule_workflow_group(flytesnacks_release_tag, workflow_group, remote)
workflows_succeeded = schedule_workflow_group(
flytesnacks_release_tag,
workflow_group,
remote,
terminate_workflow_on_failure,
)
except Exception:
print(traceback.format_exc())

workflows_succeeded = False

if workflows_succeeded:
Expand Down Expand Up @@ -173,23 +195,43 @@ def run(release_tag: str, priorities: List[str], config_file_path) -> List[Dict[
return results


if __name__ == "__main__":
# Assume that the first argument passed to the script is a flytesnacks release tag and
# the second one is a comma-separated list of priorities, as defined in the flytesnacks
# tests manifest.
flytesnacks_release_tag = sys.argv[1]
priorities = sys.argv[2].split(',')
config_file = sys.argv[3]
return_non_zero_on_failure = sys.argv[4]

results = run(flytesnacks_release_tag, priorities, config_file)
@click.command()
@click.option(
"--return_non_zero_on_failure",
default=False,
is_flag=True,
help="Return a non-zero exit status if any workflow fails",
)
@click.option(
"--terminate_workflow_on_failure",
default=False,
is_flag=True,
help="Abort failing workflows upon exit",
)
@click.argument("flytesnacks_release_tag")
@click.argument("priorities")
@click.argument("config_file")
def cli(
flytesnacks_release_tag,
priorities,
config_file,
return_non_zero_on_failure,
terminate_workflow_on_failure,
):
print(f"return_non_zero_on_failure={return_non_zero_on_failure}")
results = run(
flytesnacks_release_tag, priorities, config_file, terminate_workflow_on_failure
)

# Write a json object in its own line describing the result of this run to stdout
print(f"Result of run:\n{json.dumps(results)}")

# Return a non-zero exit code if core fails
if return_non_zero_on_failure is not None:
# find the result
if return_non_zero_on_failure:
for result in results:
if result['label'] == return_non_zero_on_failure and result['status'] != 'passing':
if result["status"] not in ("passing", "coming soon"):
sys.exit(1)


if __name__ == "__main__":
cli()
29 changes: 15 additions & 14 deletions boilerplate/flyte/golang_support_tools/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,21 @@ module github.com/flyteorg/boilerplate
go 1.17

require (
github.com/EngHabu/mockery v0.0.0-20220405200825-3f76291311cf
github.com/alvaroloes/enumer v1.1.2
github.com/flyteorg/flytestdlib v0.4.7
github.com/flyteorg/flytestdlib v0.4.16
github.com/golangci/golangci-lint v1.38.0
github.com/pseudomuto/protoc-gen-doc v1.4.1
github.com/vektra/mockery v0.0.0-20181123154057-e78b021dcbb5
)

require (
4d63.com/gochecknoglobals v0.0.0-20201008074935-acfc0b28355a // indirect
cloud.google.com/go v0.75.0 // indirect
cloud.google.com/go/storage v1.12.0 // indirect
github.com/Azure/azure-sdk-for-go v51.0.0+incompatible // indirect
github.com/Azure/azure-sdk-for-go v62.3.0+incompatible // indirect
github.com/Azure/azure-sdk-for-go/sdk/azcore v0.21.1 // indirect
github.com/Azure/azure-sdk-for-go/sdk/internal v0.8.3 // indirect
github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v0.3.0 // indirect
github.com/Azure/go-autorest v14.2.0+incompatible // indirect
github.com/Azure/go-autorest/autorest v0.11.17 // indirect
github.com/Azure/go-autorest/autorest/adal v0.9.10 // indirect
Expand Down Expand Up @@ -46,6 +49,7 @@ require (
github.com/esimonov/ifshort v1.0.1 // indirect
github.com/fatih/color v1.10.0 // indirect
github.com/fatih/structtag v1.2.0 // indirect
github.com/flyteorg/stow v0.3.1 // indirect
github.com/form3tech-oss/jwt-go v3.2.2+incompatible // indirect
github.com/fsnotify/fsnotify v1.4.9 // indirect
github.com/fzipp/gocyclo v0.3.1 // indirect
Expand All @@ -62,6 +66,7 @@ require (
github.com/go-xmlfmt/xmlfmt v0.0.0-20191208150333-d5b6f63a941b // indirect
github.com/gobwas/glob v0.2.3 // indirect
github.com/gofrs/flock v0.8.0 // indirect
github.com/gofrs/uuid v4.2.0+incompatible // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e // indirect
github.com/golang/protobuf v1.4.3 // indirect
Expand All @@ -82,7 +87,6 @@ require (
github.com/gostaticanalysis/comment v1.4.1 // indirect
github.com/gostaticanalysis/forcetypeassert v0.0.0-20200621232751-01d4955beaa5 // indirect
github.com/gostaticanalysis/nilerr v0.1.1 // indirect
github.com/graymeta/stow v0.2.7 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/huandu/xstrings v1.0.0 // indirect
github.com/imdario/mergo v0.3.5 // indirect
Expand Down Expand Up @@ -135,7 +139,6 @@ require (
github.com/ryancurrah/gomodguard v1.2.0 // indirect
github.com/ryanrolds/sqlclosecheck v0.3.0 // indirect
github.com/sanposhiho/wastedassign v0.1.3 // indirect
github.com/satori/go.uuid v1.2.0 // indirect
github.com/securego/gosec/v2 v2.6.1 // indirect
github.com/shazow/go-diff v0.0.0-20160112020656-b6b7b6733b8c // indirect
github.com/sirupsen/logrus v1.8.0 // indirect
Expand All @@ -149,7 +152,7 @@ require (
github.com/spf13/viper v1.7.1 // indirect
github.com/ssgreg/nlreturn/v2 v2.1.0 // indirect
github.com/stretchr/objx v0.3.0 // indirect
github.com/stretchr/testify v1.7.0 // indirect
github.com/stretchr/testify v1.7.1 // indirect
github.com/subosito/gotenv v1.2.0 // indirect
github.com/tdakkota/asciicheck v0.0.0-20200416200610-e657995f937b // indirect
github.com/tetafro/godot v1.4.4 // indirect
Expand All @@ -160,15 +163,15 @@ require (
github.com/ultraware/whitespace v0.0.4 // indirect
github.com/uudashr/gocognit v1.0.1 // indirect
go.opencensus.io v0.22.6 // indirect
golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad // indirect
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519 // indirect
golang.org/x/lint v0.0.0-20201208152925-83fdc39ff7b5 // indirect
golang.org/x/mod v0.4.1 // indirect
golang.org/x/net v0.0.0-20210119194325-5f4716e94777 // indirect
golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3 // indirect
golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f // indirect
golang.org/x/oauth2 v0.0.0-20210126194326-f9ce19ea3013 // indirect
golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c // indirect
golang.org/x/text v0.3.5 // indirect
golang.org/x/sys v0.0.0-20211019181941-9d821ace8654 // indirect
golang.org/x/text v0.3.7 // indirect
golang.org/x/time v0.0.0-20201208040808-7e3f01d25324 // indirect
golang.org/x/tools v0.1.0 // indirect
golang.org/x/tools v0.1.10 // indirect
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
google.golang.org/api v0.38.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
Expand All @@ -188,6 +191,4 @@ require (
mvdan.cc/unparam v0.0.0-20210104141923-aac4ce9116a7 // indirect
)

replace github.com/vektra/mockery => github.com/enghabu/mockery v0.0.0-20191009061720-9d0c8670c2f0

replace github.com/pseudomuto/protoc-gen-doc => github.com/flyteorg/protoc-gen-doc v1.4.2
Loading

0 comments on commit d6771a3

Please sign in to comment.