-
Notifications
You must be signed in to change notification settings - Fork 2
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
Refactoring language_container_deployer #162
Conversation
|
||
deployer.upload_container = MagicMock() | ||
deployer.activate_container = MagicMock() | ||
deployer.get_language_settings = MagicMock() |
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.
Instead of making the function get_language_settings
public and overwriting it with a mock, I would suggest to extract completely from the deployer class and injecting it into the constructor as a parameter with default to its actual implementation
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.
Maybe, actually extract all three functions (Upload, activate, get_language_settings) in one extra class.
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.
For the moment, we could keep it this way, but long-term these functions might be of interest independent of the deployer. We can then extract them.
@@ -52,6 +26,8 @@ def run_deployer(deployer, upload_container: bool = True, | |||
utils.DB_PASSWORD_ENVIRONMENT_VARIABLE, "")) |
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 click Options are not yet packed into @add_options(create_deployer_option(utils.DB_PASSWORD_ENVIRONMENT_VARIABLE, utils.BUCKETFS_PASSWORD_ENVIRONMENT_VARIABLE)
, but I think we can only do it during reintegration. Maybe in the meantime we should copy the add_options from itde to here. This prepare this already.
exasol_transformers_extension/deployment/language_container_deployer.py
Outdated
Show resolved
Hide resolved
exasol_transformers_extension/deployment/language_container_deployer.py
Outdated
Show resolved
Hide resolved
exasol_transformers_extension/deployment/language_container_deployer.py
Outdated
Show resolved
Hide resolved
SLC_NAME = "exasol_transformers_extension_container_release.tar.gz" | ||
GH_RELEASE_URL = "https://github.com/exasol/transformers-extension/releases/download" | ||
|
||
def download_from_git_and_run(self, version: 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.
Thinking about, we could move this as well to the LanguageContainerDeployer and use attributes for the url and slc name which we set in the constructor
SLC_NAME = "exasol_transformers_extension_container_release.tar.gz" | ||
GH_RELEASE_URL = "https://github.com/exasol/transformers-extension/releases/download" | ||
|
||
def download_from_git_and_run(self, version: 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.
def download_from_git_and_run(self, version: str, | |
def download_from_github_and_run(self, version: str, |
|
||
deployer.upload_container = MagicMock() | ||
deployer.activate_container = MagicMock() | ||
deployer.get_language_settings = MagicMock() |
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.
For the moment, we could keep it this way, but long-term these functions might be of interest independent of the deployer. We can then extract them.
…ployer.py Co-authored-by: Torsten Kilias <[email protected]>
…ployer.py Co-authored-by: Torsten Kilias <[email protected]>
…ployer.py Co-authored-by: Torsten Kilias <[email protected]>
This commit is NOT ready to be merged. Pushing it just to discuss some ideas. |
|
||
def update_parameter(parameter_name: str, formatter: str) -> None: | ||
param_formatter = ctx.params.get(parameter_name, formatter) | ||
if param_formatter: | ||
# Enclose in double curly brackets all other parameters in the formatting string, | ||
# to avoid the missing parameters' error. | ||
pattern = r'\{(?!' + param.name + r'\})\w+\}' |
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.
an example how the pattern looks at the end and what it matches might be useful
_ParameterFormatters, CustomizableParameters) | ||
|
||
|
||
def test_parameter_formatters_1param(): |
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.
wow, I like that
# to avoid the missing parameters' error. | ||
# to avoid the missing parameters' error. Below is an example of a formatter string | ||
# before and after applying the regex, assuming the current parameter is 'version'. | ||
# 'something-with-{version}/tailored-for-{user}' => 'something-with-{version}/tailored-for-{{user}}' |
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.
did you actually change the wrong parameter
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 pattern in this example would be \{(?!version\})\w+\}
and it matches all substrings {...}
that are not {version}
.
This is just an explanation of a generic usage. We currently don't have a use case with more than 1 parameter. |
closes #159
All Submissions:
[CodeBuild]
to the commit message