Skip to content

Commit

Permalink
Merge branch 'master' into update-maptask-example
Browse files Browse the repository at this point in the history
  • Loading branch information
pingsutw authored Nov 26, 2023
2 parents ce3e232 + 829590f commit 31f38b7
Show file tree
Hide file tree
Showing 67 changed files with 1,177 additions and 1,910 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,8 @@ jobs:
e2e-tests:
runs-on: ubuntu-latest
env:
FLYTESNACKS_PRIORITIES: 'P0'
FLYTESNACKS_VERSION: ''
FLYTESNACKS_PRIORITIES: "P0"
FLYTESNACKS_VERSION: ""
timeout-minutes: 30
steps:
- name: Set latest Flytesnacks release
Expand All @@ -185,7 +185,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
python-version: "3.11"
- uses: unionai/[email protected]
- name: Setup sandbox
run: |
Expand Down Expand Up @@ -220,15 +220,15 @@ jobs:
advanced_composition/advanced_composition/dynamics.py \
advanced_composition/advanced_composition/map_task.py \
advanced_composition/advanced_composition/subworkflows.py \
data_types_and_io/data_types_and_io/custom_objects.py \
data_types_and_io/data_types_and_io/schema.py \
data_types_and_io/data_types_and_io/typed_schema.py ;
data_types_and_io/data_types_and_io/dataclass.py \
data_types_and_io/data_types_and_io/structured_dataset.py ;
do
# TODO: unpin version of flytekit once the FlyteFile bug is fixed
pyflyte --config ./boilerplate/flyte/end2end/functional-test-config.yaml \
register \
--project flytesnacks \
--domain development \
--image cr.flyte.org/flyteorg/flytekit:py3.11-latest \
--image cr.flyte.org/flyteorg/flytekit:py3.11-1.10.0 \
--version ${{ env.FLYTESNACKS_VERSION }} \
flytesnacks/examples/$f;
done
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/serialize_example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ jobs:
with:
fetch-depth: "0"
- uses: unionai/[email protected]
with:
version: 'v0.7.8'
- name: setup download artifact dir
run: |
mkdir download-artifact
Expand Down
File renamed without changes.
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export REPOSITORY=flytesnacks
include boilerplate/flyte/end2end/Makefile
.SILENT:

Expand Down Expand Up @@ -27,3 +28,7 @@ fmt: ## Format code with black and isort
autoflake --remove-all-unused-imports --ignore-init-module-imports --ignore-pass-after-docstring --in-place -r examples
pre-commit run black --all-files || true
pre-commit run isort --all-files || true

.PHONY: update_boilerplate
update_boilerplate:
@boilerplate/update.sh
4 changes: 2 additions & 2 deletions boilerplate/flyte/code_of_conduct/update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@

set -e

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

cp "${DIR}"/CODE_OF_CONDUCT.md "${DIR}"/../../../CODE_OF_CONDUCT.md
cp "$DIR"/CODE_OF_CONDUCT.md "$DIR"/../../../CODE_OF_CONDUCT.md
5 changes: 3 additions & 2 deletions boilerplate/flyte/end2end/end2end.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
# TO OPT OUT OF UPDATES, SEE https://github.com/flyteorg/boilerplate/blob/master/Readme.rst
set -eu

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

python ./boilerplate/flyte/end2end/run-tests.py "$FLYTESNACKS_VERSION" "$FLYTESNACKS_PRIORITIES" "$CONFIG_FILE" "${EXTRA_FLAGS[@]}"
17 changes: 2 additions & 15 deletions boilerplate/flyte/end2end/functional-test-config.yaml
Original file line number Diff line number Diff line change
@@ -1,18 +1,5 @@
admin:
# For GRPC endpoints you might want to use dns:///flyte.myexample.com
endpoint: dns:///localhost:30080
insecure: true
authType: Pkce
logger:
show-source: true
level: 0
storage:
connection:
access-key: minio
auth-type: accesskey
disable-ssl: true
endpoint: http://localhost:30002
region: us-east-1
secret-key: miniostorage
type: minio
container: "my-s3-bucket"
enable-multicontainer: true
insecure: true
79 changes: 63 additions & 16 deletions boilerplate/flyte/end2end/run-tests.py
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import sys
import time
import traceback
from typing import Dict, List, Mapping, Tuple
from typing import Dict, List, Mapping, Optional, Tuple

