Skip to content
GitLab
Menu
Why GitLab
Pricing
Contact Sales
Explore
Why GitLab
Pricing
Contact Sales
Explore
Sign in
Get free trial
Primary navigation
Search or go to…
Project
buildgrid
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Privacy statement
Keyboard shortcuts
?
What's new
6
Snippets
Groups
Projects
Show more breadcrumbs
BuildGrid
buildgrid
Commits
d6865d83
Commit
d6865d83
authored
6 years ago
by
Martin Blanchard
Browse files
Options
Downloads
Patches
Plain Diff
Get rid of the various any_pb2.Any() helpers
parent
07d66e27
No related branches found
No related tags found
Loading
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
buildgrid/_app/bots/buildbox.py
+3
-7
3 additions, 7 deletions
buildgrid/_app/bots/buildbox.py
buildgrid/_app/bots/host.py
+3
-7
3 additions, 7 deletions
buildgrid/_app/bots/host.py
buildgrid/server/job.py
+4
-13
4 additions, 13 deletions
buildgrid/server/job.py
with
10 additions
and
27 deletions
buildgrid/_app/bots/buildbox.py
+
3
−
7
View file @
d6865d83
...
...
@@ -17,8 +17,6 @@ import os
import
subprocess
import
tempfile
from
google.protobuf
import
any_pb2
from
buildgrid.client.cas
import
download
,
upload
from
buildgrid._exceptions
import
BotError
from
buildgrid._protos.build.bazel.remote.execution.v2
import
remote_execution_pb2
...
...
@@ -29,13 +27,14 @@ from buildgrid.utils import read_file, write_file
def
work_buildbox
(
context
,
lease
):
"""
Executes a lease for a build action, using buildbox.
"""
local_cas_directory
=
context
.
local_cas
# instance_name = context.parent
logger
=
context
.
logger
action_digest
=
remote_execution_pb2
.
Digest
()
lease
.
payload
.
Unpack
(
action_digest
)
lease
.
result
.
Clear
()
with
download
(
context
.
cas_channel
)
as
downloader
:
action
=
downloader
.
get_message
(
action_digest
,
...
...
@@ -131,10 +130,7 @@ def work_buildbox(context, lease):
action_result
.
output_directories
.
extend
([
output_directory
])
action_result_any
=
any_pb2
.
Any
()
action_result_any
.
Pack
(
action_result
)
lease
.
result
.
CopyFrom
(
action_result_any
)
lease
.
result
.
Pack
(
action_result
)
return
lease
...
...
This diff is collapsed.
Click to expand it.
buildgrid/_app/bots/host.py
+
3
−
7
View file @
d6865d83
...
...
@@ -17,8 +17,6 @@ import os
import
subprocess
import
tempfile
from
google.protobuf
import
any_pb2
from
buildgrid.client.cas
import
download
,
upload
from
buildgrid._protos.build.bazel.remote.execution.v2
import
remote_execution_pb2
from
buildgrid.utils
import
output_file_maker
,
output_directory_maker
...
...
@@ -27,12 +25,13 @@ from buildgrid.utils import output_file_maker, output_directory_maker
def
work_host_tools
(
context
,
lease
):
"""
Executes a lease for a build action, using host tools.
"""
instance_name
=
context
.
parent
logger
=
context
.
logger
action_digest
=
remote_execution_pb2
.
Digest
()
lease
.
payload
.
Unpack
(
action_digest
)
lease
.
result
.
Clear
()
with
tempfile
.
TemporaryDirectory
()
as
temp_directory
:
with
download
(
context
.
cas_channel
,
instance
=
instance_name
)
as
downloader
:
...
...
@@ -122,9 +121,6 @@ def work_host_tools(context, lease):
action_result
.
output_directories
.
extend
(
output_directories
)
action_result_any
=
any_pb2
.
Any
()
action_result_any
.
Pack
(
action_result
)
lease
.
result
.
CopyFrom
(
action_result_any
)
lease
.
result
.
Pack
(
action_result
)
return
lease
This diff is collapsed.
Click to expand it.
buildgrid/server/job.py
+
4
−
13
View file @
d6865d83
...
...
@@ -19,8 +19,6 @@ import logging
import
uuid
from
enum
import
Enum
from
google.protobuf
import
any_pb2
from
buildgrid._protos.build.bazel.remote.execution.v2
import
remote_execution_pb2
from
buildgrid._protos.google.devtools.remoteworkers.v1test2
import
bots_pb2
from
buildgrid._protos.google.longrunning
import
operations_pb2
...
...
@@ -96,7 +94,7 @@ class Job:
self
.
_operation_update_queues
.
remove
(
queue
)
def
get_operation
(
self
):
self
.
_operation
.
metadata
.
CopyFrom
(
self
.
_pack_any
(
self
.
get_operation_meta
())
)
self
.
_operation
.
metadata
.
Pack
(
self
.
get_operation_meta
())
if
self
.
result
is
not
None
:
self
.
_operation
.
done
=
True
response
=
remote_execution_pb2
.
ExecuteResponse
(
result
=
self
.
result
,
...
...
@@ -105,7 +103,7 @@ class Job:
if
not
self
.
result_cached
:
response
.
status
.
CopyFrom
(
self
.
lease
.
status
)
self
.
_operation
.
response
.
CopyFrom
(
self
.
_pack_any
(
response
)
)
self
.
_operation
.
response
.
Pack
(
response
)
return
self
.
_operation
...
...
@@ -117,11 +115,9 @@ class Job:
return
meta
def
create_lease
(
self
):
action_digest
=
self
.
_pack_any
(
self
.
_action_digest
)
lease
=
bots_pb2
.
Lease
(
id
=
self
.
name
,
state
=
LeaseState
.
PENDING
.
value
)
lease
.
payload
.
Pack
(
self
.
_action_digest
)
lease
=
bots_pb2
.
Lease
(
id
=
self
.
name
,
payload
=
action_digest
,
state
=
LeaseState
.
PENDING
.
value
)
self
.
lease
=
lease
return
lease
...
...
@@ -129,8 +125,3 @@ class Job:
self
.
_execute_stage
=
stage
for
queue
in
self
.
_operation_update_queues
:
queue
.
put
(
self
.
get_operation
())
def
_pack_any
(
self
,
pack
):
some_any
=
any_pb2
.
Any
()
some_any
.
Pack
(
pack
)
return
some_any
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment