diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 0a79d595bf..62d40d3d75 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -38,11 +38,13 @@ jobs: - run: | python -m pip install --upgrade pip pip install --upgrade setuptools - pip install -r requirements/_requirements.txt -r requirements/requirements.cpu.txt -r requirements/requirements.sdk.http.txt -r requirements/requirements.test.unit.txt -r requirements/requirements.http.txt + pip install -r requirements/_requirements.txt -r requirements/requirements.cpu.txt -r requirements/requirements.sdk.http.txt -r requirements/requirements.test.unit.txt -r requirements/requirements.test.integration.txt -r requirements/requirements.http.txt working-directory: ./inference_repo - run: pip install . working-directory: ./roboflow_enterprise_blocks - - run: python -m development.docs.build_block_docs + - run: | + python -m development.docs.build_block_docs + python -m development.docs.workflows_gallery_builder working-directory: ./inference_repo - run: mkdocs gh-deploy --force working-directory: ./inference_repo diff --git a/.gitignore b/.gitignore index 499d5c8748..cc2600b0dd 100644 --- a/.gitignore +++ b/.gitignore @@ -165,6 +165,7 @@ scratch !tests/inference/unit_tests/core/utils/assets/*.jpg docs/workflows/blocks/* docs/workflows/kinds/* +docs/workflows/gallery/* !tests/workflows/integration_tests/execution/assets/*.jpg !tests/workflows/integration_tests/execution/assets/rock_paper_scissors/*.jpg !tests/workflows/unit_tests/core_steps/models/third_party/assets/*.png diff --git a/development/docs/__init__.py b/development/docs/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/development/docs/workflows_gallery_builder.py b/development/docs/workflows_gallery_builder.py new file mode 100644 index 0000000000..871a5ed8a1 --- /dev/null +++ b/development/docs/workflows_gallery_builder.py @@ -0,0 +1,147 @@ +import json +import os +from collections import defaultdict +from typing import List, Dict, Optional + +import pytest + +from tests.workflows.integration_tests.execution.workflows_gallery_collector.decorators import GALLERY_ENTRIES, \ + WorkflowGalleryEntry + +INTEGRATION_TESTS_DIRECTORY = os.path.abspath(os.path.join( + os.path.dirname(__file__), + "..", + "..", + "tests/workflows/integration_tests/execution" +)) +DOCS_ROOT = os.path.abspath(os.path.join( + os.path.dirname(__file__), + "..", + "..", + "docs" +)) +WORKFLOWS_DOCS_ROOT_PATH = os.path.join(DOCS_ROOT, "workflows") + +GALLERY_INDEX_PATH = os.path.join(WORKFLOWS_DOCS_ROOT_PATH, "gallery_index.md") +GALLERY_DIR_PATH = os.path.join(WORKFLOWS_DOCS_ROOT_PATH, "gallery") + + +def generate_gallery() -> None: + run_pytest_collection_to_fill_workflows_gallery() + categorised_gallery = categorise_gallery(gallery=GALLERY_ENTRIES) + generate_gallery_index(categories=list(categorised_gallery.keys())) + for category, entries in categorised_gallery.items(): + generate_gallery_page_for_category(category=category, entries=entries) + + +def run_pytest_collection_to_fill_workflows_gallery() -> None: + pytest.main(["--collect-only", INTEGRATION_TESTS_DIRECTORY]) + + +def categorise_gallery(gallery: List[WorkflowGalleryEntry]) -> Dict[str, List[WorkflowGalleryEntry]]: + result = defaultdict(list) + for item in gallery: + result[item.category].append(item) + return result + + +def generate_gallery_index(categories: List[str]) -> None: + index = read_file(path=GALLERY_INDEX_PATH) + index_lines = index.split("\n") + list_start_index = find_line_with_marker(lines=index_lines, marker='") + if list_start_index is None or list_end_index is None: + raise RuntimeError("Could not find expected