-
Notifications
You must be signed in to change notification settings - Fork 125
Implement initial "waiting" logs with tqdm? #327
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
We don't know ahead of time how long a query will take, so the current tqdm logic won't work. Looks like there are a couple of open issues for indefinite progress bars at: tqdm/tqdm#427 tqdm/tqdm#925 A couple of options:
|
Good point @tswast I just looked back on some code I wrote a few years ago and found this — coincidentally for waiting for jobs from Google Cloud! — though now I see the links above, maybe I should be more cautious about suggesting it's easy to have an indefinite progress bar... def wait_for_job(job, timeout_in_seconds=None):
# https://github.com/GoogleCloudPlatform/python-docs-samples/blob/master/bigquery/cloud-client/snippets.py
if timeout_in_seconds:
start = datetime.datetime.now()
timeout = start + datetime.timedelta(0, timeout_in_seconds)
with tqdm(
bar_format="Waiting for {desc} Elapsed: {elapsed}", total=10000
) as progress:
while True:
job.reload() # Refreshes the state via a GET request.
progress.set_description(str(job))
if job.state == "DONE":
if job.error_result:
raise RuntimeError(job.errors)
progress.bar_format = "Completed {desc}. Elapsed: {elapsed}"
return
if timeout_in_seconds:
if datetime.datetime.now() > timeout:
raise SystemError(f"Timed out after {timeout_in_seconds} seconds")
time.sleep(1) |
I had some more thoughts about this. The UI uses the job statistics to show progression through the various stages. Filed googleapis/python-bigquery#343 to see if we can implement this in |
I just merged googleapis/python-bigquery#352 which will be available in |
Currently the initial logs are every ~second. Could we instead implement this as a tqdm "progress bar", albeit without progress? That would be more elegant.
We could also have a hiearachical progress bar, with each of the two steps being a descendent of the parent. This would screen off the final log messages; since the total time would be left by tqdm.
The text was updated successfully, but these errors were encountered: