Page 1 of 2

JSON Request for task

Posted: Thu Apr 16, 2020 12:21 pm
by artem.lavilin
Hello! How to form a json-request for all information about current task (time start, etc)?
I looked at all the files in the examples folder, but did not find what I needed.
Try this:

Code: Select all

{
	"get":
	{
		"type" : "jobs",
		"block_ids" : [1],
		"task_ids" : [0],
		"ids" : [3]
	}
}
But how to get the 'block_ids', 'task_ids' is not very clear.
Thanks in advance.

Re: JSON Request for task

Posted: Thu Apr 16, 2020 12:29 pm
by timurhai
Hi!
Block and task id is just their number (array index), 0 - is the first, 1 - is the second, n-1 - is the last.

Re: JSON Request for task

Posted: Thu Apr 16, 2020 12:37 pm
by artem.lavilin
Does this mean if I want to get information about tasks I need to get a block_num and task_num and then iterate over them?
It's correctly?

Code: Select all

task_num= task['task_num']
block_num= task['block_num']
job_id = task['job_id']

get = {
	'type': 'jobs',
	'ids': [job_id],
	'block_ids': range(0, block_num),
	'tasks_ids': range(0, task_num),
}
            
request = af.json.dumps({'get': get})
result, jobInfo = af.afnetwork.sendServer(request)

Re: JSON Request for task

Posted: Thu Apr 16, 2020 12:48 pm
by artem.lavilin
Maybe there is some easier way to get this information about task by Python Api?

Re: JSON Request for task

Posted: Thu Apr 16, 2020 12:51 pm
by timurhai
You can open Web GUI and see network log to see how it works.
Also you can launch AfWatch in a terminal (linux), it prints json requests too.

If you need to get job all tasks, you can get job with tasks at once:
https://github.com/CGRU/cgru/blob/maste ... bs.json#L8

Re: JSON Request for task

Posted: Thu Apr 16, 2020 1:09 pm
by artem.lavilin
Thanks. I'll try look at the network log.

Re: JSON Request for task

Posted: Thu Apr 16, 2020 4:20 pm
by artem.lavilin
Sorry, I do not get the information I wanted.
I try request with block_id and task_id, but result is empty. I looked at the net-monitor.
If i use only block_id, i get result (i get info only about tasks_num, tasks_name, etc). task_id doesn’t affect anything.
How to get complete information about a specific task?

Re: JSON Request for task

Posted: Thu Apr 16, 2020 4:24 pm
by timurhai
You can open it in GUI and see logs.

Re: JSON Request for task

Posted: Thu Apr 16, 2020 4:26 pm
by artem.lavilin
I need to see task through python.

Re: JSON Request for task

Posted: Thu Apr 16, 2020 4:34 pm
by timurhai
Server has only JSON API. Python module (API) just helps you to construct a valid JSON objects.