-
Notifications
You must be signed in to change notification settings - Fork 178
Feature: Requirements config option and handling #833
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…check for installed python modules. Additionally Mbed CLI will only report but not attempt to install missing python modules during `mbed compile`, `mbed test`, `mbed export`, `mbed detect`
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think most people opting out of dependency updates will not want extra prints in their logs.
def check_requirements(self, show_warning_only=False): | ||
skip_requirements = self.get_cfg("NO_REQUIREMENTS", False) | ||
if skip_requirements: | ||
action("Skipping installed requirements check due to configuration flag.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we make this a verbose only print?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a non standard behavior and it's very easy to forget it. An extra line is not an overkill and it passes the responsibility to the user to handle requirements. Without the notice, there's no indication that one of the fundamental mbed CLI functions is not being performed because of user config.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think having it under a verbose print makes sense, we already tell the user to run with -v
if the subprocess exits with a non zero code: https://github.com/ARMmbed/mbed-cli/blob/master/mbed/mbed.py#L3388
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And I already explained that not reminding that we're skipping all requirements check (which is NOT RECOMMENDED) should be clearly visible. Read my comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR should not come in as is due to a few issues listed below.
mbed/mbed.py
Outdated
@@ -2977,7 +2982,7 @@ def test_(toolchain=None, target=None, compile_list=False, run_list=False, | |||
def dev_mgmt(toolchain=None, target=None, source=False, profile=False, build=False): | |||
orig_path = getcwd() | |||
program = Program(getcwd(), True) | |||
program.check_requirements(True) | |||
program.check_requirements() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a behavior change, this will now cause the CLI to halt and exit with a non-zero return code if the requirements aren't present before running the mbed dm
command.
I'm not necessarily against this, it just wasn't documented in the PR description or the commit message so I missed this at first.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To clarify the behavior:
- Mbed CLI should attempt to auto-install requirements when:
- Codebased is being imported (
mbed import
,mbed add
,mbed deploy
,mbed new
) - Codebased is being updated/checked out (
mbed update
) - Certificates are being installed or changed (
mbed dm
)
- Codebased is being imported (
- Mbed CLI should only check and NOT try to auto-install requirements when:
- Code is being compiled, tested or exported
- Any Mbed CLI operation that doesn't imply network connectivity
As thoroughly described here #756. Also as mentioned in my first comment to this PR.
mbed/mbed.py
Outdated
@@ -1681,7 +1686,7 @@ def post_action(self, check_reqs=True): | |||
shutil.copy(os.path.join(mbed_tools_path, 'default_settings.py'), os.path.join(self.path, 'mbed_settings.py')) | |||
|
|||
if check_reqs: | |||
self.check_requirements(True) | |||
self.check_requirements() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a behavior change, this will now cause the CLI to halt and exit with a non-zero return code if the requirements aren't present after cloning (and auto-installing) mbed-os.
I'm not necessarily against this, it just wasn't documented in the PR description or the commit message so I missed this at first.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To clarify the behavior:
- Mbed CLI should attempt to auto-install requirements when:
- Codebased is being imported (
mbed import
,mbed add
,mbed deploy
,mbed new
) - Codebased is being updated/checked out (
mbed update
) - Certificates are being installed or changed (
mbed dm
)
- Codebased is being imported (
- Mbed CLI should only check and NOT try to auto-install requirements when:
- Code is being compiled, tested or exported
- Any Mbed CLI operation that doesn't imply network connectivity
As thoroughly described here #756. Also as mentioned in my first comment to this PR.
mbed/mbed.py
Outdated
@@ -1636,7 +1641,7 @@ def check_requirements(self, show_warning=False): | |||
if not pkg in installed_packages: | |||
missing.append(pkg) | |||
|
|||
if missing and install_requirements: | |||
if missing and install_requirements and not show_warning_only: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh hang on, so now the show_warning_only
is being used to select if things should be auto installed? That doesn't sound right.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
show_warning_only = show a warning and do not auto-install
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@screamerbg Perhaps it could use a different name then?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@theotherjimmy Proposal?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
require_install
?and invert the logic so that True raises an error and False warns.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Everything looks OK to me with the exception of the comment about the show_warning_only
. My opinion is that flags for logging and modifying install behavior should be separate.
While I'd prefer to have the "Skipping installed requirements" print to only be printed in verbose, we can revisit this in a separate PR. Right now this feature is being requested by many folks so I'd prefer to have a solution for them. Thanks very much for contributing this @screamerbg .
To clarify the behavior:
As thoroughly described here #756. Also as mentioned in my first comment to this PR. In addition to this, the behavior above can be overridden using the |
@screamerbg Thanks for the clarifications, I hadn't seen that issue before, that helps give the context. I still would prefer to have the two flags separate in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@screamerbg, oh man, my GitHub didn't refresh! I see that you've pushed updated flags for that function. Looks good, thanks very much!
Hey man, no worries! I could have made that clearer, but I had to rush to meetings 😄 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A follow up PR is fine for these updates.
This PR tunes how Mbed OS python requirements are being installed:
mbed import
,mbed add
,mbed deploy
,mbed new
)mbed update
)mbed dm
)As thoroughly described here #756.