Using Raw Container Task
In Truefoundry workflow, a container task allows you to execute a command or script inside a Docker container without needing to write a custom Python function for that specific task. It provides a way to use pre-built Docker images and run commands directly within those containers.
ContainerTaskConfig
- Just like python task config, in container task, we have
ContainerTaskConfig
which take, image spec as image, env, resource and service_account as input.
Example
Now lets take a look at the example where we will just use the alpine base image and then print the number from 1 to 10 and will print their sum.
Prerequisites
Before you proceed with the guide, make sure you have the following:
- Truefoundry CLI: Set up and configure the TrueFoundry CLI tool on your local machine by following the Setup for CLI guide.
- Workspace: To deploy your workflow, you’ll need a workspace. If you don’t have one, you can create it using this guide: Creating a Workspaceor seek assistance from your cluster administrator.
Creating the workflow
Create a workflow.py where we will write the code for our workflow and place in the project root folder. (With other dependent files and requirements.txt)
workflow.py
- So here we have defined container_task where we are using alpine image and the command which is basically a bash script to print the number from 1 to 10 and their sum.
- The container task can be called in the same way as you call the python task.
Now run the below command in the terminal to deploy your workflow, replace <workfspace-fqn>
with the workspace fqn which you can find on the UI.