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
d1d642e6
Commit
d1d642e6
authored
6 years ago
by
Martin Blanchard
Browse files
Options
Downloads
Patches
Plain Diff
temp_directory.py: Port to new CAS downloader helper
#79
parent
350d1493
No related branches found
No related tags found
Loading
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
buildgrid/_app/bots/temp_directory.py
+11
-12
11 additions, 12 deletions
buildgrid/_app/bots/temp_directory.py
with
11 additions
and
12 deletions
buildgrid/_app/bots/temp_directory.py
+
11
−
12
View file @
d1d642e6
...
...
@@ -19,10 +19,8 @@ import tempfile
from
google.protobuf
import
any_pb2
from
buildgrid.client.cas
import
upload
from
buildgrid.client.cas
import
download
,
upload
from
buildgrid._protos.build.bazel.remote.execution.v2
import
remote_execution_pb2
from
buildgrid._protos.google.bytestream
import
bytestream_pb2_grpc
from
buildgrid.utils
import
write_fetch_directory
,
parse_to_pb2_from_fetch
from
buildgrid.utils
import
output_file_maker
,
output_directory_maker
...
...
@@ -30,29 +28,30 @@ def work_temp_directory(context, lease):
"""
Executes a lease for a build action, using host tools.
"""
stub_bytestream
=
bytestream_pb2_grpc
.
ByteStreamStub
(
context
.
cas_channel
)
instance_name
=
context
.
parent
logger
=
context
.
logger
action_digest
=
remote_execution_pb2
.
Digest
()
lease
.
payload
.
Unpack
(
action_digest
)
action
=
parse_to_pb2_from_fetch
(
remote_execution_pb2
.
Action
(),
stub_bytestream
,
action_digest
,
instance_name
)
with
tempfile
.
TemporaryDirectory
()
as
temp_directory
:
command
=
parse_to_pb2_from_fetch
(
remote_execution_pb2
.
Command
(),
stub_bytestream
,
action
.
command_digest
,
instance_name
)
with
download
(
context
.
cas_channel
,
instance
=
instance_name
)
as
downloader
:
action
=
downloader
.
get_message
(
action_digest
,
remote_execution_pb2
.
Action
())
assert
action
.
command_digest
.
hash
command
=
downloader
.
get_message
(
action
.
command_digest
,
remote_execution_pb2
.
Command
())
write_fetch_directory
(
temp_directory
,
stub_bytestream
,
action
.
input_root_digest
,
instance_name
)
downloader
.
download_directory
(
action
.
input_root_digest
,
temp_directory
)
environment
=
os
.
environ
.
copy
()
for
variable
in
command
.
environment_variables
:
if
variable
.
name
not
in
[
'
PATH
'
,
'
PWD
'
]:
environment
[
variable
.
name
]
=
variable
.
value
command_line
=
list
()
command_line
=
[]
for
argument
in
command
.
arguments
:
command_line
.
append
(
argument
.
strip
())
...
...
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