-
Notifications
You must be signed in to change notification settings - Fork 13
Add the ability to specify custom build steps when adding modules #265
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
This value was unused and the signature now matches `_add_using_url` Signed-off-by: jakub-nt <175944085+jakub-nt@users.noreply.github.com>
Signed-off-by: jakub-nt <175944085+jakub-nt@users.noreply.github.com>
It had a subnormal name. Signed-off-by: jakub-nt <175944085+jakub-nt@users.noreply.github.com>
This makes it clear that the functions take a module name, not an entire module object Signed-off-by: jakub-nt <175944085+jakub-nt@users.noreply.github.com>
Signed-off-by: jakub-nt <175944085+jakub-nt@users.noreply.github.com>
f13c73a to
c8f0083
Compare
|
Please explain how this should work. Do you need it for Is there a ticket? If so could you link it to the PR and in the last commit? |
|
It should work by using a provided steps list as the added module's Yes, it's for |
olehermanse
left a 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.
Looks good, just some smaller things to fix.
| log.debug("Added build step '%s' for module '%s'" % (step, name)) | ||
|
|
||
| def _handle_local_module(self, module): | ||
| def _handle_local_module(self, module, use_default_build_steps=True): |
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 don't think it's necessary to switch from explicit_build_steps to use_default_build_steps. Just use explicit_build_steps all the way down where needed.
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.
The actual build step values would be unused then, there would only be a check whether they're None or not. That would read weird. Dunno.
| if use_default_build_steps: | ||
| self._add_policy_files_build_step(module) | ||
| self._add_bundles_build_step(module, policy_files) |
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 leaves the module object in a "half done" state, I think one of these would be preferable:
- Just add the defaults, and you can overwrite
module["steps"]in the calling code. - Or, send
explicit_build_stepsall the way down to this function.
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 leaves the module object in a "half done" state
I don't see how that would be the case after and not be the case before. The argument to this function is a Module object, which at the time of entering this function will already have some build steps from when it was constructed (and that construction will now use explicit_build_steps, too, so all the required steps should be there already).
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.
Okay, are these methods the ones which prompt user about bundle and policy files? If so, we should add a comment about that here.
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.
Yes, those are the methods. I still don't see what you would ideally like to see here, so feel free to suggest.
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.
It looks like _handle_local_module() is not really needed for our case? Maybe a better approach is to clarify it a bit (give it a better name / docstring), and avoid calling it in this case?
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.
Yeah, I found this function a bit strange/unclear (e.g. how it appears in a general _add_without_dependencies function) at first. The current code is setting build steps in a few separate places, maybe there could be improvements, I avoided changing the structure for now, since optional params in existing places could do the job.
|
|
||
| def _add_without_dependencies(self, modules): | ||
| def _add_without_dependencies(self, modules, use_default_build_steps=True): | ||
| """Note: `use_default_build_steps` is only relevant for local modules.""" |
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 docstring note could be replaced by an assert.
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 would say the note is for the users of the function, for them to learn what the function parameter does. This is why it's in the docstring. An assert is only readable inside of the function.
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.
You could have both. An assert is much more important IMO, and less likely to go stale.
cfbs/cfbs_config.py
Outdated
| checksum=None, | ||
| explicit_build_steps: Optional[List[str]] = None, | ||
| ): | ||
| """Note: explicit build steps are applied only to directly added modules, not their dependencies.""" |
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.
Same here;
if explicit_build_steps is not None:
assert len(to_add) == 1, "explicit_build_steps is only for adding a single module"
assert is_local(to_add[0]), "explicit_build_steps is only for adding a local module"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 not the same. Are you saying the ability to provide explicit build steps should be limited to adding single local modules only? It seems like it could be useful for adding multiple local modules at once, or for providing custom build steps for modules added from an index or URL.
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 know it's not exactly the same, but I would add restrictions to try to catch programmer mistakes, rather than notes that look like they could be missed or go stale in the future.
In this case, I think we could place very strict restritctions, yes, only one module, no dependencies, has to be local.
AFAIK that's what we need (for now). The pre-existing add code is a bit messy (not your fault), so it would be nice to have asserts which protect against the unexpected.
If in the future we want to expand it to multiple modules or non-local modules, that is easily doable - remove one assert and ensure it works correctly.
… scenarios Signed-off-by: jakub-nt <175944085+jakub-nt@users.noreply.github.com>
No description provided.