import click
import requests
Expand Down Expand Up @@ -50,15 +50,17 @@
("basics.named_outputs.simple_wf_with_named_outputs", {}),
# # Getting a 403 for the wikipedia image
# # ("basics.reference_task.wf", {}),
("data_types_and_io.custom_objects.wf", {"x": 10, "y": 20}),
("data_types_and_io.dataclass.dataclass_wf", {"x": 10, "y": 20}),
# Enums are not supported in flyteremote
# ("type_system.enums.enum_wf", {"c": "red"}),
("data_types_and_io.schema.df_wf", {"a": 42}),
("data_types_and_io.typed_schema.wf", {}),
("data_types_and_io.structured_dataset.simple_sd_wf", {"a": 42}),
# ("my.imperative.workflow.example", {"in1": "hello", "in2": "foo"}),
],
"integrations-k8s-spark": [
("k8s_spark_plugin.pyspark_pi.my_spark", {"triggered_date": datetime.datetime.now()}),
(
"k8s_spark_plugin.pyspark_pi.my_spark",
{"triggered_date": datetime.datetime.now()},
),
],
"integrations-kfpytorch": [
("kfpytorch_plugin.pytorch_mnist.pytorch_training_wf", {}),
Expand Down Expand Up @@ -89,10 +91,16 @@
}


def execute_workflow(remote, version, workflow_name, inputs):
def execute_workflow(
remote: FlyteRemote,
version,
workflow_name,
inputs,
cluster_pool_name: Optional[str] = None,
):
print(f"Fetching workflow={workflow_name} and version={version}")
wf = remote.fetch_workflow(name=workflow_name, version=version)
return remote.execute(wf, inputs=inputs, wait=False)
return remote.execute(wf, inputs=inputs, wait=False, cluster_pool=cluster_pool_name)


def executions_finished(executions_by_wfgroup: Dict[str, List[FlyteWorkflowExecution]]) -> bool:
Expand Down Expand Up @@ -125,17 +133,18 @@ def schedule_workflow_groups(
workflow_groups: List[str],
remote: FlyteRemote,
terminate_workflow_on_failure: bool,
cluster_pool_name: Optional[str] = None,
) -> Dict[str, bool]:
"""
Schedule workflows executions for all workflow gropus and return True if all executions succeed, otherwise
Schedule workflows executions for all workflow groups and return True if all executions succeed, otherwise
return False.
"""
executions_by_wfgroup = {}
# Schedule executions for each workflow group,
for wf_group in workflow_groups:
workflows = FLYTESNACKS_WORKFLOW_GROUPS.get(wf_group, [])
executions_by_wfgroup[wf_group] = [
execute_workflow(remote, tag, workflow[0], workflow[1]) for workflow in workflows
execute_workflow(remote, tag, workflow[0], workflow[1], cluster_pool_name) for workflow in workflows
]

# Wait for all executions to finish
Expand Down Expand Up @@ -179,11 +188,14 @@ def run(
priorities: List[str],
config_file_path,
terminate_workflow_on_failure: bool,
test_project_name: str,
test_project_domain: str,
cluster_pool_name: Optional[str] = None,
) -> List[Dict[str, str]]:
remote = FlyteRemote(
Config.auto(config_file=config_file_path),
default_project="flytesnacks",
default_domain="development",
test_project_name,
test_project_domain,
)

# For a given release tag and priority, this function filters the workflow groups from the flytesnacks
Expand Down Expand Up @@ -215,7 +227,11 @@ def run(
valid_workgroups.append(workflow_group)

results_by_wfgroup = schedule_workflow_groups(
flytesnacks_release_tag, valid_workgroups, remote, terminate_workflow_on_failure
flytesnacks_release_tag,
valid_workgroups,
remote,
terminate_workflow_on_failure,
cluster_pool_name,
)

for workflow_group, succeeded in results_by_wfgroup.items():
Expand Down Expand Up @@ -246,6 +262,9 @@ def run(


@click.command()
@click.argument("flytesnacks_release_tag")
@click.argument("priorities")
@click.argument("config_file")
@click.option(
"--return_non_zero_on_failure",
default=False,
Expand All @@ -258,18 +277,46 @@ def run(
is_flag=True,
help="Abort failing workflows upon exit",
)
@click.argument("flytesnacks_release_tag")
@click.argument("priorities")
@click.argument("config_file")
@click.option(
"--test_project_name",
default="flytesnacks",
type=str,
is_flag=False,
help="Name of project to run functional tests on",
)
@click.option(
"--test_project_domain",
default="development",
type=str,
is_flag=False,
help="Name of domain in project to run functional tests on",
)
@click.argument(
"cluster_pool_name",
required=False,
type=str,
default=None,
)
def cli(
flytesnacks_release_tag,
priorities,
config_file,
return_non_zero_on_failure,
terminate_workflow_on_failure,
test_project_name,
test_project_domain,
cluster_pool_name,
):
print(f"return_non_zero_on_failure={return_non_zero_on_failure}")
results = run(flytesnacks_release_tag, priorities, config_file, terminate_workflow_on_failure)
results = run(
flytesnacks_release_tag,
priorities,
config_file,
terminate_workflow_on_failure,
test_project_name,
test_project_domain,
cluster_pool_name,
)

# 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)}")
Expand Down
1 change: 1 addition & 0 deletions dev-requirements.in
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ isort
mock
pytest
mypy
mashumaro
Loading

0 comments on commit 31f38b7

Please sign in to comment.