Skip to content
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

feat: add dispatch_deadline parameter to tasks_v2.Task #60

Merged
merged 2 commits into from
Jan 29, 2025
Merged
Show file tree
Hide file tree
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
7 changes: 7 additions & 0 deletions gcp_pilot/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ def push(
use_oidc_auth: bool = True,
content_type: str | None = None,
headers: dict[str, str] | None = None,
task_timeout: timedelta | None = None,
) -> tasks_v2.Task:
queue_path = self.client.queue_path(
project=project_id or self.project_id,
Expand Down Expand Up @@ -81,6 +82,9 @@ def push(
),
)

if task_timeout is not None:
task.dispatch_deadline = self.timedelta_to_duration(task_timeout)

if delay_in_seconds:
target_date = datetime.now(tz=UTC) + timedelta(seconds=delay_in_seconds)
timestamp = timestamp_pb2.Timestamp()
Expand Down Expand Up @@ -116,6 +120,9 @@ def create_queue(
queue=queue,
)

def timedelta_to_duration(delta: timedelta) -> str:
return f"{int(delta.total_seconds())}s"

def get_queue(
self,
queue_name: str,
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "gcp-pilot"
version = "1.31.0"
version = "1.32.0"
description = "Google Cloud Platform Friendly Pilot"
authors = [
{name = "Joao Daher", email = "[email protected]"},
Expand Down