Run your worker locally¶
Once you have implemented a worker, you can run it on some Arkindex elements on your own machine to test it.
Retrieving credentials¶
For a worker to run properly, you will need two types of credentials:
- An API token that gives the worker access to the API
- A worker run ID that lets the worker send results to Arkindex and report that those come from this particular worker run
Retrieving a token¶
For the worker to run, you will need an Arkindex authentication token. You can use your own account’s token when testing on your own machine.
You can retrieve your personal API Token from your profile page.
Creating a user worker run¶
Every object published from a worker in Arkindex is tracked using a worker run reference. In order to test your worker, you can create a new user worker run by following the official Arkindex documentation.
Retrieving a existing worker run ID¶
-
Open a web browser and browse to the Arkindex instance.
-
In the top-right user menu, click on Worker Runs.
-
You can copy the ID of a listed worker by clicking in the ID column, or create a new one from the web interface.
Setting credentials¶
In a shell you need to set 3 environment variables to transmit your credentials and Arkindex instance information to the worker:
ARKINDEX_API_URL
- URL that points to the root of the Arkindex instance you are using.
ARKINDEX_API_TOKEN
- The API token you retrieved earlier, on your profile page.
ARKINDEX_WORKER_RUN_ID
- The worker run ID you retrieved earlier. Can be omitted if the worker does not create new data in Arkindex.
To set credentials for your worker¶
- In a shell, run:
export ARKINDEX_API_URL="https://arkindex.teklia.com"
export ARKINDEX_API_TOKEN="YOUR_TOKEN_HERE"
export ARKINDEX_WORKER_RUN_ID="xxxxx"
Warning
Do not add these instructions to a script such as .bashrc
;
this would mean storing credentials in plaintext and can lead to security breaches
Running your worker¶
With the credentials configured, you can now run your worker. You will need a list of element IDs to run your worker on, which can be found in the browser’s address bar when browsing an element on Arkindex.
To run your worker¶
- Activate the Python environment: run
workon X
whereX
is the name of your Python environment. - Run
worker-X
, whereX
is the__package
name of your worker, followed by--element=Y
whereY
is the ID of an element. You can repeat--element
as many times as you need to process multiple elements.