acoustic-carpenter-78188
11/07/2023, 7:45 PM"""Simple tasks that can be used to debug flyte."""
import os
from flytekit import PodTemplate, Resources, task
from flytekitplugins.spark import Spark
from kubernetes.client import V1Container, V1PodSpec, V1Toleration
from .utils import SparkTaskHelper
task_helper = SparkTaskHelper(
client=os.environ.get("CLIENT", "client"),
)
@task(
requests=Resources(cpu="0.1", mem="128Mi"),
limits=Resources(cpu="0.2", mem="256Mi"),
container_image=task_helper.container_image,
pod_template=PodTemplate(
primary_container_name="primary",
pod_spec=V1PodSpec(
containers=[
V1Container(
name="primary",
image="hello-world",
),
],
node_selector={"app": "flyte"},
tolerations=[
V1Toleration(
key="app",
operator="Equal",
value="flyte",
effect="NoSchedule",
),
],
),
),
)
def hello_world_no_spark() -> None:
"""Print "hello world"."""
print("hello world")
@task(
task_config=Spark(
spark_conf=task_helper.spark_confs,
executor_path=task_helper.ex_path,
applications_path=task_helper.app_path,
),
container_image=task_helper.container_image,
pod_template=PodTemplate(
primary_container_name="primary",
pod_spec=V1PodSpec(
containers=[
V1Container(
name="primary",
image="hello-world",
),
],
node_selector={"app": "flyte"},
tolerations=[
V1Toleration(
key="app",
operator="Equal",
value="flyte",
effect="NoSchedule",
),
],
),
),
)
def hello_world_spark() -> None:
"""Print "hello world"."""
print("hello world")
yields
{"config":{"primary_container_name":"primary"},"id":{"resourceType":1,"project":"flint","domain":"development","name":"flint_tasks.test.hello_world.hello_world_no_spark","version":"5.2.0-5dca779"},"type":"python-task","metadata":{"tags":{},"runtime":{"type":1,"version":"1.10.0","flavor":"python"},"retries":{}},"interface":{"inputs":{"variables":{}},"outputs":{"variables":{}}},"k8sPod":{"metadata":{"labels":{},"annotations":{}},"podSpec":{"fields":{"containers":{"listValue":{"values":[{"structValue":{"fields":{"env":{"listValue":{"values":[]}},"image":{"stringValue":"275184421095.dkr.ecr.af-south-1.amazonaws.com/flint-spark:5.2.0-5dca779-flint"},"name":{"stringValue":"primary"},"command":{"listValue":{"values":[]}},"resources":{"structValue":{"fields":{"limits":{"structValue":{"fields":{"memory":{"stringValue":"256Mi"},"cpu":{"stringValue":"0.2"}}}},"requests":{"structValue":{"fields":{"cpu":{"stringValue":"0.1"},"memory":{"stringValue":"128Mi"}}}}}}},"args":{"listValue":{"values":[{"stringValue":"pyflyte-fast-execute"},{"stringValue":"--additional-distribution"},{"stringValue":*****},{"stringValue":"--dest-dir"},{"stringValue":"/root"},{"stringValue":"--"},{"stringValue":"pyflyte-execute"},{"stringValue":"--inputs"},{"stringValue":"{{.input}}"},{"stringValue":"--output-prefix"},{"stringValue":"{{.outputPrefix}}"},{"stringValue":"--raw-output-data-prefix"},{"stringValue":"{{.rawOutputDataPrefix}}"},{"stringValue":"--checkpoint-path"},{"stringValue":"{{.checkpointOutputPrefix}}"},{"stringValue":"--prev-checkpoint"},{"stringValue":"{{.prevCheckpointPrefix}}"},{"stringValue":"--resolver"},{"stringValue":"flytekit.core.python_auto_container.default_task_resolver"},{"stringValue":"--"},{"stringValue":"task-module"},{"stringValue":"flint_tasks.test.hello_world"},{"stringValue":"task-name"},{"stringValue":"hello_world_no_spark"}]}}}}}]}},"tolerations":{"listValue":{"values":[{"structValue":{"fields":{"effect":{"stringValue":"NoSchedule"},"operator":{"stringValue":"Equal"},"value":{"stringValue":"flyte"},"key":{"stringValue":"app"}}}}]}},"nodeSelector":{"structValue":{"fields":{"app":{"stringValue":"flyte"}}}}}}}}
for hello_world_no_spark and
{
"config": {
"primary_container_name": "primary"
},
"id": {
"resourceType": 1,
"project": "flint",
"domain": "development",
"name": "flint_tasks.test.hello_world.hello_world_spark",
"version": "5.2.0-dd4654f"
},
"type": "spark",
"metadata": {
"tags": {},
"runtime": {
"type": 1,
"version": "1.10.0",
"flavor": "python"
},
"retries": {}
},
"interface": {
"inputs": {
"variables": {}
},
"outputs": {
"variables": {}
}
},
"custom": {
"fields": {
"sparkConf": {
"structValue": {
"fields": {
"spark.kubernetes.executor.request.cores": {
"stringValue": "1"
},
"spark.executor.instances": {
"stringValue": "4"
},
"spark.kubernetes.driver.limit.cores": {
"stringValue": "1"
},
"spark.sql.hive.metastore.jars.path": {
"stringValue": "file:///opt/spark/jars/hive/*.jar"
},
"spark.sql.hive.metastore.version": {
"stringValue": "3.1.3"
},
"spark.hive.metastore.uris": {
"stringValue": "thrift://poc-flint-metastore-thrift.flyte:9083"
},
"spark.sql.catalogImplementation": {
"stringValue": "hive"
},
"spark.kubernetes.driver.request.cores": {
"stringValue": "1"
},
"spark.executor.memory": {
"stringValue": "2g"
},
"spark.kubernetes.executor.limit.cores": {
"stringValue": "4"
},
"spark.sql.hive.metastore.jars": {
"stringValue": "path"
}
}
}
},
"databricksConf": {
"structValue": {
"fields": {}
}
},
"mainApplicationFile": {
"stringValue": "local:///usr/local/bin/entrypoint.py"
},
"executorPath": {
"stringValue": "python"
}
}
},
"k8sPod": {
"metadata": {
"labels": {},
"annotations": {}
},
"podSpec": {
"fields": {
"nodeSelector": {
"structValue": {
"fields": {
"app": {
"stringValue": "flyte"
}
}
}
},
"containers": {
"listValue": {
"values": [
{
"structValue": {
"fields": {
"args": {
"listValue": {
"values": [
{
"stringValue": "pyflyte-fast-execute"
},
{
"stringValue": "--additional-distribution"
},
{
"stringValue": "s3://dev-flyte-s3-storage/flint/development/4LLRY7MSZOQFAUROC42QEWSXOY======/fast07b0f2c937e3074c9a67215953b107e2.tar.gz"
},
{
"stringValue": "--dest-dir"
},
{
"stringValue": "/root"
},
{
"stringValue": "--"
},
{
"stringValue": "pyflyte-execute"
},
{
"stringValue": "--inputs"
},
{
"stringValue": "{{.input}}"
},
{
"stringValue": "--output-prefix"
},
{
"stringValue": "{{.outputPrefix}}"
},
{
"stringValue": "--raw-output-data-prefix"
},
{
"stringValue": "{{.rawOutputDataPrefix}}"
},
{
"stringValue": "--checkpoint-path"
},
{
"stringValue": "{{.checkpointOutputPrefix}}"
},
{
"stringValue": "--prev-checkpoint"
},
{
"stringValue": "{{.prevCheckpointPrefix}}"
},
{
"stringValue": "--resolver"
},
{
"stringValue": "flytekit.core.python_auto_container.default_task_resolver"
},
{
"stringValue": "--"
},
{
"stringValue": "task-module"
},
{
"stringValue": "flint_tasks.test.hello_world"
},
{
"stringValue": "task-name"
},
{
"stringValue": "hello_world_spark"
}
]
}
},
"env": {
"listValue": {
"values": []
}
},
"image": {
"stringValue": "275184421095.dkr.ecr.af-south-1.amazonaws.com/flint-spark:5.2.0-dd4654f-flint"
},
"name": {
"stringValue": "primary"
},
"command": {
"listValue": {
"values": []
}
}
}
}
}
]
}
},
"tolerations": {
"listValue": {
"values": [
{
"structValue": {
"fields": {
"value": {
"stringValue": "flyte"
},
"key": {
"stringValue": "app"
},
"effect": {
"stringValue": "NoSchedule"
},
"operator": {
"stringValue": "Equal"
}
}
}
}
]
}
}
}
}
}
}
for hello_world_spark
On creation, the manifest…
flyteorg/flyteacoustic-carpenter-78188
11/08/2023, 5:43 AMacoustic-carpenter-78188
11/08/2023, 5:43 AM