JSON Request for task

General discussions and questions.
artem.lavilin
Posts: 10
Joined: Thu Apr 16, 2020 12:10 pm

JSON Request for task

Post 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.
User avatar
timurhai
Site Admin
Posts: 911
Joined: Sun Jan 15, 2017 8:40 pm
Location: Russia, Korolev
Contact:

Re: JSON Request for task

Post 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.
Timur Hairulin
CGRU 3.3.1, Ubuntu 20.04, 22.04, MS Windows 10 (clients only).
artem.lavilin
Posts: 10
Joined: Thu Apr 16, 2020 12:10 pm

Re: JSON Request for task

Post 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)
artem.lavilin
Posts: 10
Joined: Thu Apr 16, 2020 12:10 pm

Re: JSON Request for task

Post by artem.lavilin »

Maybe there is some easier way to get this information about task by Python Api?
Attachments
2020-04-16_15-44-57.png
2020-04-16_15-44-57.png (27.96 KiB) Viewed 7112 times
User avatar
timurhai
Site Admin
Posts: 911
Joined: Sun Jan 15, 2017 8:40 pm
Location: Russia, Korolev
Contact:

Re: JSON Request for task

Post 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
Timur Hairulin
CGRU 3.3.1, Ubuntu 20.04, 22.04, MS Windows 10 (clients only).
artem.lavilin
Posts: 10
Joined: Thu Apr 16, 2020 12:10 pm

Re: JSON Request for task

Post by artem.lavilin »

Thanks. I'll try look at the network log.
artem.lavilin
Posts: 10
Joined: Thu Apr 16, 2020 12:10 pm

Re: JSON Request for task

Post 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?
User avatar
timurhai
Site Admin
Posts: 911
Joined: Sun Jan 15, 2017 8:40 pm
Location: Russia, Korolev
Contact:

Re: JSON Request for task

Post by timurhai »

You can open it in GUI and see logs.
Timur Hairulin
CGRU 3.3.1, Ubuntu 20.04, 22.04, MS Windows 10 (clients only).
artem.lavilin
Posts: 10
Joined: Thu Apr 16, 2020 12:10 pm

Re: JSON Request for task

Post by artem.lavilin »

I need to see task through python.
User avatar
timurhai
Site Admin
Posts: 911
Joined: Sun Jan 15, 2017 8:40 pm
Location: Russia, Korolev
Contact:

Re: JSON Request for task

Post by timurhai »

Server has only JSON API. Python module (API) just helps you to construct a valid JSON objects.
Timur Hairulin
CGRU 3.3.1, Ubuntu 20.04, 22.04, MS Windows 10 (clients only).
Post Reply