Delete job id from DB

delete

/py-scripts/v1/jobs/{jobId}

Delete job from table by job_id

Request

Path Parameters
Back to Top

Response

202 Response

Job is still pending.

302 Response

Returns the Content-Location header where the result of the job can be fetched.
Headers

401 Response

When the user doesn't have privileges to perform the action.

500 Response

Problem connecting to Broker, finding the job id or other unexpected error.
Back to Top

Examples

If your Python function is taking too long to run and you need to abort or delete it, you can use cURL to send a DELETE request to stop the running function call. Follow these steps to delete a running job :

  1. Define a function: The function, delayed_task(), takes a significant amount of time for completion.
    import oml 
    
    delayed_task = """def delayed_task():
        import time
        time.sleep(60*50)"""
     
    oml.script.create("delayed_task", delayed_task, is_global=True, overwrite=True)
  2. Run the script: The following cURL command runs the script named delayed_task with asynchronous values.
    curl -i -k -X POST --header "Authorization: Bearer ${token}" 
    --header 'Content-Type: application/json' --header 'Accept: application/json' -d '{"service":"LOW","asyncFlag":true, "timeout": 4800}'  
    "https://<server>/oml/api/py-scripts/v1/do-eval/delayed_task"
    HTTP/1.1 201 Created
    Date: Mon, 10 Feb 2025 22:02:07 GMT
    Content-Length: 0
    Connection: keep-alive
    Strict-Transport-Security: max-age=31536000; includeSubDomains
    X-Content-Type-Options: nosniff
    Cache-Control: no-cache, no-store, must-revalidate
    Pragma: no-cache
    X-Frame-Options: SAMEORIGIN
    X-XSS-Protection: 1;mode=block
    Content-Security-Policy: default-src 'none'; connect-src 'self'; font-src 'self' static.oracle.com; img-src 'self' data: static.oracle.com; media-src 'none'; object-src 'none'; script-src 'self' static.oracle.com 'unsafe-inline' 'unsafe-eval'; style-src 'self' static.oracle.com 'unsafe-inline'; frame-ancestors 'none'
    Set-Cookie: JSESSIONID=node0ek02l8eh8vwd18g92em0oj8bg1.node0; Path=/oml; Secure; HttpOnly
    Expires: Thu, 01 Jan 1970 00:00:00 GMT
    Location: https://<server>/oml/api/py-scripts/v1/jobs/0836ae69-f0ef-42d5-8773-f66b4b7fd4bb
  3. Check the job status: Check the jobs with ID to see if they are running.
    curl -i -k -X GET --header "Authorization: Bearer ${token}" 
    --header 'Content-Type: application/json' --header 'Accept: application/json' -d '{"service":"LOW"}'  
    "https://<server>/oml/api/py-scripts/v1/jobs/0836ae69-f0ef-42d5-8773-f66b4b7fd4bb"
    HTTP/1.1 202 Accepted
    Date: Mon, 10 Feb 2025 22:02:51 GMT
    Content-Type: application/json
    Content-Length: 93
    Connection: keep-alive
    Strict-Transport-Security: max-age=31536000; includeSubDomains
    X-Content-Type-Options: nosniff
    Cache-Control: no-cache, no-store, must-revalidate
    Pragma: no-cache
    X-Frame-Options: SAMEORIGIN
    X-XSS-Protection: 1;mode=block
    Content-Security-Policy: default-src 'none'; connect-src 'self'; font-src 'self' static.oracle.com; img-src 'self' data: static.oracle.com; media-src 'none'; object-src 'none'; script-src 'self' static.oracle.com 'unsafe-inline' 'unsafe-eval'; style-src 'self' static.oracle.com 'unsafe-inline'; frame-ancestors 'none'
     
    {"createdDate":" Feb 10,2025 22:02","status":"job is still running","elapsedTime":"00:00:44"}
    
  4. Delete the job: Delete the job with jobid, 0836ae69-f0ef-42d5-8773-f66b4b7fd4bb.
    curl -i -k -X DELETE  --header "Authorization: Bearer ${token}" --header 'Content-Type: application/json' 
    --header 'Accept: application/json' -d '{"service":"LOW"}'  
    "https://<server>/oml/api/py-scripts/v1/jobs/0836ae69-f0ef-42d5-8773-f66b4b7fd4bb"
    HTTP/1.1 200 OK
    Date: Mon, 10 Feb 2025 22:03:43 GMT
    Content-Type: application/json
    Content-Length: 112
    Connection: keep-alive
    Strict-Transport-Security: max-age=31536000; includeSubDomains
    X-Content-Type-Options: nosniff
    Cache-Control: no-cache, no-store, must-revalidate
    Pragma: no-cache
    X-Frame-Options: SAMEORIGIN
    X-XSS-Protection: 1;mode=block
    Content-Security-Policy: default-src 'none'; connect-src 'self'; font-src 'self' static.oracle.com; img-src 'self' data: static.oracle.com; media-src 'none'; object-src 'none'; script-src 'self' static.oracle.com 'unsafe-inline' 'unsafe-eval'; style-src 'self' static.oracle.com 'unsafe-inline'; frame-ancestors 'none'
     
    {"Message":"Job 0836ae69-f0ef-42d5-8773-f66b4b7fd4bb sucessfully deleted container ending :  LOW-1739224926687"}
  5. Delete the job a second time: If you attempt to delete a job ID for the second time it will result in Failure as job is no longer accessible.
    curl -i -k -X DELETE  --header "Authorization: Bearer ${token}" 
    --header 'Content-Type: application/json' --header 'Accept: application/json' -d '{"service":"LOW"}'  
    "https://<server>/oml/api/py-scripts/v1/jobs/0836ae69-f0ef-42d5-8773-f66b4b7fd4bb"
    HTTP/1.1 200 OK
    Date: Mon, 10 Feb 2025 22:03:49 GMT
    Content-Type: application/json
    Content-Length: 102
    Connection: keep-alive
    Strict-Transport-Security: max-age=31536000; includeSubDomains
    X-Content-Type-Options: nosniff
    Cache-Control: no-cache, no-store, must-revalidate
    Pragma: no-cache
    X-Frame-Options: SAMEORIGIN
    X-XSS-Protection: 1;mode=block
    Content-Security-Policy: default-src 'none'; connect-src 'self'; font-src 'self' static.oracle.com; img-src 'self' data: static.oracle.com; media-src 'none'; object-src 'none'; script-src 'self' static.oracle.com 'unsafe-inline' 'unsafe-eval'; style-src 'self' static.oracle.com 'unsafe-inline'; frame-ancestors 'none'
     
    {"Message":"Job 0836ae69-f0ef-42d5-8773-f66b4b7fd4bb status is FAILURE and not applicable to delete" }
Back to Top