-
Notifications
You must be signed in to change notification settings - Fork 3k
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
[FAST_BUILD] Refactor tagging: create functions, better logs and names, textwrap.d… #2239
Conversation
@@ -15,9 +15,6 @@ | |||
|
|||
|
|||
def apply_tags(config: Config) -> None: | |||
""" |
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.
These docstrings are not helpful (especially in apps), and not consistent at all
@@ -28,6 +25,8 @@ def apply_tags(config: Config) -> None: | |||
LOGGER.info(f"Applying tag: {tag}") | |||
docker["tag", config.full_image(), tag] & plumbum.FG | |||
|
|||
LOGGER.info(f"All tags applied to image: {config.image}") |
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.
Tried to add it everywhere so looks are more meaningful
LOGGER.info(f"Merging tags for image: {config.image}") | ||
|
||
all_tags: set[str] = set() | ||
def read_tags_from_files(config: Config) -> set[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.
Separate function makes it more understandable
config: Config, filename: str, all_tags: list[str] | ||
) -> None: | ||
LOGGER.info("Appending build history line") | ||
def get_build_history_line(config: Config, filename: str, container: Container) -> 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.
The idea is that get-like functions are more testable.
And we don't mix writing to files and creating file content
from tagging.manifests.manifest_interface import ManifestInterface | ||
|
||
|
||
def get_manifests(image: str | None) -> list[ManifestInterface]: |
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.
After this refactoring, there is no need to have both taggers and manifests in the same place.
So, it's better to have 2 functions.
Their implementation is similar, but that's ok
@@ -1,5 +1,7 @@ | |||
# Copyright (c) Jupyter Development Team. | |||
# Distributed under the terms of the Modified BSD License. | |||
import textwrap |
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.
Makes the code a bit easier to read
…edent
Describe your changes
Issue ticket if applicable
Checklist (especially for first-time contributors)