All Products
Search
Document Center

Batch Compute:easy_list

Last Updated:May 14, 2018

Parameter description

Attribute Type Description
resource_type str Resource type. Currently, only “jobs”, “clusters”, “tasks”, or “instances” can be listed
resource_info tuple Location parameter, containing all other information required to list resources. For example, job_id and task_name must be provided when instances are listed
filters dict Key-value pair. You can set multiple resource filtering conditions

Response description

The easy_list method returns a list object, which contains all resource instances that meet filtering conditions in resource_type.

Example

  1. try:
  2. client = Client(...
  3. ...
  4. # List all jobs which named "PythonSDK" and have a description of "test list job".
  5. for job in client.easy_list("jobs", Name="PythonSDK", Description="test list job"):
  6. print (job.Name, job.Id)
  7. # List all jobs which named "PythonSDK" and have a description of "test list job".
  8. # filters can be also unpacked from a dict.
  9. job_filters = {
  10. "Name": "PythonSDK",
  11. "Description": "test list job"
  12. }
  13. for job in client.easy_list("jobs", **job_filters):
  14. print (job.Name, job.Id)
  15. # List all jobs whose state is "Waiting" or "Running".
  16. # `filetrs` with a tuple value also available.
  17. for job in client.easy_list('jobs', State=['Waiting', 'Running']):
  18. print (job.Name, job.Id)
  19. # List all jobs whose state is "Waiting" or "Running".
  20. # `filters` with a function value defined by users.
  21. state_filter = lambda state: state in ['Waiting', 'Running']
  22. for job in client.easy_list('jobs', State=state_filter):
  23. print (job.Name, job.Id)
  24. # List all "Runing" tasks in a job.
  25. job_id = 'job-xxx'
  26. client.easy_list('tasks', job_id, State='Running')
  27. # List all "Running" instances in a task.
  28. job_id = 'job-xxx'
  29. task_name = 'Echo'
  30. client.easy_list('instances', job_id, task_name, State='Running')
  31. except ClientError, e:
  32. print(e)