The documentation to list jobs using the AzureML REST API is here: https://learn.microsoft.com/en-us/rest/api/azureml/jobs/list?view=rest-azureml-2024-04-01&tabs=HTTP
However this query can return hundreds of completed jobs. I'm interested to filter the list server-side to only queued or running jobs. I have not been able to specify the right combination of properties directives to get these jobs- what is the secret sauce?
Notably AzureML Studio uses a different API at https://ml.azure.com/api/.../entities to fetch this list but this API isn't supported by the Az REST CLI.
There is no option to filter the jobs server side.
So, only possible way is to get the list and do filter like below.
import requests
from azure.identity import DefaultAzureCredential, InteractiveBrowserCredential
endpoint = "https://management.azure.com/subscriptions/0b36xxxxb0/resourceGroups/<resource_grp>/providers/Microsoft.MachineLearningServices/workspaces/<workspace_name>/jobs?api-version=2024-04-01"
credential = DefaultAzureCredential()
token = credential.get_token("https://management.core.windows.net/.default").token
headers = {
"Authorization": f"Bearer {token}"
}
response = requests.get(endpoint, headers=headers)
for i in response.json()['value']:
if i['properties']['status']=="Running" or i['properties']['status']=="Queued":
print(f"{i['name']}, {i['properties']['displayName']}, {i['properties']['status']}")
Output:
Since you have more jobs, the response contains the nextLink, which is a link to the next page of JobBase objects where you need to filter the jobs again.
If you want to check the jobs under single parent run you can use azure ml python sdk v2 where you can provide parent run name for listing the job.
client = MLClient.from_config(credential)
client.jobs.list(parent_job_name="")
This gives only the child jobs under given parent job, which reduces the total jobs you are listing