JSON Request for task

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

JSON Request for task

Post by artem.lavilin » Thu Apr 16, 2020 12:21 pm

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: 580
Joined: Sun Jan 15, 2017 8:40 pm
Location: Russia, Korolev
Contact:

Re: JSON Request for task

Post by timurhai » Thu Apr 16, 2020 12:29 pm

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 2.4.0, Ubuntu 18.04 LTS, MS Windows 10 (clients only).

artem.lavilin
Posts: 8
Joined: Thu Apr 16, 2020 12:10 pm

Re: JSON Request for task

Post by artem.lavilin » Thu Apr 16, 2020 12:37 pm

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: 8
Joined: Thu Apr 16, 2020 12:10 pm

Re: JSON Request for task

Post by artem.lavilin » Thu Apr 16, 2020 12:48 pm

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 376 times

User avatar
timurhai
Site Admin
Posts: 580
Joined: Sun Jan 15, 2017 8:40 pm
Location: Russia, Korolev
Contact:

Re: JSON Request for task

Post by timurhai » Thu Apr 16, 2020 12:51 pm

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 2.4.0, Ubuntu 18.04 LTS, MS Windows 10 (clients only).

artem.lavilin
Posts: 8
Joined: Thu Apr 16, 2020 12:10 pm

Re: JSON Request for task

Post by artem.lavilin » Thu Apr 16, 2020 1:09 pm

Thanks. I'll try look at the network log.

artem.lavilin
Posts: 8
Joined: Thu Apr 16, 2020 12:10 pm

Re: JSON Request for task

Post by artem.lavilin » Thu Apr 16, 2020 4:20 pm

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: 580
Joined: Sun Jan 15, 2017 8:40 pm
Location: Russia, Korolev
Contact:

Re: JSON Request for task

Post by timurhai » Thu Apr 16, 2020 4:24 pm

You can open it in GUI and see logs.
Timur Hairulin
CGRU 2.4.0, Ubuntu 18.04 LTS, MS Windows 10 (clients only).

artem.lavilin
Posts: 8
Joined: Thu Apr 16, 2020 12:10 pm

Re: JSON Request for task

Post by artem.lavilin » Thu Apr 16, 2020 4:26 pm

I need to see task through python.

User avatar
timurhai
Site Admin
Posts: 580
Joined: Sun Jan 15, 2017 8:40 pm
Location: Russia, Korolev
Contact:

Re: JSON Request for task

Post by timurhai » Thu Apr 16, 2020 4:34 pm

Server has only JSON API. Python module (API) just helps you to construct a valid JSON objects.
Timur Hairulin
CGRU 2.4.0, Ubuntu 18.04 LTS, MS Windows 10 (clients only).

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests