Python code to cancel executing TRTH jobs

ns3481
ns3481 Newcomer

I have some jobs pending for over a week and wanted to just cancel them. Looking for a python implementation. Thanks!

screen-shot-2023-03-02-at-70443-pm.png

I tried looking here:

https://community.developers.refinitiv.com/questions/34724/cancelling-executing-job-1.html
https://community.developers.refinitiv.com/questions/65945/cancel-queued-up-trth-jobs.html






Best Answer

  • Jirapongse
    Jirapongse ✭✭✭✭✭
    Answer ✓
    @ns3481

    Are they on-demand extractions or scheduled extractions?

    You may need to contact the Tick History support team directly via MyRefinitiv to verify these jobs.

Answers

  • Hi @ns3481 ,

    Could you try the below? or please let me know if you use other endpoints

    DELETE https://selectapi.datascope.refinitiv.com/RestApi/v1/Extractions/ExtractRawResult(ExtractionId='<job ID>')

    The Python code looks like this

    import requests
    import json

    url = "https://selectapi.datascope.refinitiv.com/RestApi/v1/Extractions/ExtractRawResult(ExtractionId='<job ID>') "

    payload = ""
    headers = {
    'Prefer': 'respond-async, wait=1',
    'Content-Type': 'application/json',
    'Authorization': 'Token <valid token>'
    }

    response = requests.request("DELETE", url, headers=headers, data=payload)

    print(response.text)
  • ns3481
    ns3481 Newcomer

    @raksina.samasiri For some reason, I can't comment on your response. Thanks for the quick turnaround. This does not work for me. here's the code, pretty much along the lines of what you suggested:


    import requests
    import json

    for job_id in ['0x085fd0a65058920c', '0x085fd1335fd8929f', '0x085fd1335f68929f', '0x085fd0a64658920c']:
    url = "https://selectapi.datascope.refinitiv.com/RestApi/v1/Extractions/ExtractRawResult(ExtractionId='{}') ".format(job_id)

    payload = ""
    headers = {
    'Prefer': 'respond-async, wait=1',
    'Content-Type': 'application/json',
    'Authorization': 'token ' + auth_token
    }

    response = requests.request("DELETE", url, headers = headers, data = payload)

    print(job_id, response.text, response.status_code)
    0x085fd0a65058920c {"error":{"message":"Job is not in progress and cannot be cancelled.  Details: report template: TickHistoryIntradaySummaries"}} 400
    0x085fd1335fd8929f {"error":{"message":"Job is not in progress and cannot be cancelled. Details: report template: TickHistoryIntradaySummaries"}} 400
    0x085fd1335f68929f {"error":{"message":"Job is not in progress and cannot be cancelled. Details: report template: TickHistoryIntradaySummaries"}} 400
    0x085fd0a64658920c {"error":{"message":"Job is not in progress and cannot be cancelled. Details: report template: TickHistoryIntradaySummaries"}} 400

    However, it says that the jobs aren't in progress which from the screenshot I posted is not true. I just want to get rid of these jobs as they eat into my processing capacity. Can you please help?

Welcome!

It looks like you're new here. Sign in or register to get started.

Welcome!

It looks like you're new here. Sign in or register to get started.