Skip to content

Commit 321e87c

Browse files
committed
Add test pipeline generator workflow and bump version to 1.0.0
- Introduced a new GitHub Actions workflow for testing the pipeline generator, including steps for setting up Python 3.10, installing dependencies, and running tests. - Updated the version of the pipeline-generator package from 0.1.0 to 1.0.0 in the uv.lock file. - Refactored import statements and improved code formatting in various files for better readability and consistency. Signed-off-by: Victor Chang <[email protected]>
1 parent 30b7799 commit 321e87c

File tree

19 files changed

+69
-29
lines changed

19 files changed

+69
-29
lines changed

.github/workflows/pr.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,20 @@ jobs:
5555
with:
5656
fail_ci_if_error: false
5757
files: ./coverage.xml
58+
59+
test-pipeline-generator:
60+
runs-on: ubuntu-latest
61+
steps:
62+
- uses: actions/checkout@v2
63+
- name: Set up Python 3.10
64+
uses: actions/setup-python@v2
65+
with:
66+
python-version: "3.10"
67+
- name: Install uv
68+
uses: astral-sh/setup-uv@v6
69+
- name: Install dependencies
70+
run: |
71+
uv sync
72+
- name: Run tests
73+
run: |
74+
uv run pytest

tools/pipeline-generator/pipeline_generator/cli/main.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,18 @@
1313

1414
import logging
1515
from pathlib import Path
16-
from typing import Optional, List, Set
16+
from typing import List, Optional, Set
17+
1718
import click
1819
from rich.console import Console
19-
from rich.table import Table
2020
from rich.logging import RichHandler
21+
from rich.table import Table
2122

2223
from ..config import load_config
2324
from ..core import HuggingFaceClient, ModelInfo
2425
from ..generator import AppGenerator
2526
from .run import run as run_command
2627

27-
2828
# Set up logging with Rich
2929
logging.basicConfig(
3030
level=logging.INFO,

tools/pipeline-generator/pipeline_generator/config/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@
1111

1212
"""Configuration module for Pipeline Generator."""
1313

14-
from .settings import Settings, Endpoint, load_config
14+
from .settings import Endpoint, Settings, load_config
1515

1616
__all__ = ["Settings", "Endpoint", "load_config"]

tools/pipeline-generator/pipeline_generator/core/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
"""Core functionality for Pipeline Generator."""
1313

14-
from .models import ModelInfo
1514
from .hub_client import HuggingFaceClient
15+
from .models import ModelInfo
1616

1717
__all__ = ["ModelInfo", "HuggingFaceClient"]

tools/pipeline-generator/pipeline_generator/core/hub_client.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,14 @@
1111

1212
"""HuggingFace Hub client for fetching model information."""
1313

14-
from typing import List, Optional, Any
1514
import logging
15+
from typing import Any, List, Optional
1616

17-
from huggingface_hub import HfApi, model_info, list_models
17+
from huggingface_hub import HfApi, list_models, model_info
1818
from huggingface_hub.utils import HfHubHTTPError
1919

20-
from .models import ModelInfo
2120
from ..config import Endpoint
22-
21+
from .models import ModelInfo
2322

2423
logger = logging.getLogger(__name__)
2524

tools/pipeline-generator/pipeline_generator/core/models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"""Data models for Pipeline Generator."""
1313

1414
from datetime import datetime
15-
from typing import List, Optional, Dict, Any
15+
from typing import Any, Dict, List, Optional
1616

1717
from pydantic import BaseModel, Field
1818

tools/pipeline-generator/pipeline_generator/generator/app_generator.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,12 @@
1313

1414
import logging
1515
from pathlib import Path
16-
from typing import Dict, Any, Optional
16+
from typing import Any, Dict, Optional
17+
1718
from jinja2 import Environment, FileSystemLoader
1819

19-
from .bundle_downloader import BundleDownloader
2020
from ..config.settings import Settings, load_config
21+
from .bundle_downloader import BundleDownloader
2122

2223
logger = logging.getLogger(__name__)
2324

@@ -40,6 +41,7 @@ def __init__(self, settings: Optional[Settings] = None) -> None:
4041
loader=FileSystemLoader(str(template_dir)),
4142
trim_blocks=True,
4243
lstrip_blocks=True,
44+
autoescape=False,
4345
)
4446

