Skip to content

fix: send BigQuery cancel request when canceling bigframes process #103

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

Merged
merged 3 commits into from
Oct 12, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions bigframes/formatting_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,11 @@ def wait_for_query_job(
except api_core_exceptions.GoogleAPICallError as exc:
add_feedback_link(exc)
raise
except KeyboardInterrupt:
query_job.cancel()
print(f"Requested cancelation for {query_job.job_type} {query_job.job_id}...")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kinda nitpick - English vocab is not my forte but I wondered about "cancelation" vs "cancellation" and looks like in googleapis repos the former is a rarity, the latter is commonly used.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kinda nitpick - English vocab is not my forte but I wondered about "cancelation" vs "cancellation" and looks like in googleapis repos the former is a rarity, the latter is commonly used.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Shobhit, created #111 to address these.

# begin the cancel request before immediately rethrowing
raise


def wait_for_job(job: GenericJob, progress_bar: Optional[str] = None):
Expand Down Expand Up @@ -190,6 +195,11 @@ def wait_for_job(job: GenericJob, progress_bar: Optional[str] = None):
except api_core_exceptions.GoogleAPICallError as exc:
add_feedback_link(exc)
raise
except KeyboardInterrupt:
job.cancel()
print(f"Requested cancelation for {job.job_type} {job.job_id}...")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We may like to follow the following pattern done elsewhere for consistency:

  1. job_type.capitalize() like in get_base_job_loading_*
  2. "<job_type> job <job_id>" instead of "<job_type> <job_id>", like in get_*_job_loading_*

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Shobhit, created #111 to address these.

# begin the cancel request before immediately rethrowing
raise


def get_job_url(query_job: GenericJob):
Expand Down