from truefoundry.workflow import task, workflow, ContainerTaskConfig, ContainerTask
from truefoundry.deploy import Image
container_task = ContainerTask(
name="container_task",
task_config=ContainerTaskConfig(
image=Image(
image_uri="alpine:3.12",
command=[
"/bin/sh",
"-c",
"""
# Generate a sequence of numbers from 1 to 10
seq 1 10 | tee /var/data/numbers.txt
# Calculate the sum of these numbers
sum=$(seq 1 10 | awk '{s+=$1} END {print s}')
# Save the sum to a file
echo "Sum: $sum"
""",
],
)
),
)
@workflow
def sum_of_numbers() -> str:
container_task()
return "The sum of numbers from 1 to 10 has been calculated."