Multi-language Workflows
Learn how to create workflows that use tasks written in different languages
Tilebox languages and SDKs
Tilebox supports multiple languages and SDKs for running workflows. All Tilebox SDKs and workflows are designed to be interoperable, which means it’s possible to have a workflow where individual tasks are executed in different languages. Check out Languages & SDKs to learn more about currently available programming SDKs.
Why multi-language workflows?
You might need to use multiple languages in a single workflow for many reasons, such as:
- You want to use a language that is better suited for a specific task (for example Python for data processing, Go for a backend API)
- You want to use a library that is only available in a specific language (for example xarray in Python)
- You started prototyping in Python, but need to start migrating the compute-intensive parts of your workflow to a different language for performance reasons
Multi-language workflow example
This guide will tackle the first use case: you have a tasking server in Go and want to offload some of the processing to Python.
Defining tasks in Python and Go
A couple important points to note:
Input parameters
Input parameters
The dataclass parameters in Python must match the struct fields in Go, including the types and the names (through the JSON tags in Go).
Due to Go and Python having different naming conventions, it’s recommended to use JSON tags in the Go struct to match the Python dataclass field names to respect the language-specific conventions.
Go fields must start with an uppercase letter to be serialized to JSON.
The need for JSON tags in the preceding Go code is currently necessary but might be removed in the future.
Execute method
Execute method
The execute method is defined in the Python task but not in the Go task since Go will only be used to submit the task, not executing it.
Identifier
Identifier
It’s necessary to define the identifier
method in both the Python and Go tasks and to make sure they match.
The identifier
method has two values, the first being an arbitrary unique task identifier and the second being the version in the v{major}.{minor}
format.
Creating a Go server that submits jobs
Write a simple HTTP tasking server in Go with a /submit
endpoint that accepts requests to submit a ScheduleImageCapture
job.
Both Go and Python code are using test-cluster-tZD9Ca2qsqt4V
as the cluster slug. You should replace it with your own cluster slug, which you can create in the Tilebox Console.
In the same way that you can submit jobs across languages you can also submit subtasks across languages.
Creating a Python runner
Write a Python script that starts a task runner and registers the ScheduleImageCapture
task.
Testing it
Start the Go server.
In another terminal, start the Python runner.
Submit a job to the Go server.
Check the Python runner output, it should print the following line:
Next Steps
As a learning exercise, you can try to change the News API Workflow to replace the FetchNews
task with a Go task and keep all the other tasks in Python.
You’ll learn how to submit a subtask in another language than what the current task is executed in.