Repository navigation
Shell API and CLI: Add option for staging additional runtime targets - #2147
nathanwilliams-ct wants to merge 2 commits into
Conversation
|
Thanks, whoever triggered the CI... looks like it needs a little work, despite the tests working locally in the tox environment and I missed the linters. |
6c82853 to
fb98811
Compare
|
I think this should pass CI now, fixed docs, linters, static type checker, formatter and 3.10 issues |
5c266ec to
4857d9e
Compare
|
pre-commit hooks would be nice. I keep running the commands locally, but It seems I am doing them in the wrong order.. fixing one thing breaks the others XD |
tox
tox -- --integration
tox -e docs
tox -e lint
tox -e mypy
tox -e formatAnd the tests locally only run on 313 and 314 for me, while CI does also 310 311 312 Is complete list right? |
tox runs the tests on all Python versions from 3.10 to 3.14 by default, but skipping versions where the interpreter is not installed. It's normally fine to test against just one Python version locally, letting CI take care of the others, unless you're actively debugging a version-specific issue.
CI also runs buildgrid and buildbarn, tests against master of buildstream-plugins-community, and builds wheels. Unless you're working in these specific areas, it shouldn't be necessary to run those locally. |
|
Ah there's a subtle conflict between format and the docs generation. |
abffc99 to
5a52dae
Compare
|
Static type checking moved out into it's own PR: #2153 |
5a52dae to
9e9eba9
Compare
9e9eba9 to
311b613
Compare
311b613 to
e271424
Compare
e271424 to
c843357
Compare
1a38816 to
031710f
Compare
|
|
||
| target_loader._set_fullpath_overrides(target_name, temp_target_file.name) | ||
|
|
||
| self.build([target]) |
There was a problem hiding this comment.
This should no longer be necessary with the fullpath override, right?
There was a problem hiding this comment.
Changing the dependencies messes with the cache key so a build is necessary still.
There was a problem hiding this comment.
Direct runtime dependencies shouldn't affect the cache key. And for build shells (where we add build dependencies), we shouldn't invoke a build before entering the shell anyway. Or am I misremembering or missing something? Have you confirmed a cache key issue with the latest version of your branch (with the fullpath override)?
There was a problem hiding this comment.
hmmm, No, I will do some further testing.
|
Nit: We prefer limiting normal text lines in git commit messages to 72 characters, matching usual git conventions. |
|
The test seems to be failing on Python 3.10 (Ubuntu 22.04) and Python 3.11 (Debian 12). |
af385fc to
502eee7
Compare
c79e587 to
c5a7569
Compare
c5a7569 to
b275ed5
Compare
This enables users to add additional functionality such as debug tooling in the shell sandbox, without needing to modify the target element. This is achived through introducing a new option to shell. All existing API and UX is maintained, to not break existing scripts. An alternative design was considered, to have the additional elements as positional arguments similar to the existing element, but this would need manual parsing to handle the cases where `--` is present and not present, splitting based on a `.bst` suffix. This UX could be re-visited in future. Example usage: bst shell --with base.bst example.bst -- cat example.txt Where: - example.bst is a simple import element with no dependencies that imports a file called example.txt - base.bst provides a basic alpine sysroot with a standard set of unix tooling (sh, df, cat etc). Changes: - Introduces `test_with_other_targets` integration test to the shell test suite. - Adds `--with` cli option to the shell subcommand and updates it's documentation. - option can be used multiple times by caller, providing a list of targets. - Extends the shell top level calling interface in Buildstream core to accept a list of other_targets - This is where the targets are loaded into elements and checked to make sure they are present - Extends the shell element implementation to accept a list of other targets - This is where the other elements are staged and integrated into the sandbox
b275ed5 to
a3cd988
Compare
juergbi
left a comment
There was a problem hiding this comment.
Thanks for the updates. I think it's almost ready but have a few minor comments.
| import sys | ||
| import tempfile |
There was a problem hiding this comment.
src/buildstream/_loader/loader.py:18:0: W0611: Unused import sys (unused-import)
src/buildstream/_loader/loader.py:19:0: W0611: Unused import tempfile (unused-import)
| ignore_project_artifact_remotes=ignore_project_artifact_remotes, | ||
| ignore_project_source_remotes=ignore_project_source_remotes, | ||
| ) | ||
| if other_targets: |
There was a problem hiding this comment.
Either here or in Stream.shell_with() we should reject the combination of --use-buildtree and --with with a clear error message as this combination can't work, right?
| def _set_fullpath_override(self, filename: str, fullpath: str | None): | ||
| if fullpath: | ||
| self._fullpath_overrides[filename] = fullpath | ||
| else: | ||
| self._fullpath_overrides.pop(filename, None) |
There was a problem hiding this comment.
Nit: Each branch is a one-liner and used exactly once. Wouldn't it be simpler to inline it at the call site?
If you think it's clearer to have this in a separate method (it could hypothetically also be used for other purposes), then I think this should be a context manager to provide some actual benefit at the call site.
Either variant is fine with me.
| # Test staging and running additional targets in the shell of the main target for debugging. | ||
| @pytest.mark.datafiles(DATA_DIR) | ||
| @pytest.mark.skipif(not HAVE_SANDBOX, reason="Only available with a functioning sandbox") | ||
| def test_with_other_targets(cli, datafiles): |
There was a problem hiding this comment.
I'd like to see at least a minimal test for a build shell as well.
| else: | ||
| raise StreamError( | ||
| "Only BUILD and RUN scopes are supported", | ||
| detail="Use the --build and --use-buildtree options to shell into a build tree", |
There was a problem hiding this comment.
This detail doesn't make sense to me. Leftover from copy paste?
This enables users to add additional functionality such as debug tooling in the shell sandbox,
without needing to modify the target element. This is achived through introducing a new option to
shell.
All existing API and UX is maintained, to not break existing scripts. An alternative design was
considered, to have the additional elements as positional arguments similar to the existing element,
but this would need manual parsing to handle the cases where
--is present and notpresent, splitting based on a
.bstsuffix. This UX could be re-visited in future.Example usage:
bst shell --with base.bst example.bst -- cat example.txt
Where:
Changes:
test_with_other_targetsintegration test to the shell test suite.--withcli option to the shell subcommand and updates it's documentation.other_targets
towards: #422