The shiny new Task API, fleshed out

Now it’s time to dig a little bit deeper into what this is, and what it means for the Golem users. To make this article more dev-oriented, to give our users a deeper dive into the API.

By Gert-Jan Rebel

Golem’s Task API has launched into testnet three weeks ago - thank you, everyone, that’s been helping out with feedback!

Now it’s time to dig a little bit deeper into what this is, and what it means for the Golem users. To make this article more dev-oriented, to give our users a deeper dive into the API.

Let’s start by the basics and dive deeper throughout the article:

What’s the Task API? The Task API is a python library containing a programming interface and utility functions. When using this library for their project, developers are able to build apps and have them easily run on the current Golem’s testnet.

Thanks to the Task API you can leverage all the computing power in the Golem Network and not rely on centralized cloud providers.

In more layman terms, the Task API is an agreement or protocol between Golem and apps so they can interoperate. Golem is able to load computational environments where apps can run. All these layers have been split so we can add environments (like docker, gWASM ) and apps ( like blender, and tutorialapp ).

How did you build this? What we technically did to implement was to separate these layers. Golem had to load docker CPU and docker GPU as the bottom layer, the computational environments. On top of this, we build an app manager, a component that is able to load apps from the data-dir and let the user enable them. Then we added a `TaskManager` for the requestor to manage the requested task state and be the bridge between the network ( TaskSession ) and the apps/environments. Last but not least, we added a new TaskComputer for the provider side, this is a bridge between the TaskSession and apps/environments on the providing side. And, as the cherry on top, we also added unit tests and integration tests for all these components, some of which developers can use to test their apps before loading them into Golem.

Who can use the Task API? Every Golem user, regardless of their technical competencies, can leverage the Task API power in a way or another.  The developers can build apps, the requestors to use apps and rent computing power using test tokens (for now, as when we launch to mainnet you will be using GNT) and the providers to run apps and trade CPU for tGNT (testGNT). The Task API is our second step (the first one being our second use-case, gWASM) in order to integrate the main user group for the Golem Network, software developers.

Want a more technical explanation?

The Task API is:

  • A GitHub repo with a code library task-api
  • A protocol definition: these are messages and functions describing how the task-api client and server interact. The library used for this is protobuf
  • A python implementation with:
    • interfaces and helpers for a client and server, the library used for this is grpclib
    • helper functions for testing
      -- build tools ( in progress )
  • a task-api client implementation inside the Golem core
    • environments and runtimes (a runtime is a computation job like requesting or providing a task.)
      • computational environments, a docker installed on the system and configured properly, that spawn runtime when an application is run (currently, docker_cpu and docker_gpu are the only environments available)
      • applications, aka task-api servers
      • application descriptor JSON files in the data-dir
      • loaded, registered and benchmarked on startup
        --- enabled by the user
  • applications, aka task-api servers
    • App descriptor file:
      • Name
      • Version
      • requestor prerequisites ( docker image )
      • Environment
      • Market strategy
    • this JSON file is only required by the requestor, the provider needs to whitelist the prerequisite source in order to pick up the task
      support for any task-api server in any environment.
      • applications can be added for requestors by adding the JSON to the golem data-dir
      • all applications can be provided for as long as the environment is enabled and the prerequisite source is whitelisted
      • environments can be added in golem core releases
  • a task-api server implementation in blenderapp and tutorialapp
    • blenderapp is an extraction of the current blender logic in golem core
    • tutorialapp is an example application running a simple proof of work computation

Are you ready to take on the challenge and try the new Golem Task API?

Then go for it! Get started with our docs over here.

As a note, we would like to let you know that even though we cannot avoid bad actors from forking existing apps - we’d like to ask you to use Golem responsibly and honestly.

Our goal is to create a free ( not as in “free beer”, but as in freedom ) and open market place where anyone can add what they want, but also be respectful of others.


Additional useful links:

Running a blender task on the current testnet

Building and running the `tutorialapp` locally

https://github.com/golemfactory/task-api

https://github.com/golemfactory/blenderapp

https://github.com/golemfactory/tutorialapp