Skip to content

Commit 27e7f9a

Browse files
refactor(dataset): move business logic to from CLI to service. (#204)
* refactor(dataset): move business logic to from CLI to service. * feat(application): support download of results for input items where external_ids points to GCP bucket or webserver. * feat(application): scrollable runs in sidebar with auto-refresh and notifier on run terminated
1 parent a1f909f commit 27e7f9a

File tree

14 files changed

+1278
-482
lines changed

14 files changed

+1278
-482
lines changed

.github/workflows/build-native-only.yml

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,29 @@ jobs:
3939
echo "$COMMIT_MESSAGE" >> $GITHUB_OUTPUT
4040
echo "EOF" >> $GITHUB_OUTPUT
4141
42-
only_build_native:
42+
check-trigger-condition:
43+
runs-on: ubuntu-latest
4344
needs: get-commit-message
44-
if: |
45-
contains(needs.get-commit-message.outputs.commit_message, 'build:native:only') ||
46-
contains(github.event.pull_request.labels.*.name, 'build:native:only')
45+
permissions:
46+
contents: read
47+
outputs:
48+
should_run: ${{ steps.check.outputs.should_run }}
49+
steps:
50+
- name: Check if workflow should run
51+
id: check
52+
run: |
53+
if [[ "${{ contains(needs.get-commit-message.outputs.commit_message, 'build:native:only') }}" == "true" ]] || \
54+
[[ "${{ contains(github.event.pull_request.labels.*.name, 'build:native:only') }}" == "true" ]]; then
55+
echo "should_run=true" >> $GITHUB_OUTPUT
56+
echo "✅ Workflow triggered: Found 'build:native:only' in commit message or PR labels"
57+
else
58+
echo "should_run=false" >> $GITHUB_OUTPUT
59+
echo "⏭️ Workflow skipped: 'build:native:only' not found in commit message or PR labels"
60+
fi
61+
62+
only_build_native:
63+
needs: [get-commit-message, check-trigger-condition]
64+
if: needs.check-trigger-condition.outputs.should_run == 'true'
4765
uses: ./.github/workflows/_build-native-only.yml
4866
permissions:
4967
attestations: write

src/aignostics/application/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
"""Application module."""
22

33
from ._cli import cli
4+
from ._models import DownloadProgress, DownloadProgressState
45
from ._service import Service
56
from ._settings import Settings
67

7-
__all__ = ["Service", "Settings", "cli"]
8+
__all__ = ["DownloadProgress", "DownloadProgressState", "Service", "Settings", "cli"]
89

910
from importlib.util import find_spec
1011

src/aignostics/application/_cli.py

Lines changed: 37 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
from aignostics.platform import NotFoundException, RunState
1414
from aignostics.utils import console, get_logger, get_user_data_directory, sanitize_path
1515

16-
from ._service import DownloadProgress, DownloadProgressState, Service
16+
from ._models import DownloadProgress, DownloadProgressState
17+
from ._service import Service
1718
from ._utils import (
1819
application_run_status_to_str,
1920
get_mime_type_for_artifact,
@@ -903,7 +904,7 @@ def result_download( # noqa: C901, PLR0913, PLR0915, PLR0917
903904
with Live(panel):
904905
main_task = main_download_progress_ui.add_task(description="", total=None, extra_description="")
905906

906-
def update_progress(progress: DownloadProgress) -> None:
907+
def update_progress(progress: DownloadProgress) -> None: # noqa: C901
907908
"""Update progress bar for file downloads."""
908909
if progress.run:
909910
panel.title = (
@@ -920,18 +921,43 @@ def update_progress(progress: DownloadProgress) -> None:
920921
panel.subtitle += f", status: {status_text} ({progress.run.termination_reason})."
921922
else:
922923
panel.subtitle += f", status: {application_run_status_to_str(progress.run.state)}."
924+
# Determine the status message based on progress state
925+
if progress.status is DownloadProgressState.DOWNLOADING_INPUT:
926+
status_message = (
927+
f"Downloading input slide {progress.item_index + 1} of {progress.item_count}"
928+
if progress.item_index is not None and progress.item_count
929+
else "Downloading input slide ..."
930+
)
931+
elif progress.status is DownloadProgressState.DOWNLOADING and progress.total_artifact_index is not None:
932+
status_message = (
933+
f"Downloading artifact {progress.total_artifact_index + 1} of {progress.total_artifact_count}"
934+
)
935+
else:
936+
status_message = progress.status
937+
923938
main_download_progress_ui.update(
924939
main_task,
925-
description=(
926-
progress.status
927-
if progress.status is not DownloadProgressState.DOWNLOADING or not progress.total_artifact_index
928-
else (
929-
f"Downloading artifact {progress.total_artifact_index + 1} "
930-
f"of {progress.total_artifact_count}"
931-
)
932-
).ljust(50),
940+
description=status_message.ljust(50),
933941
)
934-
if progress.artifact_path:
942+
# Handle input slide download progress
943+
if progress.status is DownloadProgressState.DOWNLOADING_INPUT and progress.input_slide_path:
944+
task_key = str(progress.input_slide_path.absolute())
945+
if task_key not in download_tasks:
946+
download_tasks[task_key] = artifact_download_progress_ui.add_task(
947+
f"{progress.input_slide_path.name}".ljust(50),
948+
total=progress.input_slide_size,
949+
extra_description=f"Input from {progress.input_slide_url or 'gs://'}"
950+
if progress.input_slide_url
951+
else "Input slide",
952+
)
953+
954+
artifact_download_progress_ui.update(
955+
download_tasks[task_key],
956+
total=progress.input_slide_size,
957+
advance=progress.input_slide_downloaded_chunk_size,
958+
)
959+
# Handle artifact download progress
960+
elif progress.artifact_path:
935961
task_key = str(progress.artifact_path.absolute())
936962
if task_key not in download_tasks:
937963
download_tasks[task_key] = artifact_download_progress_ui.add_task(

0 commit comments

Comments
 (0)