|
15 | 15 | import logging |
16 | 16 | from pathlib import Path |
17 | 17 |
|
| 18 | +import sorter as sorter_module |
18 | 19 | from constants import ( |
19 | 20 | AVAILABLE_IMAGES_TABLE_HEADER, |
20 | 21 | GLOBAL_CONFIG, |
|
34 | 35 | sort_by_version, |
35 | 36 | ) |
36 | 37 | from jinja2 import Template |
37 | | -from sorter import accelerator_sorter, platform_sorter, repository_sorter |
38 | 38 | from utils import ( |
39 | 39 | get_framework_order, |
40 | 40 | load_jinja2, |
|
44 | 44 | write_output, |
45 | 45 | ) |
46 | 46 |
|
| 47 | +DEFAULT_TIEBREAKERS = [sorter_module.platform_sorter, sorter_module.accelerator_sorter] |
| 48 | + |
| 49 | + |
47 | 50 | LOGGER = logging.getLogger(__name__) |
48 | 51 |
|
49 | 52 |
|
@@ -100,7 +103,11 @@ def _generate_framework_index( |
100 | 103 | for version in sorted_versions: |
101 | 104 | sorted_images = sort_by_version( |
102 | 105 | images_by_version[version], |
103 | | - tiebreakers=[repository_sorter, platform_sorter, accelerator_sorter], |
| 106 | + tiebreakers=[ |
| 107 | + sorter_module.repository_sorter, |
| 108 | + sorter_module.platform_sorter, |
| 109 | + sorter_module.accelerator_sorter, |
| 110 | + ], |
104 | 111 | ) |
105 | 112 |
|
106 | 113 | supported = [img for img in sorted_images if img.is_supported] |
@@ -290,8 +297,14 @@ def generate_available_images(dry_run: bool = False) -> str: |
290 | 297 | columns = table_config.get("columns", []) |
291 | 298 | has_public_registry = check_public_registry(images, repository) |
292 | 299 |
|
293 | | - # Sort images by version desc, platform, accelerator |
294 | | - images = sort_by_version(images, tiebreakers=[platform_sorter, accelerator_sorter]) |
| 300 | + # Sort images by version desc with tiebreakers from config or defaults |
| 301 | + tiebreaker_names = table_config.get("tiebreakers") |
| 302 | + tiebreakers = ( |
| 303 | + [getattr(sorter_module, name) for name in tiebreaker_names] |
| 304 | + if tiebreaker_names |
| 305 | + else DEFAULT_TIEBREAKERS |
| 306 | + ) |
| 307 | + images = sort_by_version(images, tiebreakers=tiebreakers) |
295 | 308 |
|
296 | 309 | # Build table |
297 | 310 | headers = [col["header"] for col in columns] |
|
0 commit comments