G
G
Golem SDK
Search…
Run first task on Golem

Running the requestor and your first task on the New Golem Network

Now you have the yagna daemon running, you may proceed with running a task as a requestor.
Python
NodeJS

Get the environment set up

Ensure you're running Python >= 3.6 and you have the venv module installed (it's normally included in the Python distribution).
Prepare a virtual environment for the tutorial script:
1
python3 -m venv --clear ~/.envs/yagna-python-tutorial
2
source ~/.envs/yagna-python-tutorial/bin/activate
Copied!
On Windows, you need to replace the above with:
1
python -m venv --clear %HOMEDRIVE%%HOMEPATH%\.envs\yagna-python-tutorial
2
%HOMEDRIVE%%HOMEPATH%\.envs\yagna-python-tutorial\Scripts\activate.bat
Copied!
Install the dependencies:
1
pip install -U pip
2
pip install yapapi
Copied!

Get the requestor agent's code

Check out or download the yapapi repository:
1
git clone https://github.com/golemfactory/yapapi.git
Copied!
and make sure you're working on the version corresponding with the latest release:
1
cd yapapi
2
git checkout b0.7
Copied!

Set the yagna app key

In order for the requestor agent to connect with the yagna daemon, you need to provide it with the previously-generated app key. You do that by setting the appropriate environment variable to a value acquired in the "Generate the app key" step in the quick primer article:
1
export YAGNA_APPKEY=insert-your-32-char-app-key-here
Copied!
On Windows, please replace the above with:
set YAGNA_APPKEY=your-32-char-app-key
Run the example
The example we're showcasing here resides in the examples/blender directory within yapapi's codebase so, ensure that you're in the checked-out repository's directory and run:
1
cd examples/blender
2
python blender.py
Copied!
Once you launch the example, you should see some messages reflecting the progress of your tasks' execution - agreement confirmations, task dispatches and finally task completions.
The example in question generates six discrete tasks for providers to execute so after those six activities are completed and results returned, the whole job is finished.
If everything goes right, after what could be anything from half-a-minute to a few minutes, you'll hopefully see the message announcing the successful completion of your assignment including a short summary of what had happened during the execution, which providers took part in the execution and the accumulated GNT cost of the whole task, e.g.:
Computation finished in 77.5s Negotiated 1 agreements with 1 providers Provider 'odra' computed 6 tasks Total cost: 0.218290307253

Get the requestor agent's code

Check out or download the yajsapi repository:
1
git clone https://github.com/golemfactory/yajsapi.git
2
cd yajsapi
3
git checkout b0.4
Copied!

Set the yagna app key

In order for the requestor agent to connect with the yagna daemon, you need to provide it with the previously-generated app key. You do that by setting the appropriate environment variable to a value acquired in the "Generate the app key" step above:
1
export YAGNA_APPKEY=insert-your-32-char-app-key-here
Copied!
On Windows, please replace the above with:
set YAGNA_APPKEY=your-32-char-app-key

Run the example task

The example we're showcasing here resides in the examples/blender directory within yajsapi's codebase so, ensure that you're in the checked-out repository's directory and run:
1
cd examples
2
yarn
3
yarn js:blender
Copied!
If everything works as expected, you should see some messages that confirm agreements being struck between your requestor node and the providers in our testnet and then ones that announce work dispatched to providers with lines starting with Task sent to provider [...] and subsequently confirmations of task completions.
To see some more detailed messages, you can run the example with yarn js:blender -d.
The example in question generates six discrete jobs for providers to execute so after those six activities are completed and results returned, the whole task is finished.
Yay! With this, you have completed your first job as a requestor in the new Golem network!

Output

You can verify that the task is indeed done by examining the generated output files which are PNG images with the selected frames of the rendered animation that should appear in the directory from which you ran the example script (examples/blender within the cloned repository's path if you followed the tutorial precisely) .
Here is an example rendered frame, provided here for reference:

Payments

Finally, you can verify that the providers have been paid for the work they contributed to get that output to you. First, acquire your Ethereum address - you can do that by running:
1
yagna app-key list
Copied!
again but this time it's the value in the id column that you're interested in. This is your the Ethereum address of your yagna node on the Rinkeby testnet and on zkSync. Once you have that address, head to https://rinkeby.zkscan.io/ , put the value in the address field there and verify that you see the outgoing payment transactions.
Last modified 6d ago
Copy link