4547
def generate_app(

tools/pipeline-generator/pipeline_generator/generator/bundle_downloader.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@
1111

1212
"""Download MONAI Bundles from HuggingFace."""
1313

14-
import logging
1514
import json
15+
import logging
1616
from pathlib import Path
17-
from typing import Optional, Dict, Any
17+
from typing import Any, Dict, Optional
1818

19-
from huggingface_hub import snapshot_download, HfApi
19+
from huggingface_hub import HfApi, snapshot_download
2020

2121
logger = logging.getLogger(__name__)
2222

tools/pipeline-generator/pipeline_generator/templates/app.py.j2

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,43 +26,56 @@ from pathlib import Path
2626
from pydicom.sr.codedict import codes
2727

2828
from monai.deploy.conditions import CountCondition
29+
2930
{% endif %}
3031
from monai.deploy.core import AppContext, Application
3132
from monai.deploy.core.domain import Image
3233
from monai.deploy.core.io_type import IOType
34+
3335
{% if use_dicom %}
3436
from monai.deploy.operators.dicom_data_loader_operator import DICOMDataLoaderOperator
3537
from monai.deploy.operators.dicom_seg_writer_operator import DICOMSegmentationWriterOperator, SegmentDescription
3638
from monai.deploy.operators.dicom_series_selector_operator import DICOMSeriesSelectorOperator
3739
from monai.deploy.operators.dicom_series_to_volume_operator import DICOMSeriesToVolumeOperator
40+
3841
{% if 'segmentation' in task.lower() %}
3942
from monai.deploy.operators.stl_conversion_operator import STLConversionOperator
43+
4044
{% endif %}
4145
{% elif input_type == "image" %}
4246
from monai.deploy.operators.image_directory_loader_operator import ImageDirectoryLoader
47+
4348
{% elif input_type == "custom" %}
49+
from monai.deploy.operators.llama3_vila_inference_operator import Llama3VILAInferenceOperator
50+
4451
# Custom operators for vision-language models
4552
from monai.deploy.operators.prompts_loader_operator import PromptsLoaderOperator
46-
from monai.deploy.operators.llama3_vila_inference_operator import Llama3VILAInferenceOperator
4753
from monai.deploy.operators.vlm_results_writer_operator import VLMResultsWriterOperator
54+
4855
{% else %}
4956
from monai.deploy.operators.nifti_directory_loader_operator import NiftiDirectoryLoader
57+
5058
{% endif %}
5159
{% if output_type == "json" %}
5260
from monai.deploy.operators.json_results_writer_operator import JSONResultsWriter
61+
5362
{% elif output_type == "image_overlay" %}
5463
from monai.deploy.operators.image_overlay_writer_operator import ImageOverlayWriter
64+
5565
{% elif not use_dicom %}
5666
from monai.deploy.operators.nifti_writer_operator import NiftiWriter
67+
5768
{% endif %}
5869
{% if "classification" in task.lower() and input_type == "image" %}
5970
from monai.deploy.operators.monai_classification_operator import MonaiClassificationOperator
71+
6072
{% elif not (input_type == "custom" and output_type == "custom") %}
6173
from monai.deploy.operators.monai_bundle_inference_operator import (
6274
BundleConfigNames,
6375
IOMapping,
6476
MonaiBundleInferenceOperator,
6577
)
78+
6679
{% endif %}
6780

6881

tools/pipeline-generator/tests/test_bundle_downloader.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
from unittest.mock import patch
1616

1717
import pytest
18-
1918
from pipeline_generator.generator.bundle_downloader import BundleDownloader
2019

2120

0 commit comments

Comments
 (0)