-
Notifications
You must be signed in to change notification settings - Fork 13
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
Update bundle related methods #99
base: main
Are you sure you want to change the base?
Update bundle related methods #99
Conversation
Notes: * What was wrong? 1. In `deploy_bundle`, I needed to convert the Path object for the bundle file to a string. If you do not convert to string first, Python will throw errors about trying to pass a Path object instead of a string to subprocess. 2. In `render_bundle`, I needed to update the regex to allow files with just the extension .j2 and .tmpl instead of being prefixed with .yaml. If I did not do that, the function would try to perform string operations on the Path object which would throw type errors.
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.
Effectively there's some missing documentation and an update to setup.py to major rev this package with these non-backwards compatible changes. Seems like there's some more work necessary to get the tests passing with these changes
if serial: | ||
cmd += ["--serial"] | ||
await self.run(*cmd, check=True) | ||
bundle: Union[str, os.PathLike], |
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 changes the signature of this method. We'll need to major rev the package and update the docs accordingly
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'm not actually convinced that the signature actually needs to change. The method signature and docstrings of an API essentially define the contract for method itself. The existing contract is fairly vague in the specification, but clear in the parameters. This change can largely (if not wholly) still honor the contract of the method without making a breaking API change. An additional advantage/improvement would be to further refine and clarify the method contract in the docstrings.
As there are existing users of this library, if the API is changed then it will break a downstream consumer of the library. Since the method contract can be upheld with the existing signature, it seems better to me to not change the signature and subsequently not break downstream consumers.
Just my $0.02
async def deploy_bundle( | ||
self, | ||
bundle: Optional[str] = None, | ||
build: bool = True, | ||
serial: bool = False, | ||
extra_args: Iterable[str] = (), | ||
): |
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 method now has a new signature and will also need the documentation updated
Any, | ||
Dict, |
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 feel like this is here to create a type like Dict[str,Any]
in quite a few places to indicate a a dict for templating context
Maybe its worth defining a local type like
Context = Dict[str, Any]
to use when we intend to render some context
technically jinja2 is very loose on it's typing.
effectively...
def render(*args: Any, **kwargs: Any):
...
Hi there @addyess - thank you for the initial round of reviews. I will work through them as I have the time 😄 Either way, we should get folks off of using |
Cool, i can agree with getting off |
Description
This pull request aims to fix the issues that I identified in issue #98. Here is the summary of modifications that I made below:
build_bundle
method to usecharmcraft pack
rather thanjuju-bundle
. It now returns a Path object that points to where the built bundle zip archive is stored.build_bundles
method to build bundles asynchronously .deploy_bundle
to usejuju deploy ...
rather thanjuju-bundle
.render_bundle
to also accept the .tmpl file extension. I also enhanced the robustness of the expression. The original regex would match inputs such asxyamlij2
,Byaml
, etc since "." means any character. I modified it so that the regex would only accept the "." character.Related issues
juju-bundle
causes breakage when callingdeploy_bundle
#98Miscellaneous
I updated the
.gitignore
file to ignore the.idea
directory. I made this modification since I use PyCharm. I also added a hashbang and copyright information to the top ofplugin.py
.