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
buildstream
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
BuildStream
buildstream
Commits
a78aaacb
Commit
a78aaacb
authored
6 years ago
by
Raoul Hidalgo Charman
Browse files
Options
Downloads
Patches
Plain Diff
pull_tree: WIP commit for what I've got so far.
doesn't work.
parent
f112bfae
No related branches found
No related tags found
Loading
Pipeline
#41870040
failed
6 years ago
Stage: prepare
Stage: test
Stage: post
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
buildstream/_artifactcache.py
+17
-6
17 additions, 6 deletions
buildstream/_artifactcache.py
buildstream/_cas/cascache.py
+0
-46
0 additions, 46 deletions
buildstream/_cas/cascache.py
buildstream/_cas/casremote.py
+32
-0
32 additions, 0 deletions
buildstream/_cas/casremote.py
with
49 additions
and
52 deletions
buildstream/_artifactcache.py
+
17
−
6
View file @
a78aaacb
...
...
@@ -694,15 +694,26 @@ class ArtifactCache():
#
# Args:
# project (Project): The current project
# digest (Digest): The digest of the tree
#
tree_
digest (Digest): The digest of the tree
#
def
pull_tree
(
self
,
project
,
digest
):
def
pull_tree
(
self
,
project
,
tree_
digest
):
for
remote
in
self
.
_remotes
[
project
]:
digest
=
self
.
cas
.
pull_tree
(
remote
,
digest
)
try
:
for
blob_digest
in
remote
.
yield_tree_digests
(
tree_digest
):
if
self
.
cas
.
check_blob
(
filenode
.
digest
):
continue
remote
.
request_blob
(
filenode
.
digest
)
for
blob_file
in
remote
.
get_blobs
():
self
.
cas
.
add_object
(
path
=
blob_file
.
name
,
link_directly
=
True
)
if
digest
:
# no need to pull from additional remotes
return
digest
# Get the last batch
for
blob_file
in
remote
.
get_blobs
(
request_batch
=
True
):
self
.
cas
.
add_object
(
path
=
blob_file
.
name
,
link_directly
=
True
)
except
BlobNotFound
:
continue
else
:
return
tree_digest
return
None
...
...
This diff is collapsed.
Click to expand it.
buildstream/_cas/cascache.py
+
0
−
46
View file @
a78aaacb
...
...
@@ -183,29 +183,6 @@ class CASCache():
return
modified
,
removed
,
added
# pull_tree():
#
# Pull a single Tree rather than a ref.
# Does not update local refs.
#
# Args:
# remote (CASRemote): The remote to pull from
# digest (Digest): The digest of the tree
#
def
pull_tree
(
self
,
remote
,
digest
):
try
:
remote
.
init
()
digest
=
self
.
_fetch_tree
(
remote
,
digest
)
return
digest
except
grpc
.
RpcError
as
e
:
if
e
.
code
()
!=
grpc
.
StatusCode
.
NOT_FOUND
:
raise
return
None
# link_ref():
#
# Add an alias for an existing ref.
...
...
@@ -771,29 +748,6 @@ class CASCache():
return
objpath
def
_fetch_tree
(
self
,
remote
,
digest
):
# download but do not store the Tree object
with
tempfile
.
NamedTemporaryFile
(
dir
=
self
.
tmpdir
)
as
out
:
remote
.
_fetch_blob
(
digest
,
out
)
tree
=
remote_execution_pb2
.
Tree
()
with
open
(
out
.
name
,
'
rb
'
)
as
f
:
tree
.
ParseFromString
(
f
.
read
())
tree
.
children
.
extend
([
tree
.
root
])
for
directory
in
tree
.
children
:
for
filenode
in
directory
.
files
:
self
.
_ensure_blob
(
remote
,
filenode
.
digest
)
# place directory blob only in final location when we've downloaded
# all referenced blobs to avoid dangling references in the repository
dirbuffer
=
directory
.
SerializeToString
()
dirdigest
=
self
.
add_object
(
buffer
=
dirbuffer
)
assert
dirdigest
.
size_bytes
==
len
(
dirbuffer
)
return
dirdigest
def
_send_directory
(
self
,
remote
,
digest
,
u_uid
=
uuid
.
uuid4
()):
required_blobs
=
self
.
_required_blobs
(
digest
)
...
...
This diff is collapsed.
Click to expand it.
buildstream/_cas/casremote.py
+
32
−
0
View file @
a78aaacb
...
...
@@ -281,6 +281,17 @@ class CASRemote():
else
:
return
None
def
get_tree_blob
(
self
,
tree_digest
):
self
.
init
()
f
=
tempfile
.
NamedTemporaryFile
(
dir
=
self
.
tmpdir
)
self
.
_fetch_blob
(
tree_digest
,
f
)
tree
=
remote_execution_pb2
.
Tree
()
with
open
(
f
.
name
,
'
rb
'
)
as
tmp
:
tree
.
ParseFromString
(
tmp
.
read
())
return
tree
# yield_directory_digests():
#
# Iterate over blobs digests starting from a root digest
...
...
@@ -301,6 +312,27 @@ class CASRemote():
# Fetch artifact, excluded_subdirs determined in pullqueue
yield
from
self
.
_yield_directory_digests
(
root_digest
,
excluded_subdirs
=
excluded_subdirs
)
def
yield_tree_digests
(
self
,
tree_digest
):
self
.
init
()
# get tree file
f
=
tempfile
.
NamedTemporaryFile
(
dir
=
self
.
tmpdir
)
self
.
_fetch_blob
(
tree_digest
,
f
)
tree
=
remote_execution_pb2
.
Tree
()
tree
.
ParseFromString
(
f
.
read
())
tree
.
children
.
extend
([
tree
.
root
])
for
directory
in
tree
.
children
:
for
filenode
in
directory
.
files
:
yield
filenode
.
digest
# add the directory to files to add to cas store
f2
=
tempfile
.
NamedTemporaryFile
(
dir
=
self
.
tmpdir
)
f2
.
write
(
directory
.
SerializeToString
())
self
.
__tmp_downloads
.
append
(
f2
)
self
.
__tmp_downloads
.
append
(
f
)
# request_blob():
#
# Request blob, triggering download depending via bytestream or cas
...
...
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