Skip to content

Commit

Permalink
add clear plan parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
antheas committed Aug 4, 2024
1 parent 7bcb8a4 commit abda1e0
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 6 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/online_test_deck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:
description: 'The ref tag to bundle'
required: true
prev:
description: 'Use previous ref'
description: 'Use previous plan'
type: boolean
default: true
latest:
Expand Down Expand Up @@ -38,7 +38,8 @@ jobs:
uses: ./.
with:
ref: 'ghcr.io/ublue-os/bazzite-deck:${{ github.event.inputs.ref }}'
prev-ref: ${{ github.event.inputs.prev == 'true' && 'ghcr.io/hhd-dev/bazzite-automated-deck:stable' || '' }}
prev-ref: ghcr.io/hhd-dev/bazzite-automated-deck:stable
clear-plan: ${{ github.event.inputs.prev == 'true' && '' || '1' }}
rechunk: 'ghcr.io/hhd-dev/rechunk:latest'
version: 'rc${{ github.event.inputs.ref }}'
revision: ${{ github.sha }}
Expand Down
3 changes: 3 additions & 0 deletions 3_chunk.sh
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ fi
if [ -n "$REVISION" ]; then
PREV_ARG+=("--revision" "$REVISION")
fi
if [ -n "$CLEAR_PLAN" ]; then
PREV_ARG+=("--clear-plan")
fi

LABEL_ARR=()
if [ -n "$LABELS" ]; then
Expand Down
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ inputs:
description: |
The previous image reference, if any. Used for versioning
the current image and to avoid layer shifts (important; may be skipped).
clear-plan:
description: |
If set, a new plan will be recreated.
prev-ref-fail:
description: |
If set, fail if the previous image reference is not found.
Expand Down Expand Up @@ -169,6 +172,7 @@ runs:
-e CHANGELOG="${{ inputs.changelog }}" \
-e OUT_REF="oci:$OUT_NAME" \
-e GIT_DIR="/var/git" \
-e CLEAR_PLAN="${{ inputs.clear-plan }}" \
-e REVISION="${{ inputs.revision }}" \
-e PREV_REF_FAIL="${{ inputs.prev-ref-fail }}" \
-u 0:0 \
Expand Down
6 changes: 6 additions & 0 deletions src/rechunk/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,11 @@ def argparse_func():
help="A debug file with the file packaging results.",
default=None,
)
parser.add_argument(
"--clear-plan",
help="Use a fresh plan, regardless of previous ref.",
action="store_true",
)

# Hyperparameters
group = parser.add_argument_group("Hyperparameters")
Expand Down Expand Up @@ -139,6 +144,7 @@ def argparse_func():
git_dir=args.git_dir,
changelog=args.changelog,
changelog_fn=args.changelog_fn,
clear_plan=args.clear_plan,
)


Expand Down
12 changes: 8 additions & 4 deletions src/rechunk/alg.py
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,7 @@ def main(
git_dir: str | None = None,
changelog: str | None = None,
changelog_fn: str | None = None,
clear_plan: bool = False,
):
if not meta_fn:
meta_fn = get_default_meta_yaml()
Expand Down Expand Up @@ -609,6 +610,8 @@ def main(
logger.info(f"Update matrix shape: {upd_matrix.shape}.")

found_previous_plan = False
manifest_json = None
info = None
if previous_manifest:
try:
logger.info("Loading existing layer data.")
Expand All @@ -619,10 +622,11 @@ def main(
except Exception as e:
logger.error(f"Error loading previous manifest:\n{e}")

if not found_previous_plan:
manifest_json = None
info = None
logger.warning("No existing layer data. Expect layer shifts")
if not found_previous_plan or clear_plan:
if clear_plan:
logger.warning("Creating a fresh plan due to --clear-plan.")
else:
logger.warning("No existing layer data. Expect layer shifts")
todo, dedi_layers, prefill = prefill_layers(
new_packages, upd_matrix, max_layers, prefill_size
)
Expand Down

0 comments on commit abda1e0

Please sign in to comment.