Skip to content
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

Merged
merged 10 commits into from
Dec 11, 2023

Conversation

ahsimb
Copy link
Collaborator

@ahsimb ahsimb commented Dec 1, 2023

closes #159

All Submissions:

  • Is the title of the Pull Request correct?
  • Is the title of the corresponding issue correct?
  • Have you updated the changelog?
  • Have you checked to ensure there aren't other open Pull Requests for the same update/change?
  • Are you mentioning the issue which this PullRequest fixes ("Fixes...")
  • Before you merge don't forget to run tests in AWS CodeBuild, by adding [CodeBuild] to the commit message

@ahsimb ahsimb requested a review from tkilias December 1, 2023 14:06
@ahsimb ahsimb self-assigned this Dec 1, 2023

deployer.upload_container = MagicMock()
deployer.activate_container = MagicMock()
deployer.get_language_settings = MagicMock()
Copy link
Collaborator

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

Copy link
Collaborator

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.

Copy link
Collaborator

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, ""))
Copy link
Collaborator

@tkilias tkilias Dec 1, 2023

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.

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,
Copy link
Collaborator

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,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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()
Copy link
Collaborator

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.

@ahsimb
Copy link
Collaborator Author

ahsimb commented Dec 7, 2023

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+\}'
Copy link
Collaborator

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():
Copy link
Collaborator

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}}'
Copy link
Collaborator

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

Copy link
Collaborator

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} .

@ahsimb
Copy link
Collaborator Author

ahsimb commented Dec 11, 2023

This is just an explanation of a generic usage. We currently don't have a use case with more than 1 parameter.

@ahsimb ahsimb merged commit e736b42 into main Dec 11, 2023
3 checks passed
@ahsimb ahsimb deleted the refactoring/159-prepare-deployment-migration branch December 11, 2023 14:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Refactoring LanguageContainer Deployer to make it reusable by other extensions
2 participants