Skip to content

Conversation

TylerZeroMaster
Copy link
Contributor

@TylerZeroMaster TylerZeroMaster commented Sep 10, 2025

https://openstax.atlassian.net/browse/CORE-1219

Summary via Gemini:

This diff shows several changes to a Python script and a few shell scripts related to a "bakery" system, which seems to process and build books. The main purpose of these changes is to introduce a new feature that identifies and processes only the latest version of a book based on its publication date.


Key Changes

The most significant change is the modification of the get_abl function in check_feed.py. Previously, it would sort all unique book entries by their commit date and return a list of {"repo": ..., "version": ...} pairs. The updated version now:

  • 🆕 Imports itertools.groupby: This new library is used to group the entries.
  • 🆕 Adds a "is_latest" flag: The script now groups books by repository_name and uuid to uniquely identify each book edition. It then sorts these groups by committed_at and determines which version is the most recent.
  • 🆕 Adds a metadata dictionary: The function now includes a new metadata key in the output, which contains the boolean flag is_latest. This flag indicates whether the current version of the book being processed is the most recent one.

Supporting Changes

  • Testing: The test file test_bakery_scripts.py has been updated to reflect the new metadata and is_latest key in the expected output, ensuring the new logic is correctly tested.
  • Shell Scripts: The dockerfiles have been updated to handle the new metadata and is_latest flag.
    • docker-entrypoint.sh: This script now reads the is_latest flag from a new metadata file. It also copies this metadata file into the working directory (edit: only when running on local).
    • git-dequeue-book.bash: This script now extracts and stores the metadata from the book's data feed into a new file.
    • step-upload-book.bash: This script now uses the ARG_IS_LATEST flag to conditionally upload ancillary files (like images or other supplementary materials), but only if the book being processed is the latest version. This prevents unnecessary uploads of older book editions versions.

Summary

In short, these changes introduce a new mechanism to track the latest version of a book within the system. Instead of simply processing all unique book entries, the system now identifies the most recent version of each book edition and uses this information to control subsequent actions, such as whether to upload ancillary files. This likely improves efficiency by avoiding redundant uploads for older book versions. 📚

Human note

This is required to avoid uploading two different versions of the same ancillary. We only care about the latest one. It is more efficient since we avoid excessive uploading, but the main goal was to only use the latest version.

@TylerZeroMaster TylerZeroMaster marked this pull request as ready for review September 10, 2025 20:12
@TylerZeroMaster TylerZeroMaster changed the title Core 1219 upload latest ancillary version CORE-1219 - upload latest ancillary version Sep 10, 2025
* Added `get_latest_code_version(api_root)` – fetches `/api/version/` and returns the JSON payload.
* Added `get_is_latest_code_version(api_root, code_version)` – compares the `tag` from the version endpoint to the supplied `code_version`.
* Updated `get_abl` to call the new helper and to set `metadata["is_latest"]` only when the code version is the latest **and** the commit SHA matches the expected latest commit.
* Refactored tests:
  * Introduced `MockJsonResponse` and `MockApi` to stub both `/api/abl` and `/api/version` endpoints.
  * Adjusted expected `is_latest` values to match the new logic.
  * Updated mock responses to include version information.

This change ensures that the pipeline only marks a book as the latest when the build’s code version is actually the most recent, preventing stale data from being uploaded.
I must have forgotten to remove it somehow
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