Skip to content

feat: add preparation space check step to fail fast - #122

Open
MRGuziX wants to merge 3 commits into
mainfrom
feat/add-search-space-validation
Open

feat: add preparation space check step to fail fast#122
MRGuziX wants to merge 3 commits into
mainfrom
feat/add-search-space-validation

Conversation

@MRGuziX

@MRGuziX MRGuziX commented Aug 6, 2026

Copy link
Copy Markdown
Collaborator

Description

We should fail fast when it come to the checking of space_preparation step, right now user can launch experiment that will take hours, and after that we will show him info "yo, your model is wrong" he cannot re-trigger it with a changed config, he cannot do anything to save hours of computing. So we need to fail fast to give him info that his provided input is "ok" or "nook"

Motivation

https://redhat.atlassian.net/browse/RHOAIENG-57709

Changes

  1. ai4rag/utils/validators.py — added validate_model_list() function (moved from search_space_preparation.py)
  2. ai4rag/components/optimization/search_space_preparation.py —
    - Imports validate_model_list from shared location + AI4RAGSearchSpace
    - Adds _validate_model_list = validate_model_list alias for backward compat
    - Adds pre_validated_search_space: AI4RAGSearchSpace | None = None parameter to prepare_search_space_report()
    - When provided: skips model validation, payload construction, and prepare_search_space_with_ogx() call
    - When None: existing behavior unchanged
  3. tests/unit/ai4rag/components/optimization/test_search_space_prep.py —
    - Added TestValidateModelListShared (verifies alias identity)
    - Added TestPrepareSearchSpaceReportPreValidated with 3 tests: skips OGX call, uses provided search space, still loads documents

Testing

  • created dev image
  • pushed it to quay
  • use url in pipeline.yaml
  • run a test with changed image
  • Step passed - failed it is that there is ai4rag 0.11 and PLC do not have that image yet so it failed last step
image

Checklist

  • Tests added/updated
  • Documentation updated
  • Code follows style guide
  • All checks passing

3 files modified:
  1. ai4rag/utils/validators.py — added validate_model_list() function (moved from search_space_preparation.py)
  2. ai4rag/components/optimization/search_space_preparation.py —
    - Imports validate_model_list from shared location + AI4RAGSearchSpace
    - Adds _validate_model_list = validate_model_list alias for backward compat
    - Adds pre_validated_search_space: AI4RAGSearchSpace | None = None parameter to prepare_search_space_report()
    - When provided: skips model validation, payload construction, and prepare_search_space_with_ogx() call
    - When None: existing behavior unchanged
  3. tests/unit/ai4rag/components/optimization/test_search_space_prep.py —
    - Added TestValidateModelListShared (verifies alias identity)
    - Added TestPrepareSearchSpaceReportPreValidated with 3 tests: skips OGX call, uses provided search space, still loads documents

Signed-off-by: Tomasz Guzik <tguzik@redhat.com>
@MRGuziX MRGuziX changed the title feat: feat: add preparation space check step to fail fast Aug 6, 2026
MRGuziX added 2 commits August 6, 2026 07:36
Signed-off-by: Tomasz Guzik <tguzik@redhat.com>
Signed-off-by: Tomasz Guzik <tguzik@redhat.com>
@MRGuziX
MRGuziX marked this pull request as ready for review August 6, 2026 09:06
return value


def validate_model_list(models: list[str] | None, name: str) -> None:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure if this is the right place for this function. Maybe, let's leave it in ai4rag/components/optimization/search_space_preparation.py

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MRGuziX Could you address this comment? Thanks

pre_validated_search_space
When provided, the function skips model-list validation,
payload construction, and the
:func:`prepare_search_space_with_ogx` call and uses this

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
:func:`prepare_search_space_with_ogx` call and uses this
`prepare_search_space_with_ogx` call and uses this

The markup :func:prepare_search_space_with_ogx is Sphinx reStructuredText (rst) syntax. Let's use sth closer to google style.

@jakub-walaszczyk

Copy link
Copy Markdown
Collaborator

@MRGuziX what about this PR? Is this valid?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants