Keeping track of your computations with the CLI

Keeping track of your computation is an important part of any Qarnot task. This can be done using all the different tools one can use to launch a computation, including the CLI (learn how to install and configure the tool here)

You can monitor the following task properties using the CLI:

Task status

Simply follow these steps to start monitoring the state of any task.

State monitoring script

Make sure to copy and paste the following code in a script that you can name task-state.sh, for example.

Note that you have to install the jq JSON processor package installed in order to run the script.

#!/bin/bash

# Loop to wait for the task to be over and print its state
echo "Waiting for task to end..."

TASK_UUID=$1

while  [[ "$NEW_STATE" != "Success" ]] && [[ "$NEW_STATE" != "Cancelled" ]] && [[ "$NEW_STATE" != "Failure" ]]; do
    sleep 1
    NEW_STATE=$(qarnot task info --id "$TASK_UUID" | jq -r .[].State)
    if [[ "$LAST_STATE" != "$NEW_STATE" ]]; then
        echo "Task state: $NEW_STATE"
        LAST_STATE="$NEW_STATE"
    fi
done

Launch a task

You can launch a simple task that waits 15s by running the following code in your terminal, as was shown in Launching a computation with our CLI.

Bash

qarnot task create  --name "Hello World - CLI" --profile docker-batch \
--instance 1 --constants "DOCKER_CMD=sleep 15"

Output

create task
Uuid : 1b643572-ad14-4c8e-ac5d-8c1464aa8e4c
Message : New task created, state : Submitted

Launching the state monitoring script

Once you have launched the task, you can copy the task UUID that's printed on your terminal and launch the following command to start monitoring your task state.

Bash

/bin/bash task-state.sh <<<TASK_UUID>>>

Output

Waiting for task to end...
Task state: FullyDispatched
Task state: FullyExecuting
Task state: UploadingResults
Task state: Success

Logs

In addition to printing your application's output to STDOUT, you can save them in a log file. This is especially useful if the log rate is too high, the platform won't follow the pace and print [...]. Using the following command might be useful to gather the full log:

qarnot task create --name "task-log" --profile docker-batch \
--constants DOCKER_CMD='sh -c "<<<YOUR_COMMAND>>> > /job/task.log"' \
--result task-log --instance 1

Indicators

It is possible to retrieve the task JSON that can be found in the 3rd tab on your Tasq dashboard. You simply have to run this command in your terminal:

qarnot task info --id <<<TASK_UUID>>>

You can go through the JSON contents and learn about many different characteristics of your task, focused on hardware type, performance metrics, run times, and more. Please refer to the Keeping track of your computations with the web UI documentation page for further information on how to use the Tasq interface for your monitoring needs.

For a more in depth view of the CLI please refer to the official documentation page.

Related Article

For more information on monitoring and debugging please consult the following articles