From fc9445964181d134b58f17a405fcbfc17ed62f09 Mon Sep 17 00:00:00 2001 From: Ivan Barba Date: Thu, 14 May 2026 22:02:56 +0000 Subject: [PATCH 1/2] Add TasksCountRequest and TasksCount to swarming.proto --- .../_internal/protos/swarming.proto | 78 +++++++- .../_internal/protos/swarming_pb2.py | 65 ++++--- .../_internal/protos/swarming_pb2.pyi | 177 +++++++++++++++++- .../_internal/protos/swarming_pb2_grpc.py | 2 +- 4 files changed, 287 insertions(+), 35 deletions(-) diff --git a/src/clusterfuzz/_internal/protos/swarming.proto b/src/clusterfuzz/_internal/protos/swarming.proto index c5822c9b4fd..8743524e960 100644 --- a/src/clusterfuzz/_internal/protos/swarming.proto +++ b/src/clusterfuzz/_internal/protos/swarming.proto @@ -1,4 +1,4 @@ -// Copyright 2024 Google LLC +// Copyright 2026 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -12,12 +12,71 @@ // See the License for the specific language governing permissions and // limitations under the License. -// This file is based on https://source.chromium.org/chromium/infra/infra/+/main:luci/appengine/swarming/proto/api_v2/swarming.proto +// This file is based on https://source.chromium.org/chromium/infra/infra_superproject/+/main:infra/luci/appengine/swarming/proto/api_v2/swarming.proto // This includes necessary messages to construct a NewTaskRequest syntax = "proto3"; package swarming.v2; +import "google/protobuf/timestamp.proto"; + +// Enums + +// Use one of the values in this enum to query for tasks in one of the +// specified state. +// +// Use 'ALL' to not use any filtering based on task state. +// +// As an example, this enum enables querying for all tasks with state COMPLETED +// but non-zero exit code via COMPLETED_FAILURE. +// +// Do not confuse StateQuery and TaskState. StateQuery is to query tasks +// via the API. TaskState is the current task state. +enum StateQuery { + // Query for all tasks currently TaskState.PENDING. + QUERY_PENDING = 0; + // Query for all tasks currently TaskState.RUNNING. This includes tasks + // currently in the overhead phase; mapping input files or archiving outputs + // back to the server. + QUERY_RUNNING = 1; + // Query for all tasks currently TaskState.PENDING or TaskState.RUNNING. This + // is the query for the 'active' tasks. + QUERY_PENDING_RUNNING = 2; + // Query for all tasks that completed normally as TaskState.COMPLETED, + // independent of the process exit code. + QUERY_COMPLETED = 3; + // Query for all tasks that completed normally as TaskState.COMPLETED and that + // had exit code 0. + QUERY_COMPLETED_SUCCESS = 4; + // Query for all tasks that completed normally as TaskState.COMPLETED and that + // had exit code not 0. + QUERY_COMPLETED_FAILURE = 5; + // Query for all tasks that are TaskState.EXPIRED. + QUERY_EXPIRED = 6; + // Query for all tasks that are TaskState.TIMED_OUT. + QUERY_TIMED_OUT = 7; + // Query for all tasks that are TaskState.BOT_DIED. + QUERY_BOT_DIED = 8; + // Query for all tasks that are TaskState.CANCELED. + QUERY_CANCELED = 9; + // Query for all tasks, independent of the task state. + // + // In hindsight, this constant should have been the value 0. Sorry, the + // original author was young and foolish. + QUERY_ALL = 10; + // Query for all tasks that are TaskState.COMPLETED but that actually didn't + // run due to TaskProperties.idempotent being True *and* that a previous task + // with the exact same TaskProperties had successfully run before, aka + // COMPLETED_SUCCESS. + QUERY_DEDUPED = 11; + // Query for all tasks that are TaskState.KILLED. + QUERY_KILLED = 12; + // Query for all tasks that are TaskState.NO_RESOURCE. + QUERY_NO_RESOURCE = 13; + // Query for all tasks that are TaskState.CLIENT_ERROR. + QUERY_CLIENT_ERROR = 14; +} + // Messages // Represents a mapping of string to a string. @@ -345,4 +404,17 @@ message NewTaskRequest { // Task realm. // See api/swarming.proto for more details. string realm = 18; -} \ No newline at end of file +} + +message TasksCountRequest { + google.protobuf.Timestamp start = 1; + google.protobuf.Timestamp end = 2; + StateQuery state = 3; + repeated string tags = 4; +} + +// Returns the count, as requested. +message TasksCount { + int32 count = 1; + google.protobuf.Timestamp now = 2; +} diff --git a/src/clusterfuzz/_internal/protos/swarming_pb2.py b/src/clusterfuzz/_internal/protos/swarming_pb2.py index 543c11cce9f..d67b1f95af5 100644 --- a/src/clusterfuzz/_internal/protos/swarming_pb2.py +++ b/src/clusterfuzz/_internal/protos/swarming_pb2.py @@ -26,41 +26,48 @@ _sym_db = _symbol_database.Default() +from google.protobuf import timestamp_pb2 as google_dot_protobuf_dot_timestamp__pb2 -DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n+clusterfuzz/_internal/protos/swarming.proto\x12\x0bswarming.v2\"(\n\nStringPair\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\t\",\n\x0eStringListPair\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x03(\t\"*\n\x06\x44igest\x12\x0c\n\x04hash\x18\x01 \x01(\t\x12\x12\n\nsize_bytes\x18\x02 \x01(\x03\"I\n\x0c\x43\x41SReference\x12\x14\n\x0c\x63\x61s_instance\x18\x01 \x01(\t\x12#\n\x06\x64igest\x18\x02 \x01(\x0b\x32\x13.swarming.v2.Digest\"B\n\x0b\x43ipdPackage\x12\x14\n\x0cpackage_name\x18\x01 \x01(\t\x12\x0f\n\x07version\x18\x02 \x01(\t\x12\x0c\n\x04path\x18\x03 \x01(\t\"y\n\tCipdInput\x12\x0e\n\x06server\x18\x01 \x01(\t\x12\x30\n\x0e\x63lient_package\x18\x02 \x01(\x0b\x32\x18.swarming.v2.CipdPackage\x12*\n\x08packages\x18\x03 \x03(\x0b\x32\x18.swarming.v2.CipdPackage\"(\n\nCacheEntry\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x0c\n\x04path\x18\x02 \x01(\t\"\xf2\x01\n\x0b\x43ontainment\x12\x16\n\x0elower_priority\x18\x01 \x01(\x08\x12\x42\n\x10\x63ontainment_type\x18\x02 \x01(\x0e\x32(.swarming.v2.Containment.ContainmentType\x12\x17\n\x0flimit_processes\x18\x03 \x01(\x03\x12$\n\x1climit_total_committed_memory\x18\x04 \x01(\x03\"H\n\x0f\x43ontainmentType\x12\x11\n\rNOT_SPECIFIED\x10\x00\x12\x08\n\x04NONE\x10\x01\x12\x08\n\x04\x41UTO\x10\x02\x12\x0e\n\nJOB_OBJECT\x10\x03\"\x83\x04\n\x0eTaskProperties\x12\'\n\x06\x63\x61\x63hes\x18\x01 \x03(\x0b\x32\x17.swarming.v2.CacheEntry\x12*\n\ncipd_input\x18\x02 \x01(\x0b\x32\x16.swarming.v2.CipdInput\x12\x0f\n\x07\x63ommand\x18\x03 \x03(\t\x12\x14\n\x0crelative_cwd\x18\x04 \x01(\t\x12+\n\ndimensions\x18\x05 \x03(\x0b\x32\x17.swarming.v2.StringPair\x12$\n\x03\x65nv\x18\x06 \x03(\x0b\x32\x17.swarming.v2.StringPair\x12\x31\n\x0c\x65nv_prefixes\x18\x07 \x03(\x0b\x32\x1b.swarming.v2.StringListPair\x12\x1e\n\x16\x65xecution_timeout_secs\x18\x08 \x01(\x05\x12\x19\n\x11grace_period_secs\x18\t \x01(\x05\x12\x12\n\nidempotent\x18\n \x01(\x08\x12\x31\n\x0e\x63\x61s_input_root\x18\x0b \x01(\x0b\x32\x19.swarming.v2.CASReference\x12\x17\n\x0fio_timeout_secs\x18\x0c \x01(\x05\x12\x0f\n\x07outputs\x18\r \x03(\t\x12\x14\n\x0csecret_bytes\x18\x0e \x01(\x0c\x12-\n\x0b\x63ontainment\x18\x0f \x01(\x0b\x32\x18.swarming.v2.Containment\"p\n\tTaskSlice\x12/\n\nproperties\x18\x01 \x01(\x0b\x32\x1b.swarming.v2.TaskProperties\x12\x17\n\x0f\x65xpiration_secs\x18\x02 \x01(\x05\x12\x19\n\x11wait_for_capacity\x18\x03 \x01(\x08\"\x1d\n\x0bResultDBCfg\x12\x0e\n\x06\x65nable\x18\x01 \x01(\x08\"\xe8\x04\n\x0eNewTaskRequest\x12\x17\n\x0f\x65xpiration_secs\x18\x01 \x01(\x05\x12\x0c\n\x04name\x18\x02 \x01(\t\x12\x16\n\x0eparent_task_id\x18\x03 \x01(\t\x12\x10\n\x08priority\x18\x04 \x01(\x05\x12/\n\nproperties\x18\x05 \x01(\x0b\x32\x1b.swarming.v2.TaskProperties\x12+\n\x0btask_slices\x18\x06 \x03(\x0b\x32\x16.swarming.v2.TaskSlice\x12\x0c\n\x04tags\x18\x07 \x03(\t\x12\x0c\n\x04user\x18\x08 \x01(\t\x12\x17\n\x0fservice_account\x18\t \x01(\t\x12\x14\n\x0cpubsub_topic\x18\n \x01(\t\x12\x19\n\x11pubsub_auth_token\x18\x0b \x01(\t\x12\x17\n\x0fpubsub_userdata\x18\x0c \x01(\t\x12\x15\n\revaluate_only\x18\r \x01(\x08\x12M\n\x12pool_task_template\x18\x0e \x01(\x0e\x32\x31.swarming.v2.NewTaskRequest.PoolTaskTemplateField\x12\x1f\n\x17\x62ot_ping_tolerance_secs\x18\x0f \x01(\x05\x12\x14\n\x0crequest_uuid\x18\x10 \x01(\t\x12*\n\x08resultdb\x18\x11 \x01(\x0b\x32\x18.swarming.v2.ResultDBCfg\x12\r\n\x05realm\x18\x12 \x01(\t\"P\n\x15PoolTaskTemplateField\x12\x08\n\x04\x41UTO\x10\x00\x12\x11\n\rCANARY_PREFER\x10\x01\x12\x10\n\x0c\x43\x41NARY_NEVER\x10\x02\x12\x08\n\x04SKIP\x10\x03\x62\x06proto3') +DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n+clusterfuzz/_internal/protos/swarming.proto\x12\x0bswarming.v2\x1a\x1fgoogle/protobuf/timestamp.proto\"(\n\nStringPair\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\t\",\n\x0eStringListPair\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x03(\t\"*\n\x06\x44igest\x12\x0c\n\x04hash\x18\x01 \x01(\t\x12\x12\n\nsize_bytes\x18\x02 \x01(\x03\"I\n\x0c\x43\x41SReference\x12\x14\n\x0c\x63\x61s_instance\x18\x01 \x01(\t\x12#\n\x06\x64igest\x18\x02 \x01(\x0b\x32\x13.swarming.v2.Digest\"B\n\x0b\x43ipdPackage\x12\x14\n\x0cpackage_name\x18\x01 \x01(\t\x12\x0f\n\x07version\x18\x02 \x01(\t\x12\x0c\n\x04path\x18\x03 \x01(\t\"y\n\tCipdInput\x12\x0e\n\x06server\x18\x01 \x01(\t\x12\x30\n\x0e\x63lient_package\x18\x02 \x01(\x0b\x32\x18.swarming.v2.CipdPackage\x12*\n\x08packages\x18\x03 \x03(\x0b\x32\x18.swarming.v2.CipdPackage\"(\n\nCacheEntry\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x0c\n\x04path\x18\x02 \x01(\t\"\xf2\x01\n\x0b\x43ontainment\x12\x16\n\x0elower_priority\x18\x01 \x01(\x08\x12\x42\n\x10\x63ontainment_type\x18\x02 \x01(\x0e\x32(.swarming.v2.Containment.ContainmentType\x12\x17\n\x0flimit_processes\x18\x03 \x01(\x03\x12$\n\x1climit_total_committed_memory\x18\x04 \x01(\x03\"H\n\x0f\x43ontainmentType\x12\x11\n\rNOT_SPECIFIED\x10\x00\x12\x08\n\x04NONE\x10\x01\x12\x08\n\x04\x41UTO\x10\x02\x12\x0e\n\nJOB_OBJECT\x10\x03\"\x83\x04\n\x0eTaskProperties\x12\'\n\x06\x63\x61\x63hes\x18\x01 \x03(\x0b\x32\x17.swarming.v2.CacheEntry\x12*\n\ncipd_input\x18\x02 \x01(\x0b\x32\x16.swarming.v2.CipdInput\x12\x0f\n\x07\x63ommand\x18\x03 \x03(\t\x12\x14\n\x0crelative_cwd\x18\x04 \x01(\t\x12+\n\ndimensions\x18\x05 \x03(\x0b\x32\x17.swarming.v2.StringPair\x12$\n\x03\x65nv\x18\x06 \x03(\x0b\x32\x17.swarming.v2.StringPair\x12\x31\n\x0c\x65nv_prefixes\x18\x07 \x03(\x0b\x32\x1b.swarming.v2.StringListPair\x12\x1e\n\x16\x65xecution_timeout_secs\x18\x08 \x01(\x05\x12\x19\n\x11grace_period_secs\x18\t \x01(\x05\x12\x12\n\nidempotent\x18\n \x01(\x08\x12\x31\n\x0e\x63\x61s_input_root\x18\x0b \x01(\x0b\x32\x19.swarming.v2.CASReference\x12\x17\n\x0fio_timeout_secs\x18\x0c \x01(\x05\x12\x0f\n\x07outputs\x18\r \x03(\t\x12\x14\n\x0csecret_bytes\x18\x0e \x01(\x0c\x12-\n\x0b\x63ontainment\x18\x0f \x01(\x0b\x32\x18.swarming.v2.Containment\"p\n\tTaskSlice\x12/\n\nproperties\x18\x01 \x01(\x0b\x32\x1b.swarming.v2.TaskProperties\x12\x17\n\x0f\x65xpiration_secs\x18\x02 \x01(\x05\x12\x19\n\x11wait_for_capacity\x18\x03 \x01(\x08\"\x1d\n\x0bResultDBCfg\x12\x0e\n\x06\x65nable\x18\x01 \x01(\x08\"\xe8\x04\n\x0eNewTaskRequest\x12\x17\n\x0f\x65xpiration_secs\x18\x01 \x01(\x05\x12\x0c\n\x04name\x18\x02 \x01(\t\x12\x16\n\x0eparent_task_id\x18\x03 \x01(\t\x12\x10\n\x08priority\x18\x04 \x01(\x05\x12/\n\nproperties\x18\x05 \x01(\x0b\x32\x1b.swarming.v2.TaskProperties\x12+\n\x0btask_slices\x18\x06 \x03(\x0b\x32\x16.swarming.v2.TaskSlice\x12\x0c\n\x04tags\x18\x07 \x03(\t\x12\x0c\n\x04user\x18\x08 \x01(\t\x12\x17\n\x0fservice_account\x18\t \x01(\t\x12\x14\n\x0cpubsub_topic\x18\n \x01(\t\x12\x19\n\x11pubsub_auth_token\x18\x0b \x01(\t\x12\x17\n\x0fpubsub_userdata\x18\x0c \x01(\t\x12\x15\n\revaluate_only\x18\r \x01(\x08\x12M\n\x12pool_task_template\x18\x0e \x01(\x0e\x32\x31.swarming.v2.NewTaskRequest.PoolTaskTemplateField\x12\x1f\n\x17\x62ot_ping_tolerance_secs\x18\x0f \x01(\x05\x12\x14\n\x0crequest_uuid\x18\x10 \x01(\t\x12*\n\x08resultdb\x18\x11 \x01(\x0b\x32\x18.swarming.v2.ResultDBCfg\x12\r\n\x05realm\x18\x12 \x01(\t\"P\n\x15PoolTaskTemplateField\x12\x08\n\x04\x41UTO\x10\x00\x12\x11\n\rCANARY_PREFER\x10\x01\x12\x10\n\x0c\x43\x41NARY_NEVER\x10\x02\x12\x08\n\x04SKIP\x10\x03\"\x9d\x01\n\x11TasksCountRequest\x12)\n\x05start\x18\x01 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12\'\n\x03\x65nd\x18\x02 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12&\n\x05state\x18\x03 \x01(\x0e\x32\x17.swarming.v2.StateQuery\x12\x0c\n\x04tags\x18\x04 \x03(\t\"D\n\nTasksCount\x12\r\n\x05\x63ount\x18\x01 \x01(\x05\x12\'\n\x03now\x18\x02 \x01(\x0b\x32\x1a.google.protobuf.Timestamp*\xcf\x02\n\nStateQuery\x12\x11\n\rQUERY_PENDING\x10\x00\x12\x11\n\rQUERY_RUNNING\x10\x01\x12\x19\n\x15QUERY_PENDING_RUNNING\x10\x02\x12\x13\n\x0fQUERY_COMPLETED\x10\x03\x12\x1b\n\x17QUERY_COMPLETED_SUCCESS\x10\x04\x12\x1b\n\x17QUERY_COMPLETED_FAILURE\x10\x05\x12\x11\n\rQUERY_EXPIRED\x10\x06\x12\x13\n\x0fQUERY_TIMED_OUT\x10\x07\x12\x12\n\x0eQUERY_BOT_DIED\x10\x08\x12\x12\n\x0eQUERY_CANCELED\x10\t\x12\r\n\tQUERY_ALL\x10\n\x12\x11\n\rQUERY_DEDUPED\x10\x0b\x12\x10\n\x0cQUERY_KILLED\x10\x0c\x12\x15\n\x11QUERY_NO_RESOURCE\x10\r\x12\x16\n\x12QUERY_CLIENT_ERROR\x10\x0e\x62\x06proto3') _globals = globals() _builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals) _builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'clusterfuzz._internal.protos.swarming_pb2', _globals) if _descriptor._USE_C_DESCRIPTORS == False: DESCRIPTOR._options = None - _globals['_STRINGPAIR']._serialized_start=60 - _globals['_STRINGPAIR']._serialized_end=100 - _globals['_STRINGLISTPAIR']._serialized_start=102 - _globals['_STRINGLISTPAIR']._serialized_end=146 - _globals['_DIGEST']._serialized_start=148 - _globals['_DIGEST']._serialized_end=190 - _globals['_CASREFERENCE']._serialized_start=192 - _globals['_CASREFERENCE']._serialized_end=265 - _globals['_CIPDPACKAGE']._serialized_start=267 - _globals['_CIPDPACKAGE']._serialized_end=333 - _globals['_CIPDINPUT']._serialized_start=335 - _globals['_CIPDINPUT']._serialized_end=456 - _globals['_CACHEENTRY']._serialized_start=458 - _globals['_CACHEENTRY']._serialized_end=498 - _globals['_CONTAINMENT']._serialized_start=501 - _globals['_CONTAINMENT']._serialized_end=743 - _globals['_CONTAINMENT_CONTAINMENTTYPE']._serialized_start=671 - _globals['_CONTAINMENT_CONTAINMENTTYPE']._serialized_end=743 - _globals['_TASKPROPERTIES']._serialized_start=746 - _globals['_TASKPROPERTIES']._serialized_end=1261 - _globals['_TASKSLICE']._serialized_start=1263 - _globals['_TASKSLICE']._serialized_end=1375 - _globals['_RESULTDBCFG']._serialized_start=1377 - _globals['_RESULTDBCFG']._serialized_end=1406 - _globals['_NEWTASKREQUEST']._serialized_start=1409 - _globals['_NEWTASKREQUEST']._serialized_end=2025 - _globals['_NEWTASKREQUEST_POOLTASKTEMPLATEFIELD']._serialized_start=1945 - _globals['_NEWTASKREQUEST_POOLTASKTEMPLATEFIELD']._serialized_end=2025 + _globals['_STATEQUERY']._serialized_start=2291 + _globals['_STATEQUERY']._serialized_end=2626 + _globals['_STRINGPAIR']._serialized_start=93 + _globals['_STRINGPAIR']._serialized_end=133 + _globals['_STRINGLISTPAIR']._serialized_start=135 + _globals['_STRINGLISTPAIR']._serialized_end=179 + _globals['_DIGEST']._serialized_start=181 + _globals['_DIGEST']._serialized_end=223 + _globals['_CASREFERENCE']._serialized_start=225 + _globals['_CASREFERENCE']._serialized_end=298 + _globals['_CIPDPACKAGE']._serialized_start=300 + _globals['_CIPDPACKAGE']._serialized_end=366 + _globals['_CIPDINPUT']._serialized_start=368 + _globals['_CIPDINPUT']._serialized_end=489 + _globals['_CACHEENTRY']._serialized_start=491 + _globals['_CACHEENTRY']._serialized_end=531 + _globals['_CONTAINMENT']._serialized_start=534 + _globals['_CONTAINMENT']._serialized_end=776 + _globals['_CONTAINMENT_CONTAINMENTTYPE']._serialized_start=704 + _globals['_CONTAINMENT_CONTAINMENTTYPE']._serialized_end=776 + _globals['_TASKPROPERTIES']._serialized_start=779 + _globals['_TASKPROPERTIES']._serialized_end=1294 + _globals['_TASKSLICE']._serialized_start=1296 + _globals['_TASKSLICE']._serialized_end=1408 + _globals['_RESULTDBCFG']._serialized_start=1410 + _globals['_RESULTDBCFG']._serialized_end=1439 + _globals['_NEWTASKREQUEST']._serialized_start=1442 + _globals['_NEWTASKREQUEST']._serialized_end=2058 + _globals['_NEWTASKREQUEST_POOLTASKTEMPLATEFIELD']._serialized_start=1978 + _globals['_NEWTASKREQUEST_POOLTASKTEMPLATEFIELD']._serialized_end=2058 + _globals['_TASKSCOUNTREQUEST']._serialized_start=2061 + _globals['_TASKSCOUNTREQUEST']._serialized_end=2218 + _globals['_TASKSCOUNT']._serialized_start=2220 + _globals['_TASKSCOUNT']._serialized_end=2288 # @@protoc_insertion_point(module_scope) diff --git a/src/clusterfuzz/_internal/protos/swarming_pb2.pyi b/src/clusterfuzz/_internal/protos/swarming_pb2.pyi index fbdb1cd7d63..d610aa2682f 100644 --- a/src/clusterfuzz/_internal/protos/swarming_pb2.pyi +++ b/src/clusterfuzz/_internal/protos/swarming_pb2.pyi @@ -1,7 +1,7 @@ """ @generated by mypy-protobuf. Do not edit manually! isort:skip_file -Copyright 2024 Google LLC +Copyright 2026 Google LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -15,7 +15,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. -This file is based on https://source.chromium.org/chromium/infra/infra/+/main:luci/appengine/swarming/proto/api_v2/swarming.proto +This file is based on https://source.chromium.org/chromium/infra/infra_superproject/+/main:infra/luci/appengine/swarming/proto/api_v2/swarming.proto This includes necessary messages to construct a NewTaskRequest """ import builtins @@ -24,6 +24,7 @@ import google.protobuf.descriptor import google.protobuf.internal.containers import google.protobuf.internal.enum_type_wrapper import google.protobuf.message +import google.protobuf.timestamp_pb2 import sys import typing @@ -34,6 +35,128 @@ else: DESCRIPTOR: google.protobuf.descriptor.FileDescriptor +class _StateQuery: + ValueType = typing.NewType("ValueType", builtins.int) + V: typing_extensions.TypeAlias = ValueType + +class _StateQueryEnumTypeWrapper(google.protobuf.internal.enum_type_wrapper._EnumTypeWrapper[_StateQuery.ValueType], builtins.type): + DESCRIPTOR: google.protobuf.descriptor.EnumDescriptor + QUERY_PENDING: _StateQuery.ValueType # 0 + """Query for all tasks currently TaskState.PENDING.""" + QUERY_RUNNING: _StateQuery.ValueType # 1 + """Query for all tasks currently TaskState.RUNNING. This includes tasks + currently in the overhead phase; mapping input files or archiving outputs + back to the server. + """ + QUERY_PENDING_RUNNING: _StateQuery.ValueType # 2 + """Query for all tasks currently TaskState.PENDING or TaskState.RUNNING. This + is the query for the 'active' tasks. + """ + QUERY_COMPLETED: _StateQuery.ValueType # 3 + """Query for all tasks that completed normally as TaskState.COMPLETED, + independent of the process exit code. + """ + QUERY_COMPLETED_SUCCESS: _StateQuery.ValueType # 4 + """Query for all tasks that completed normally as TaskState.COMPLETED and that + had exit code 0. + """ + QUERY_COMPLETED_FAILURE: _StateQuery.ValueType # 5 + """Query for all tasks that completed normally as TaskState.COMPLETED and that + had exit code not 0. + """ + QUERY_EXPIRED: _StateQuery.ValueType # 6 + """Query for all tasks that are TaskState.EXPIRED.""" + QUERY_TIMED_OUT: _StateQuery.ValueType # 7 + """Query for all tasks that are TaskState.TIMED_OUT.""" + QUERY_BOT_DIED: _StateQuery.ValueType # 8 + """Query for all tasks that are TaskState.BOT_DIED.""" + QUERY_CANCELED: _StateQuery.ValueType # 9 + """Query for all tasks that are TaskState.CANCELED.""" + QUERY_ALL: _StateQuery.ValueType # 10 + """Query for all tasks, independent of the task state. + + In hindsight, this constant should have been the value 0. Sorry, the + original author was young and foolish. + """ + QUERY_DEDUPED: _StateQuery.ValueType # 11 + """Query for all tasks that are TaskState.COMPLETED but that actually didn't + run due to TaskProperties.idempotent being True *and* that a previous task + with the exact same TaskProperties had successfully run before, aka + COMPLETED_SUCCESS. + """ + QUERY_KILLED: _StateQuery.ValueType # 12 + """Query for all tasks that are TaskState.KILLED.""" + QUERY_NO_RESOURCE: _StateQuery.ValueType # 13 + """Query for all tasks that are TaskState.NO_RESOURCE.""" + QUERY_CLIENT_ERROR: _StateQuery.ValueType # 14 + """Query for all tasks that are TaskState.CLIENT_ERROR.""" + +class StateQuery(_StateQuery, metaclass=_StateQueryEnumTypeWrapper): + """Enums + + Use one of the values in this enum to query for tasks in one of the + specified state. + + Use 'ALL' to not use any filtering based on task state. + + As an example, this enum enables querying for all tasks with state COMPLETED + but non-zero exit code via COMPLETED_FAILURE. + + Do not confuse StateQuery and TaskState. StateQuery is to query tasks + via the API. TaskState is the current task state. + """ + +QUERY_PENDING: StateQuery.ValueType # 0 +"""Query for all tasks currently TaskState.PENDING.""" +QUERY_RUNNING: StateQuery.ValueType # 1 +"""Query for all tasks currently TaskState.RUNNING. This includes tasks +currently in the overhead phase; mapping input files or archiving outputs +back to the server. +""" +QUERY_PENDING_RUNNING: StateQuery.ValueType # 2 +"""Query for all tasks currently TaskState.PENDING or TaskState.RUNNING. This +is the query for the 'active' tasks. +""" +QUERY_COMPLETED: StateQuery.ValueType # 3 +"""Query for all tasks that completed normally as TaskState.COMPLETED, +independent of the process exit code. +""" +QUERY_COMPLETED_SUCCESS: StateQuery.ValueType # 4 +"""Query for all tasks that completed normally as TaskState.COMPLETED and that +had exit code 0. +""" +QUERY_COMPLETED_FAILURE: StateQuery.ValueType # 5 +"""Query for all tasks that completed normally as TaskState.COMPLETED and that +had exit code not 0. +""" +QUERY_EXPIRED: StateQuery.ValueType # 6 +"""Query for all tasks that are TaskState.EXPIRED.""" +QUERY_TIMED_OUT: StateQuery.ValueType # 7 +"""Query for all tasks that are TaskState.TIMED_OUT.""" +QUERY_BOT_DIED: StateQuery.ValueType # 8 +"""Query for all tasks that are TaskState.BOT_DIED.""" +QUERY_CANCELED: StateQuery.ValueType # 9 +"""Query for all tasks that are TaskState.CANCELED.""" +QUERY_ALL: StateQuery.ValueType # 10 +"""Query for all tasks, independent of the task state. + +In hindsight, this constant should have been the value 0. Sorry, the +original author was young and foolish. +""" +QUERY_DEDUPED: StateQuery.ValueType # 11 +"""Query for all tasks that are TaskState.COMPLETED but that actually didn't +run due to TaskProperties.idempotent being True *and* that a previous task +with the exact same TaskProperties had successfully run before, aka +COMPLETED_SUCCESS. +""" +QUERY_KILLED: StateQuery.ValueType # 12 +"""Query for all tasks that are TaskState.KILLED.""" +QUERY_NO_RESOURCE: StateQuery.ValueType # 13 +"""Query for all tasks that are TaskState.NO_RESOURCE.""" +QUERY_CLIENT_ERROR: StateQuery.ValueType # 14 +"""Query for all tasks that are TaskState.CLIENT_ERROR.""" +global___StateQuery = StateQuery + @typing_extensions.final class StringPair(google.protobuf.message.Message): """Messages @@ -673,3 +796,53 @@ class NewTaskRequest(google.protobuf.message.Message): def ClearField(self, field_name: typing_extensions.Literal["bot_ping_tolerance_secs", b"bot_ping_tolerance_secs", "evaluate_only", b"evaluate_only", "expiration_secs", b"expiration_secs", "name", b"name", "parent_task_id", b"parent_task_id", "pool_task_template", b"pool_task_template", "priority", b"priority", "properties", b"properties", "pubsub_auth_token", b"pubsub_auth_token", "pubsub_topic", b"pubsub_topic", "pubsub_userdata", b"pubsub_userdata", "realm", b"realm", "request_uuid", b"request_uuid", "resultdb", b"resultdb", "service_account", b"service_account", "tags", b"tags", "task_slices", b"task_slices", "user", b"user"]) -> None: ... global___NewTaskRequest = NewTaskRequest + +@typing_extensions.final +class TasksCountRequest(google.protobuf.message.Message): + DESCRIPTOR: google.protobuf.descriptor.Descriptor + + START_FIELD_NUMBER: builtins.int + END_FIELD_NUMBER: builtins.int + STATE_FIELD_NUMBER: builtins.int + TAGS_FIELD_NUMBER: builtins.int + @property + def start(self) -> google.protobuf.timestamp_pb2.Timestamp: ... + @property + def end(self) -> google.protobuf.timestamp_pb2.Timestamp: ... + state: global___StateQuery.ValueType + @property + def tags(self) -> google.protobuf.internal.containers.RepeatedScalarFieldContainer[builtins.str]: ... + def __init__( + self, + *, + start: google.protobuf.timestamp_pb2.Timestamp | None = ..., + end: google.protobuf.timestamp_pb2.Timestamp | None = ..., + state: global___StateQuery.ValueType = ..., + tags: collections.abc.Iterable[builtins.str] | None = ..., + ) -> None: ... + def HasField(self, field_name: typing_extensions.Literal["end", b"end", "start", b"start"]) -> builtins.bool: ... + def ClearField(self, field_name: typing_extensions.Literal["end", b"end", "start", b"start", "state", b"state", "tags", b"tags"]) -> None: ... + +global___TasksCountRequest = TasksCountRequest + +@typing_extensions.final +class TasksCount(google.protobuf.message.Message): + """Returns the count, as requested.""" + + DESCRIPTOR: google.protobuf.descriptor.Descriptor + + COUNT_FIELD_NUMBER: builtins.int + NOW_FIELD_NUMBER: builtins.int + count: builtins.int + @property + def now(self) -> google.protobuf.timestamp_pb2.Timestamp: ... + def __init__( + self, + *, + count: builtins.int = ..., + now: google.protobuf.timestamp_pb2.Timestamp | None = ..., + ) -> None: ... + def HasField(self, field_name: typing_extensions.Literal["now", b"now"]) -> builtins.bool: ... + def ClearField(self, field_name: typing_extensions.Literal["count", b"count", "now", b"now"]) -> None: ... + +global___TasksCount = TasksCount diff --git a/src/clusterfuzz/_internal/protos/swarming_pb2_grpc.py b/src/clusterfuzz/_internal/protos/swarming_pb2_grpc.py index e88584a711d..7553de3ca87 100644 --- a/src/clusterfuzz/_internal/protos/swarming_pb2_grpc.py +++ b/src/clusterfuzz/_internal/protos/swarming_pb2_grpc.py @@ -1,4 +1,4 @@ -# Copyright 2026 Google LLC +# Copyright 2023 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. From e48e236d1885bab311b8ae00c6afcd536f2b2593 Mon Sep 17 00:00:00 2001 From: Ivan Barba Date: Mon, 18 May 2026 17:53:35 +0000 Subject: [PATCH 2/2] Updates date in grpc.py --- src/clusterfuzz/_internal/protos/swarming_pb2_grpc.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/clusterfuzz/_internal/protos/swarming_pb2_grpc.py b/src/clusterfuzz/_internal/protos/swarming_pb2_grpc.py index 7553de3ca87..e88584a711d 100644 --- a/src/clusterfuzz/_internal/protos/swarming_pb2_grpc.py +++ b/src/clusterfuzz/_internal/protos/swarming_pb2_grpc.py @@ -1,4 +1,4 @@ -# Copyright 2023 Google LLC +# Copyright 2026 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License.