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

[FAST_BUILD] Refactor tagging: create functions, better logs and names, textwrap.d… #2239

Merged
merged 1 commit into from
Feb 23, 2025

Conversation

mathbunnyru
Copy link
Member

…edent

Describe your changes

Issue ticket if applicable

Checklist (especially for first-time contributors)

  • I have performed a self-review of my code
  • If it is a core feature, I have added thorough tests
  • I will try not to use force-push to make the review process easier for reviewers
  • I have updated the documentation for significant changes

@@ -15,9 +15,6 @@


def apply_tags(config: Config) -> None:
"""
Copy link
Member Author

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}")
Copy link
Member Author

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]:
Copy link
Member Author

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:
Copy link
Member Author

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]:
Copy link
Member Author

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
Copy link
Member Author

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

@mathbunnyru mathbunnyru merged commit 123d215 into jupyter:main Feb 23, 2025
40 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant