Skip to content

Commit 09e7542

Browse files
committed
Eliminate state entirely
1 parent 30d7c34 commit 09e7542

File tree

3 files changed

+12
-57
lines changed

3 files changed

+12
-57
lines changed

src/buildstream/_frontend/cli.py

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,6 @@ def build(
535535
# Inspect Command #
536536
##################################################################
537537
@cli.command(name="inspect", short_help="Inspect Project Information")
538-
@click.option("-s", "--state", default=False, show_default=True, is_flag=True, help="Show information that requires inspecting remote state")
539538
@click.option(
540539
"--deps",
541540
"-d",
@@ -554,7 +553,7 @@ def build(
554553
)
555554
@click.argument("elements", nargs=-1, type=click.Path(readable=False))
556555
@click.pass_obj
557-
def inspect(app, elements, state, deps):
556+
def inspect(app, elements, deps):
558557
"""Access structured data about a given buildstream project and it's computed elements.
559558
560559
Specifying no elements will result in showing the default targets
@@ -575,24 +574,16 @@ def inspect(app, elements, state, deps):
575574
build: Build time dependencies, excluding the element itself
576575
all: All dependencies
577576
578-
If ``--state`` is toggled then pipeline elements which require remote state will be
579-
shown in addition to information that is available on the local system.
580-
581577
Examples:
582578
583-
# Show all default elements with remote information
584-
\n
585-
bst inspect --state
586-
587-
588579
# A specific target (glob pattern)
589580
\n
590-
bst inspect -s public/*.bst
581+
bst inspect public/*.bst
591582
592583
593584
# With a dependency target
594585
\n
595-
bst inspect -d run --state
586+
bst inspect -d run
596587
597588
598589
# Show each remote file source (with the help of jq)
@@ -601,7 +592,7 @@ def inspect(app, elements, state, deps):
601592
602593
"""
603594
with app.initialized():
604-
app.inspector.dump_to_stdout(elements, selection=deps, with_state=state)
595+
app.inspector.dump_to_stdout(elements, selection=deps)
605596

606597

607598
##################################################################

src/buildstream/_frontend/inspect.py

Lines changed: 6 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,8 @@ class _Element:
1616
name: str
1717
description: str
1818
workspace: any
19-
key: str
20-
key_full: str
21-
# state: str
2219
environment: dict[str, str]
2320
variables: dict[str, str]
24-
artifact: any
2521
dependencies: list[str]
2622
build_dependencies: list[str]
2723
runtime_dependencies: list[str]
@@ -201,34 +197,9 @@ def __init__(self, stream, project, context):
201197
self.project = project
202198
self.context = context
203199

204-
def _elements(self, dependencies, with_state=False):
200+
def _elements(self, dependencies):
205201
for element in dependencies:
206202

207-
# These operations require state and are only shown if requested
208-
key = None
209-
key_full = None
210-
state = None
211-
artifact = None
212-
213-
if with_state:
214-
key = element._get_display_key().brief
215-
216-
key_full = element._get_display_key().full
217-
218-
# BUG: Due to the assersion within .get_artifact this will
219-
# error but there is no other way to determine if an artifact
220-
# exists and we only want to show this value for informational
221-
# purposes.
222-
try:
223-
_artifact = element._get_artifact()
224-
if _artifact.cached():
225-
artifact = {
226-
"files": artifact.get_files(),
227-
"digest": artifact_files._get_digest(),
228-
}
229-
except:
230-
pass
231-
232203
sources = []
233204
for source in element.sources():
234205
source_infos = source.collect_source_info()
@@ -260,10 +231,6 @@ def _elements(self, dependencies, with_state=False):
260231
runtime_dependencies=lambda element: [
261232
dependency._get_full_name() for dependency in element._dependencies(_Scope.RUN, recurse=False)
262233
],
263-
key=key,
264-
key_full=key_full,
265-
# state=state,
266-
artifact=artifact,
267234
)
268235

269236
def _get_projects(self) -> [_Project]:
@@ -361,23 +328,20 @@ def _get_user_config(self) -> _UserConfig:
361328
remote_action_cache_service=remote_action_cache_service,
362329
)
363330

364-
def _get_output(self, dependencies, with_state=False) -> _InspectOutput:
331+
def _get_output(self, dependencies) -> _InspectOutput:
365332
return _InspectOutput(
366333
project=self._get_projects(),
367334
user_config=self._get_user_config(),
368-
elements=[element for element in self._elements(dependencies, with_state=with_state)],
335+
elements=[element for element in self._elements(dependencies)],
369336
)
370337

371-
def dump_to_stdout(self, elements=[], selection=_PipelineSelection.NONE, with_state=False):
338+
def dump_to_stdout(self, elements=[], selection=_PipelineSelection.NONE):
372339
if not elements:
373340
elements = self.project.get_default_targets()
374341

375342
dependencies = self.stream.load_selection(
376-
elements, selection=selection, except_targets=[], need_state=with_state
343+
elements, selection=selection, except_targets=[]
377344
)
378345

379-
if with_state:
380-
self.stream.query_cache(dependencies, need_state=True)
381-
382-
output = self._get_output(dependencies, with_state)
346+
output = self._get_output(dependencies)
383347
json.dump(_dump_dataclass(output), sys.stdout)

tests/frontend/inspect.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ def _assert_has_source(elements, expected: _Source):
6565
[
6666
([], ["import-local-files.bst", "import-remote-files.bst", "target.bst"]),
6767
(["*.bst", "**/*.bst"],["import-local-files.bst", "import-remote-files.bst", "target.bst"]),
68-
(["--state"], ["import-local-files.bst", "import-remote-files.bst", "target.bst"]),
69-
(["--state", "--deps", "all"], ["import-local-files.bst", "import-remote-files.bst", "target.bst"]),
68+
([], ["import-local-files.bst", "import-remote-files.bst", "target.bst"]),
69+
(["--deps", "all"], ["import-local-files.bst", "import-remote-files.bst", "target.bst"]),
7070
(["import-*.bst"], ["import-local-files.bst", "import-remote-files.bst"])
7171
],
7272
)

0 commit comments

Comments
 (0)