Documentation

Fetching logs

#!/usr/bin/env python3

import qarnot

conn = qarnot.Connection(client_token="<<< PUT YOUR SECRET TOKEN >>>")
task = conn.create_task("test logs Tasq", "docker-batch", 1)

task.constants["DOCKER_CMD"] = 'sh -c "echo This work for both stdout...; \
                                       sleep 5; \
                                       echooo ... and stderr!"'

task.submit()
#!/usr/bin/env python3

import qarnot
import sys

conn = qarnot.Connection(client_token="<<< PUT YOUR SECRET TOKEN >>>")
task = conn.create_task("test logs terminal", "docker-batch", 1)

task.constants["DOCKER_CMD"] = 'sh -c "echo This work for both stdout...; \
                                       sleep 5; \
                                       echooo ... and stderr!"'

task.submit()

done = False
while not done:
    # Wait for 5 seconds and returns True if the task is finished 
    done = task.wait(5)

    # Display fresh stdout / stderr
    sys.stdout.write(task.fresh_stdout())
    sys.stderr.write(task.fresh_stderr())
0> This work for both stdout...
0> sh: 1: echooo: not found
#!/usr/bin/env python3

import qarnot

conn = qarnot.Connection(client_token="<<< PUT YOUR SECRET TOKEN >>>")
task = conn.create_task("test logs file", "docker-batch", 1)

output_bucket = conn.create_bucket("output")
task.results = output_bucket

task.constants["DOCKER_CMD"] = 'sh -c "echo This work for both stdout... >> test.log 2>&1; \
                                       sleep 5; \
                                       echooo ... and stderr! >> test.log 2>&1"'

# Upload the content of /job to your output bucket every 5 seconds
task.snapshot(5)

task.submit()

done = False
while not done:
    # Download the content of the output bucket locally
    task.download_results('my_output_folder')
    # Wait for 5 seconds and returns True if the task is finished 
    done = task.wait(5)
#!/usr/bin/env python3

import qarnot

conn = qarnot.Connection(client_token="<<< PUT YOUR SECRET TOKEN >>>")
task = conn.create_task("test logs file and Tasq", "docker-batch", 1)

output_bucket = conn.create_bucket("output")
task.results = output_bucket

task.constants["DOCKER_CMD"] = 'sh -c "echo This work for both stdout... 2>&1 | tee -a test.log; \
                                       sleep 5; \
                                       echooo ... and stderr! 2>&1 | tee -a test.log"'

# Upload the content of /job to your output bucket every 5 seconds
task.snapshot(5)

task.submit()

done = False
while not done:
    # Download the content of the output bucket locally
    task.download_results('my_output_folder')
    # Wait for 5 seconds and returns True if the task is finished 
    done = task.wait(5)

Any feedback on this page ?