Skip to content
GitLab
Next
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
7b7d6fb0
Commit
7b7d6fb0
authored
6 years ago
by
James Ennis
Browse files
Options
Downloads
Patches
Plain Diff
_stream.py: Allow loading to handle artifact refs
parent
446854fc
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
buildstream/_stream.py
+46
-15
46 additions, 15 deletions
buildstream/_stream.py
with
46 additions
and
15 deletions
buildstream/_stream.py
+
46
−
15
View file @
7b7d6fb0
...
...
@@ -29,7 +29,7 @@ import tempfile
from
contextlib
import
contextmanager
,
suppress
from
fnmatch
import
fnmatch
from
._exceptions
import
StreamError
,
ImplError
,
BstError
,
set_last_task_error
from
._exceptions
import
StreamError
,
ImplError
,
BstError
,
ArtifactElementError
,
set_last_task_error
from
._message
import
Message
,
MessageType
from
._scheduler
import
Scheduler
,
SchedStatus
,
TrackQueue
,
FetchQueue
,
BuildQueue
,
PullQueue
,
PushQueue
from
._pipeline
import
Pipeline
,
PipelineSelection
...
...
@@ -109,19 +109,21 @@ class Stream():
def
load_selection
(
self
,
targets
,
*
,
selection
=
PipelineSelection
.
NONE
,
except_targets
=
(),
use_artifact_config
=
False
):
use_artifact_config
=
False
,
load_refs
=
False
):
profile_start
(
Topics
.
LOAD_SELECTION
,
"
_
"
.
join
(
t
.
replace
(
os
.
sep
,
'
-
'
)
for
t
in
targets
))
elements
,
_
=
self
.
_load
(
targets
,
(),
selection
=
selection
,
except_targets
=
except_targets
,
fetch_subprojects
=
False
,
use_artifact_config
=
use_artifact_config
)
target_objects
,
_
=
self
.
_load
(
targets
,
(),
selection
=
selection
,
except_targets
=
except_targets
,
fetch_subprojects
=
False
,
use_artifact_config
=
use_artifact_config
,
load_refs
=
load_refs
)
profile_end
(
Topics
.
LOAD_SELECTION
,
"
_
"
.
join
(
t
.
replace
(
os
.
sep
,
'
-
'
)
for
t
in
targets
))
return
elemen
ts
return
target_objec
ts
# shell()
#
...
...
@@ -913,25 +915,40 @@ class Stream():
use_artifact_config
=
False
,
artifact_remote_url
=
None
,
fetch_subprojects
=
False
,
dynamic_plan
=
False
):
dynamic_plan
=
False
,
load_refs
=
False
):
# Obtain cached refs and project element path needed to classify artifacts
cas
=
self
.
_artifacts
.
cas
cached_refs
=
cas
.
list_refs
()
project_element_path
=
self
.
_project
.
element_path
# Classify element and artifact strings
target_elements
,
target_artifacts
=
self
.
_classify_artifacts
(
targets
,
cached_refs
,
project_element_path
)
if
target_artifacts
and
not
load_refs
:
detail
=
''
.
join
(
target_artifacts
)
raise
ArtifactElementError
(
"
Cannot perform this operation with artifact refs:
"
,
detail
=
detail
)
# Load rewritable if we have any tracking selection to make
rewritable
=
False
if
track_targets
:
rewritable
=
True
# Load all targets
# Load all target
element
s
elements
,
except_elements
,
track_elements
,
track_except_elements
=
\
self
.
_pipeline
.
load
([
targets
,
except_targets
,
track_targets
,
track_except_targets
],
self
.
_pipeline
.
load
([
target
_element
s
,
except_targets
,
track_targets
,
track_except_targets
],
rewritable
=
rewritable
,
fetch_subprojects
=
fetch_subprojects
)
artifacts
=
self
.
_load_refs
(
target_artifacts
)
# Optionally filter out junction elements
if
ignore_junction_targets
:
elements
=
[
e
for
e
in
elements
if
e
.
get_kind
()
!=
'
junction
'
]
# Hold on to the targets
self
.
targets
=
elements
self
.
targets
=
elements
+
artifacts
# Here we should raise an error if the track_elements targets
# are not dependencies of the primary targets, this is not
...
...
@@ -988,9 +1005,9 @@ class Stream():
# Now move on to loading primary selection.
#
self
.
_pipeline
.
resolve_elements
(
el
emen
ts
)
selected
=
self
.
_pipeline
.
get_selection
(
el
emen
ts
,
selection
,
silent
=
False
)
selected
=
self
.
_pipeline
.
except_elements
(
el
emen
ts
,
self
.
_pipeline
.
resolve_elements
(
s
el
f
.
targe
ts
)
selected
=
self
.
_pipeline
.
get_selection
(
s
el
f
.
targe
ts
,
selection
,
silent
=
False
)
selected
=
self
.
_pipeline
.
except_elements
(
s
el
f
.
targe
ts
,
selected
,
except_elements
)
...
...
@@ -1014,6 +1031,20 @@ class Stream():
return
selected
,
track_selected
# _load_refs()
#
# Create and resolve ArtifactElement objects
#
def
_load_refs
(
self
,
refs
):
artifact_elements
=
[]
for
ref
in
refs
:
artifact_element
=
self
.
_project
.
create_artifact_element
(
ref
)
artifact_elements
.
append
(
artifact_element
)
self
.
_pipeline
.
resolve_elements
(
artifact_elements
)
return
artifact_elements
# _message()
#
# Local message propagator
...
...
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