server-client-python icon indicating copy to clipboard operation
server-client-python copied to clipboard

`server.jobs.wait_for_job` fails for ID generated by `create_extract`

Open eschranz opened this issue 2 years ago • 2 comments

Describe the bug The job ID generated when creating an extract via TSC is not queryable by the server.jobs.wait_for_job method.

Versions Details of your environment, including:

  • Tableau Server version 3.10
  • Python 3.8.12
  • tableauserverclient==0.19.0

To Reproduce

refresh_job = server.datasources.create_extract(datasource_item)
job_status = server.jobs.wait_for_job(refresh_job.id)

# Also
server.jobs.get_by_id(refresh_job.id)

Results

400031: Bad Request
    There was a problem querying job '{refresh_job.id}'.

Solution

from tableauserverclient.exponential_backoff import ExponentialBackoffTimer

refresh_job = server.datasources.create_extract(datasource_item)
backoff_timer = ExponentialBackoffTimer()

job = list(j for j in tsc.Pager(server.jobs) if j.id == refresh_job.id)[0]     
while job.ended_at is None:
    backoff_timer.sleep()
    print(f"{refresh_job.id} still running")
    job = list(j for j in tsc.Pager(server.jobs) if j.id == refresh_job.id)[0]

eschranz avatar Aug 19 '22 07:08 eschranz

Thanks for posting this - it looks like it needs a server-side fix, but I can add your workaround in the client for now.

jacalata avatar Aug 30 '22 07:08 jacalata

Hello, I am still facing the same issue as OP, can't query jobs related to create_extract.

Environment: TSC version: 0.24, Rest API version: 3.19 Tableau Server version: 2023.2.0 (20232.23.0616.0032)

nawidsayed avatar Jul 02 '23 16:07 nawidsayed