Skip to content
26 changes: 22 additions & 4 deletions .github/workflows/build-native-only.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,29 @@ jobs:
echo "$COMMIT_MESSAGE" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT

only_build_native:
check-trigger-condition:
runs-on: ubuntu-latest
needs: get-commit-message
if: |
contains(needs.get-commit-message.outputs.commit_message, 'build:native:only') ||
contains(github.event.pull_request.labels.*.name, 'build:native:only')
permissions:
contents: read
outputs:
should_run: ${{ steps.check.outputs.should_run }}
steps:
- name: Check if workflow should run
id: check
run: |
if [[ "${{ contains(needs.get-commit-message.outputs.commit_message, 'build:native:only') }}" == "true" ]] || \
[[ "${{ contains(github.event.pull_request.labels.*.name, 'build:native:only') }}" == "true" ]]; then
echo "should_run=true" >> $GITHUB_OUTPUT
echo "✅ Workflow triggered: Found 'build:native:only' in commit message or PR labels"
else
echo "should_run=false" >> $GITHUB_OUTPUT
echo "⏭️ Workflow skipped: 'build:native:only' not found in commit message or PR labels"
fi

only_build_native:
needs: [get-commit-message, check-trigger-condition]
if: needs.check-trigger-condition.outputs.should_run == 'true'
uses: ./.github/workflows/_build-native-only.yml
permissions:
attestations: write
Expand Down
3 changes: 2 additions & 1 deletion src/aignostics/application/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
"""Application module."""

from ._cli import cli
from ._models import DownloadProgress, DownloadProgressState
from ._service import Service
from ._settings import Settings

__all__ = ["Service", "Settings", "cli"]
__all__ = ["DownloadProgress", "DownloadProgressState", "Service", "Settings", "cli"]

from importlib.util import find_spec

Expand Down
48 changes: 37 additions & 11 deletions src/aignostics/application/_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
from aignostics.platform import NotFoundException, RunState
from aignostics.utils import console, get_logger, get_user_data_directory, sanitize_path

from ._service import DownloadProgress, DownloadProgressState, Service
from ._models import DownloadProgress, DownloadProgressState
from ._service import Service
from ._utils import (
application_run_status_to_str,
get_mime_type_for_artifact,
Expand Down Expand Up @@ -903,7 +904,7 @@ def result_download( # noqa: C901, PLR0913, PLR0915, PLR0917
with Live(panel):
main_task = main_download_progress_ui.add_task(description="", total=None, extra_description="")

def update_progress(progress: DownloadProgress) -> None:
def update_progress(progress: DownloadProgress) -> None: # noqa: C901
"""Update progress bar for file downloads."""
if progress.run:
panel.title = (
Expand All @@ -920,18 +921,43 @@ def update_progress(progress: DownloadProgress) -> None:
panel.subtitle += f", status: {status_text} ({progress.run.termination_reason})."
else:
panel.subtitle += f", status: {application_run_status_to_str(progress.run.state)}."
# Determine the status message based on progress state
if progress.status is DownloadProgressState.DOWNLOADING_INPUT:
status_message = (
f"Downloading input slide {progress.item_index + 1} of {progress.item_count}"
if progress.item_index is not None and progress.item_count
else "Downloading input slide ..."
)
elif progress.status is DownloadProgressState.DOWNLOADING and progress.total_artifact_index is not None:
status_message = (
f"Downloading artifact {progress.total_artifact_index + 1} of {progress.total_artifact_count}"
)
else:
status_message = progress.status

main_download_progress_ui.update(
main_task,
description=(
progress.status
if progress.status is not DownloadProgressState.DOWNLOADING or not progress.total_artifact_index
else (
f"Downloading artifact {progress.total_artifact_index + 1} "
f"of {progress.total_artifact_count}"
)
).ljust(50),
description=status_message.ljust(50),
)
if progress.artifact_path:
# Handle input slide download progress
if progress.status is DownloadProgressState.DOWNLOADING_INPUT and progress.input_slide_path:
task_key = str(progress.input_slide_path.absolute())
if task_key not in download_tasks:
download_tasks[task_key] = artifact_download_progress_ui.add_task(
f"{progress.input_slide_path.name}".ljust(50),
total=progress.input_slide_size,
extra_description=f"Input from {progress.input_slide_url or 'gs://'}"
if progress.input_slide_url
else "Input slide",
)

artifact_download_progress_ui.update(
download_tasks[task_key],
total=progress.input_slide_size,
advance=progress.input_slide_downloaded_chunk_size,
)
# Handle artifact download progress
elif progress.artifact_path:
task_key = str(progress.artifact_path.absolute())
if task_key not in download_tasks:
download_tasks[task_key] = artifact_download_progress_ui.add_task(
Expand Down
Loading
Loading