Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
137 commits
Select commit Hold shift + click to select a range
d127f41
ok
thomashebrard Oct 7, 2025
a9c4f8c
fix specialDOmain
thomashebrard Oct 9, 2025
62e6519
WIP Better explain migration errors
lchoquel Oct 9, 2025
aca2c6a
fix PipeExtract
thomashebrard Oct 9, 2025
e6bfa9d
WIP Distinct migration maps
lchoquel Oct 9, 2025
722cde0
Merge branch 'dev' into fix/api
thomashebrard Oct 9, 2025
8032274
conver info to debug log
thomashebrard Oct 9, 2025
86616a7
add pipeline_run_id
thomashebrard Oct 9, 2025
2d4ecc0
Better detect migrations, regroup hints
lchoquel Oct 10, 2025
ba81265
Cleaner and more specific setup errors
lchoquel Oct 10, 2025
b2c48c6
Improve error messages
lchoquel Oct 10, 2025
459b684
Rename pipe category
lchoquel Oct 10, 2025
a9c56eb
Finish rename pipe category
lchoquel Oct 10, 2025
9175dac
fix ut
thomashebrard Oct 10, 2025
da2354a
Fix UT
lchoquel Oct 10, 2025
df14214
Move UT to correct place
lchoquel Oct 10, 2025
d694579
Add UTs for pipe controllers
lchoquel Oct 10, 2025
7d1f750
Changelog
lchoquel Oct 11, 2025
ebec94c
Changelog
lchoquel Oct 11, 2025
7fdca20
Update AGENTS.md and add MIGRATION.md
lchoquel Oct 12, 2025
a62d41e
All templating going through jinaj2, proper separation from template …
lchoquel Oct 12, 2025
7000cda
stop using toml directly in config manager
lchoquel Oct 12, 2025
73406de
stop using toml directly in interpreter.py
lchoquel Oct 12, 2025
7224dc3
Use tomli instead of toml package
lchoquel Oct 12, 2025
07c95a9
Cleanup unused dependencies
lchoquel Oct 12, 2025
1d06561
Changelog
lchoquel Oct 12, 2025
608b285
Cleanup
lchoquel Oct 12, 2025
2636729
Support having a space in dir path
lchoquel Oct 12, 2025
e446de3
Merge branch 'refactor/Makefile-improve' into refactor/Toml-support
lchoquel Oct 12, 2025
f76bc65
improve merge-check-pyright
lchoquel Oct 12, 2025
5c1ba55
Improve error messages
lchoquel Oct 12, 2025
59016fd
Completed MIGRATION.md
lchoquel Oct 12, 2025
a3c79b3
Prepare kit
lchoquel Oct 12, 2025
b66324f
WIP kit system
lchoquel Oct 12, 2025
60c170c
WIP kit
lchoquel Oct 12, 2025
60ebb5a
Cleanup before Kit
lchoquel Oct 12, 2025
7d67a81
Simpler heading 1
lchoquel Oct 12, 2025
13ee804
refactor Kit index
lchoquel Oct 12, 2025
b64885a
kit UT
lchoquel Oct 12, 2025
1fd9ac1
remove useless __init__.py from tests/
lchoquel Oct 12, 2025
9add8a5
No Base Library
lchoquel Oct 12, 2025
3d84cdb
Cleanup
lchoquel Oct 12, 2025
79eec68
Cleanup dry run errors
lchoquel Oct 12, 2025
23ecfa0
Fixed warnings
lchoquel Oct 12, 2025
6969203
Moved Builder, library is no more
lchoquel Oct 12, 2025
902c6b6
Avoid executing modules if they don't have StructuredContent classes
lchoquel Oct 12, 2025
94a4b2c
Avoid executing modules if they don't have decorated pipe_funcs
lchoquel Oct 12, 2025
372b2ec
Polish
lchoquel Oct 13, 2025
12dbc44
Better handle image prompts
lchoquel Oct 13, 2025
173c3fc
WIP fixing prompt image
lchoquel Oct 13, 2025
c634bbc
Fix image url / base 64 issues
lchoquel Oct 13, 2025
eff1a0f
Fix double base64 encoding bug on images
lchoquel Oct 13, 2025
7374f08
Cleanup and restore image features
lchoquel Oct 13, 2025
82827a5
Formatting
lchoquel Oct 13, 2025
c7d759d
kit migrations
lchoquel Oct 13, 2025
f864ed2
Merge branch 'fix/Debug-image-prompts' into docs/Update-docs-and-Migr…
lchoquel Oct 13, 2025
f64fda0
Remove untested code from migration guide
lchoquel Oct 13, 2025
583fbce
remove old stuff related to the pipelines library
lchoquel Oct 13, 2025
6f40143
More migration guiding (packages moved and renamed)
lchoquel Oct 13, 2025
5da479c
Remove build_flow_cmd (was just a test)
lchoquel Oct 13, 2025
01855a1
Reorg pip build commands
lchoquel Oct 13, 2025
53e62fe
Update rules
lchoquel Oct 13, 2025
b59ec19
Remove rules
lchoquel Oct 13, 2025
6f135d1
coding standards in other agent rules
lchoquel Oct 13, 2025
588e7ee
Updated docs
lchoquel Oct 14, 2025
ff96bce
Changelog
lchoquel Oct 14, 2025
3ccaea2
Docs about pipe_funcs and warnings
lchoquel Oct 14, 2025
8fa3f04
Pipe builder docs
lchoquel Oct 14, 2025
cd2f8f2
Update Quick Start
lchoquel Oct 14, 2025
b67502b
cookbook docs
lchoquel Oct 14, 2025
70c1f0e
Rules
lchoquel Oct 14, 2025
23cba07
config
lchoquel Oct 14, 2025
b0f001d
Cleanup pytest rules
lchoquel Oct 14, 2025
76715b0
Enable client projects to get pipes from Pipelex package, useful for …
lchoquel Oct 14, 2025
718e392
Fix finding the PLX from the Pipelex package (for Pipe Builder)
lchoquel Oct 14, 2025
bfa06dc
Use pkgutil.walk_packages to find structures and pipe_funcs in Pipele…
lchoquel Oct 14, 2025
53fd425
Add extensive logging for @pipe_func registration debugging
lchoquel Oct 14, 2025
fcb1c15
force registration of pipe funcs
lchoquel Oct 14, 2025
34e81eb
Cleanup - move code to util module
lchoquel Oct 14, 2025
f7151ff
Cleanup
lchoquel Oct 14, 2025
530d446
Cleanup logs
lchoquel Oct 14, 2025
6d2f96c
Cleanup redundant code
lchoquel Oct 14, 2025
89628d8
Remove useless arg
lchoquel Oct 14, 2025
cd3bc0a
Proofread agent rules
lchoquel Oct 14, 2025
80e80e6
More python standards
lchoquel Oct 14, 2025
0589fa8
ScanConfig to exclude directories from scanning.
lchoquel Oct 14, 2025
e99c6aa
Merge remote-tracking branch 'origin/fix/Access-to-builder-classes-an…
thomashebrard Oct 14, 2025
487254b
add codegen
thomashebrard Oct 14, 2025
accc95f
Merge branch 'dev' into demo-app
thomashebrard Oct 14, 2025
afa995b
Merge branch 'demo-app' into demo-app-2
thomashebrard Oct 14, 2025
d86654a
merge commit
thomashebrard Oct 14, 2025
af00c0f
add runner
thomashebrard Oct 14, 2025
e1be50d
fix cli
thomashebrard Oct 15, 2025
1162cc4
fix tests
thomashebrard Oct 15, 2025
ea59e31
ok
thomashebrard Oct 15, 2025
9db56ee
Merge branch 'dev' into demo-app
thomashebrard Oct 15, 2025
ba8214f
fix test
thomashebrard Oct 15, 2025
3122705
Merge branch 'demo-app' into demo-app-2
thomashebrard Oct 15, 2025
c541f5c
remove
thomashebrard Oct 15, 2025
87502ac
rollback test file
thomashebrard Oct 15, 2025
0642ddb
ok
thomashebrard Oct 15, 2025
991739c
11.2
thomashebrard Oct 15, 2025
b9f3dc3
bump
thomashebrard Oct 15, 2025
cd7cdc0
bump
thomashebrard Oct 15, 2025
d2ef66a
Merge branch 'dev' into demo-app
thomashebrard Oct 15, 2025
c0a6a54
Merge branch 'demo-app' into demo-app-2
thomashebrard Oct 16, 2025
f168144
Merge branch 'demo-app-2' into feature/library-per-run
thomashebrard Oct 16, 2025
b872a0d
ok
thomashebrard Oct 16, 2025
2f0e2f2
0.12.0
thomashebrard Oct 16, 2025
8c30f33
Merge branch 'demo-app' into demo-app-2
thomashebrard Oct 16, 2025
3551342
fix cocode
thomashebrard Oct 16, 2025
60bf36d
Merge branch 'fix/various-fixes-for-api' into feature/ready-to-run-py…
thomashebrard Oct 16, 2025
af38623
fix
thomashebrard Oct 16, 2025
1cd85bd
Merge branch 'fix/various-fixes-for-api' into feature/ready-to-run-py…
thomashebrard Oct 16, 2025
bab1637
Merge branch 'feature/ready-to-run-py-file' into feature/library-per-run
thomashebrard Oct 16, 2025
7b03343
fix library Manager
thomashebrard Oct 16, 2025
1c14c3c
fix UT
thomashebrard Oct 16, 2025
72d7e15
Merge branch 'fix/various-fixes-for-api' into feature/ready-to-run-py…
thomashebrard Oct 16, 2025
8b745c2
Merge branch 'feature/ready-to-run-py-file' into feature/library-per-run
thomashebrard Oct 16, 2025
0b5133b
fix libraries
thomashebrard Oct 16, 2025
bf8213e
Merge branch 'dev' into feature/ready-to-run-py-file
thomashebrard Oct 16, 2025
c94a435
fix
thomashebrard Oct 16, 2025
fe7eabc
fix cli
thomashebrard Oct 16, 2025
788f76d
update badge
thomashebrard Oct 16, 2025
72a3ad6
fix cli
thomashebrard Oct 16, 2025
bbddf3d
Merge branch 'feature/ready-to-run-py-file' into feature/library-per-run
thomashebrard Oct 16, 2025
750621a
ok
thomashebrard Oct 16, 2025
5ac55d9
move some code
thomashebrard Oct 16, 2025
bcbad09
Merge branch 'feature/ready-to-run-py-file' into feature/library-per-run
thomashebrard Oct 16, 2025
1f448bb
move around some files
thomashebrard Oct 16, 2025
336eb87
Merge branch 'feature/ready-to-run-py-file' into feature/library-per-run
thomashebrard Oct 16, 2025
ec3fc8c
fix almost all make cc
thomashebrard Oct 16, 2025
4cc39ae
ok
thomashebrard Oct 17, 2025
5b9450a
fix
thomashebrard Oct 17, 2025
71c3914
Merge branch 'dev' into feature/library-per-run
thomashebrard Oct 21, 2025
6f40bbf
ok
thomashebrard Oct 21, 2025
4bcb9dc
make cc
thomashebrard Oct 21, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions pipelex/builder/builder_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
StaticValidationError,
)
from pipelex.hub import get_library_manager
from pipelex.libraries.library_ids import SpecialLibraryId
from pipelex.pipe_run.dry_run import DryRunOutput, dry_run_pipes


Expand All @@ -41,7 +42,7 @@ async def validate_bundle_spec(bundle_spec: PipelexBundleSpec):

library_manager = get_library_manager()
dry_run_result = await dry_run_bundle_blueprint(bundle_blueprint=bundle_blueprint)
library_manager.remove_from_blueprint(blueprint=bundle_blueprint)
library_manager.remove_from_blueprints(library_id=SpecialLibraryId.UNTITLED, blueprints=[bundle_blueprint])

dry_run_pipe_failures = extract_pipe_failures_from_dry_run_result(bundle_spec=bundle_spec, dry_run_result=dry_run_result)
if dry_run_pipe_failures:
Expand Down Expand Up @@ -103,7 +104,7 @@ def document_pipe_failures_from_dry_run_blueprint(
async def dry_run_bundle_blueprint(bundle_blueprint: PipelexBundleBlueprint) -> dict[str, DryRunOutput]:
library_manager = get_library_manager()
try:
pipes = library_manager.load_from_blueprint(blueprint=bundle_blueprint)
pipes = library_manager.load_from_blueprints(library_id=SpecialLibraryId.UNTITLED, blueprints=[bundle_blueprint])
dry_run_result = await dry_run_pipes(pipes=pipes, raise_on_failure=True)
except StaticValidationError as static_validation_error:
static_validation_error_data = StaticValidationErrorData(
Expand Down
6 changes: 2 additions & 4 deletions pipelex/cli/commands/validate_cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,14 @@

def do_validate_all_libraries_and_dry_run() -> None:
"""Validate libraries and dry-run all pipes."""
pipelex_instance = Pipelex.make()
pipelex_instance.validate_libraries()
Pipelex.make()
asyncio.run(dry_run_pipes(pipes=get_pipes(), raise_on_failure=True))
log.info("Setup sequence passed OK, config and pipelines are validated.")


def do_dry_run_pipe(pipe_code: str) -> None:
"""Dry run a single pipe."""
pipelex_instance = Pipelex.make()
pipelex_instance.validate_libraries()
Pipelex.make()

asyncio.run(
dry_run_pipe(
Expand Down
2 changes: 1 addition & 1 deletion pipelex/core/stuffs/stuff_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
from pipelex.core.concepts.concept import Concept
from pipelex.core.concepts.concept_blueprint import ConceptBlueprint
from pipelex.core.concepts.concept_factory import ConceptFactory
from pipelex.core.concepts.concept_library import ConceptLibraryConceptNotFoundError
from pipelex.core.concepts.concept_native import NativeConceptCode
from pipelex.core.stuffs.list_content import ListContent
from pipelex.core.stuffs.structured_content import StructuredContent
Expand All @@ -16,6 +15,7 @@
from pipelex.core.stuffs.text_content import TextContent
from pipelex.exceptions import PipelexException
from pipelex.hub import get_class_registry, get_concept_library, get_native_concept, get_required_concept
from pipelex.libraries.concept.concept_library import ConceptLibraryConceptNotFoundError
from pipelex.tools.typing.pydantic_utils import format_pydantic_validation_error


Expand Down
64 changes: 33 additions & 31 deletions pipelex/hub.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@
from pipelex.cogt.models.model_deck import ModelDeck
from pipelex.cogt.models.model_manager_abstract import ModelManagerAbstract
from pipelex.core.concepts.concept import Concept
from pipelex.core.concepts.concept_library_abstract import ConceptLibraryAbstract
from pipelex.core.concepts.concept_native import NativeConceptCode
from pipelex.core.domains.domain import Domain
from pipelex.core.domains.domain_library_abstract import DomainLibraryAbstract
from pipelex.core.pipes.pipe_abstract import PipeAbstract
from pipelex.core.pipes.pipe_library_abstract import PipeLibraryAbstract
from pipelex.libraries.concept.concept_library_abstract import ConceptLibraryAbstract
from pipelex.libraries.domain.domain_library_abstract import DomainLibraryAbstract
from pipelex.libraries.library_ids import SpecialLibraryId
from pipelex.libraries.library_manager_abstract import LibraryManagerAbstract
from pipelex.libraries.pipe.pipe_library_abstract import PipeLibraryAbstract
from pipelex.observer.observer_protocol import ObserverProtocol
from pipelex.pipe_run.pipe_router_protocol import PipeRouterProtocol
from pipelex.pipeline.activity.activity_manager_protocol import ActivityManagerProtocol
from pipelex.pipeline.pipeline import Pipeline
from pipelex.pipeline.pipeline_manager_abstract import PipelineManagerAbstract
from pipelex.pipeline.track.pipeline_tracker_protocol import PipelineTrackerProtocol
from pipelex.plugins.plugin_manager import PluginManager
Expand Down Expand Up @@ -233,21 +233,27 @@ def get_required_content_generator(self) -> ContentGeneratorProtocol:

# pipelex

def get_required_domain_library(self) -> DomainLibraryAbstract:
def get_required_domain_library(self, library_id: str | None = None) -> DomainLibraryAbstract:
if self._library_manager is not None:
return self._library_manager.get_library(library_id=library_id).domain_library
if self._domain_library is None:
msg = "DomainLibrary is not initialized"
msg = "DomainLibrary with library_id '{library_id}' is not initialized"
raise RuntimeError(msg)
return self._domain_library

def get_required_concept_library(self) -> ConceptLibraryAbstract:
def get_required_concept_library(self, library_id: str | None = None) -> ConceptLibraryAbstract:
if self._library_manager is not None:
return self._library_manager.get_library(library_id=library_id).concept_library
if self._concept_library is None:
msg = "ConceptLibrary is not initialized"
msg = "ConceptLibrary with library_id '{library_id}' is not initialized"
raise RuntimeError(msg)
return self._concept_library

def get_required_pipe_library(self) -> PipeLibraryAbstract:
def get_required_pipe_library(self, library_id: str | None = None) -> PipeLibraryAbstract:
if self._library_manager is not None:
return self._library_manager.get_library(library_id=library_id).pipe_library
if self._pipe_library is None:
msg = "PipeLibrary is not initialized"
msg = "PipeLibrary with library_id '{library_id}' is not initialized"
raise RuntimeError(msg)
return self._pipe_library

Expand Down Expand Up @@ -372,36 +378,36 @@ def get_secret(secret_id: str) -> str:
return get_secrets_provider().get_secret(secret_id=secret_id)


def get_required_domain(domain: str) -> Domain:
return get_pipelex_hub().get_required_domain_library().get_required_domain(domain=domain)
def get_required_domain(domain: str, library_id: str | None = None) -> Domain:
return get_pipelex_hub().get_required_domain_library(library_id=library_id).get_required_domain(domain=domain)


def get_optional_domain(domain: str) -> Domain | None:
return get_pipelex_hub().get_required_domain_library().get_domain(domain=domain)
def get_optional_domain(domain: str, library_id: str | None = None) -> Domain | None:
return get_pipelex_hub().get_required_domain_library(library_id=library_id).get_domain(domain=domain)


def get_pipe_library() -> PipeLibraryAbstract:
return get_pipelex_hub().get_required_pipe_library()
def get_pipe_library(library_id: str | None = None) -> PipeLibraryAbstract:
return get_pipelex_hub().get_required_pipe_library(library_id=library_id)


def get_pipes() -> list[PipeAbstract]:
return get_pipelex_hub().get_required_pipe_library().get_pipes()
def get_pipes(library_id: str | None = None) -> list[PipeAbstract]:
return get_pipelex_hub().get_required_pipe_library(library_id=library_id).get_pipes()


def get_required_pipe(pipe_code: str) -> PipeAbstract:
return get_pipelex_hub().get_required_pipe_library().get_required_pipe(pipe_code=pipe_code)
def get_required_pipe(pipe_code: str, library_id: str | None = None) -> PipeAbstract:
return get_pipelex_hub().get_required_pipe_library(library_id=library_id).get_required_pipe(pipe_code=pipe_code)


def get_optional_pipe(pipe_code: str) -> PipeAbstract | None:
return get_pipelex_hub().get_required_pipe_library().get_optional_pipe(pipe_code=pipe_code)
def get_optional_pipe(pipe_code: str, library_id: str | None = None) -> PipeAbstract | None:
return get_pipelex_hub().get_required_pipe_library(library_id=library_id).get_optional_pipe(pipe_code=pipe_code)


def get_concept_library() -> ConceptLibraryAbstract:
return get_pipelex_hub().get_required_concept_library()
def get_concept_library(library_id: str | None = None) -> ConceptLibraryAbstract:
return get_pipelex_hub().get_required_concept_library(library_id=library_id)


def get_required_concept(concept_string: str) -> Concept:
return get_pipelex_hub().get_required_concept_library().get_required_concept(concept_string=concept_string)
def get_required_concept(concept_string: str, library_id: str | None = None) -> Concept:
return get_pipelex_hub().get_required_concept_library(library_id=library_id).get_required_concept(concept_string=concept_string)


def get_pipe_router() -> PipeRouterProtocol:
Expand All @@ -420,10 +426,6 @@ def get_activity_manager() -> ActivityManagerProtocol:
return get_pipelex_hub().get_activity_manager()


def get_pipeline(pipeline_run_id: str) -> Pipeline:
return get_pipeline_manager().get_pipeline(pipeline_run_id=pipeline_run_id)


def get_library_manager() -> LibraryManagerAbstract:
return get_pipelex_hub().get_required_library_manager()

Expand All @@ -433,4 +435,4 @@ def get_observer_provider() -> ObserverProtocol:


def get_native_concept(native_concept: NativeConceptCode) -> Concept:
return get_pipelex_hub().get_required_concept_library().get_native_concept(native_concept=native_concept)
return get_pipelex_hub().get_required_concept_library(library_id=SpecialLibraryId.UNTITLED).get_native_concept(native_concept=native_concept)
10 changes: 10 additions & 0 deletions pipelex/libraries/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,11 @@
from pipelex.libraries.library import Library
from pipelex.libraries.library_ids import SpecialLibraryId
from pipelex.libraries.library_manager import LibraryManager
from pipelex.libraries.library_manager_abstract import LibraryManagerAbstract

__all__ = [
"Library",
"LibraryManager",
"LibraryManagerAbstract",
"SpecialLibraryId",
]
Empty file.
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
from typing import Any

from pydantic import Field, RootModel
from pydantic import Field, RootModel, model_validator
from typing_extensions import override

from pipelex.core.concepts.concept import Concept
from pipelex.core.concepts.concept_blueprint import ConceptBlueprint
from pipelex.core.concepts.concept_factory import ConceptFactory
from pipelex.core.concepts.concept_library_abstract import ConceptLibraryAbstract
from pipelex.core.concepts.concept_native import NativeConceptCode
from pipelex.core.domains.domain import SpecialDomain
from pipelex.core.stuffs.image_content import ImageContent
from pipelex.exceptions import ConceptLibraryConceptNotFoundError, ConceptLibraryError
from pipelex.hub import get_class_registry
from pipelex.libraries.concept.concept_library_abstract import ConceptLibraryAbstract
from pipelex.types import Self

ConceptLibraryRoot = dict[str, Concept]
Expand All @@ -20,8 +16,8 @@
class ConceptLibrary(RootModel[ConceptLibraryRoot], ConceptLibraryAbstract):
root: ConceptLibraryRoot = Field(default_factory=dict)

def validate_with_libraries(self):
"""Validates that the each refine concept code in the refines array of each concept in the library exists in the library"""
@model_validator(mode="before")
def validation_static(self):
for concept in self.root.values():
if concept.refines and concept.refines not in self.root:
msg = f"Concept '{concept.code}' refines '{concept.refines}' but no concept with the code '{concept.refines}' exists"
Expand All @@ -33,17 +29,19 @@ def setup(self):
self.add_concepts(concepts=all_native_concepts)

@override
def reset(self):
def teardown(self):
self.root = {}
self.setup()

@override
def teardown(self):
self.root = {}
def reset(self):
self.teardown()
self.setup()

@classmethod
def make_empty(cls) -> Self:
return cls(root={})
library = cls(root={})
library.setup()
return library

@override
def list_concepts(self) -> list[Concept]:
Expand Down Expand Up @@ -105,23 +103,15 @@ def get_native_concepts(self) -> list[Concept]:
return [self.get_native_concept(native_concept=native_concept) for native_concept in NativeConceptCode.values_list()]

@override
def get_class(self, concept_code: str) -> type[Any] | None:
return get_class_registry().get_class(concept_code)
def search_for_concept_in_domains(self, concept_code: str, search_domains: list[str]) -> Concept | None:
ConceptBlueprint.validate_concept_code(concept_code=concept_code)
for domain in search_domains:
if found_concept := self.get_required_concept(
concept_string=ConceptFactory.make_concept_string_with_domain(domain=domain, concept_code=concept_code),
):
return found_concept

@override
def is_image_concept(self, concept: Concept) -> bool:
"""Check if the concept is an image concept.
It is an image concept if its structure class is a subclass of ImageContent
or if it refines the native Image concept.
"""
pydantic_model = self.get_class(concept_code=concept.structure_class_name)
is_image_class = bool(pydantic_model and issubclass(pydantic_model, ImageContent))
refines_image = self.is_compatible(
tested_concept=concept,
wanted_concept=self.get_native_concept(native_concept=NativeConceptCode.IMAGE),
strict=True,
)
return is_image_class or refines_image
return None

@override
def get_required_concept_from_concept_string_or_code(self, concept_string_or_code: str, search_domains: list[str] | None = None) -> Concept:
Expand Down Expand Up @@ -155,14 +145,3 @@ def get_required_concept_from_concept_string_or_code(self, concept_string_or_cod
msg = f"Multiple concepts found for '{concept_string_or_code}': {found_concepts}. Please specify the domain."
raise ConceptLibraryConceptNotFoundError(msg)
return found_concepts[0]

@override
def search_for_concept_in_domains(self, concept_code: str, search_domains: list[str]) -> Concept | None:
ConceptBlueprint.validate_concept_code(concept_code=concept_code)
for domain in search_domains:
if found_concept := self.get_required_concept(
concept_string=ConceptFactory.make_concept_string_with_domain(domain=domain, concept_code=concept_code),
):
return found_concept

return None
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from abc import ABC, abstractmethod
from typing import Any

from pipelex.core.concepts.concept import Concept
from pipelex.core.concepts.concept_native import NativeConceptCode
Expand Down Expand Up @@ -46,18 +45,10 @@ def reset(self) -> None:
def teardown(self) -> None:
pass

@abstractmethod
def is_image_concept(self, concept: Concept) -> bool:
pass

@abstractmethod
def search_for_concept_in_domains(self, concept_code: str, search_domains: list[str]) -> Concept | None:
pass

@abstractmethod
def get_class(self, concept_code: str) -> type[Any] | None:
pass

@abstractmethod
def get_native_concept(self, native_concept: NativeConceptCode) -> Concept:
pass
Expand Down
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
from typing_extensions import override

from pipelex.core.domains.domain import Domain
from pipelex.core.domains.domain_library_abstract import DomainLibraryAbstract
from pipelex.exceptions import DomainLibraryError
from pipelex.libraries.domain.domain_library_abstract import DomainLibraryAbstract
from pipelex.types import Self

DomainLibraryRoot = dict[str, Domain]
Expand All @@ -13,9 +13,17 @@ class DomainLibrary(RootModel[DomainLibraryRoot], DomainLibraryAbstract):
def validate_with_libraries(self):
pass

def reset(self):
def setup(self):
pass

@override
def teardown(self):
self.root = {}

def reset(self):
self.teardown()
self.setup()

@classmethod
def make_empty(cls) -> Self:
return cls(root={})
Expand All @@ -36,18 +44,11 @@ def remove_domain_by_code(self, domain_code: str) -> None:
if domain_code in self.root:
del self.root[domain_code]

@override
def get_domain(self, domain: str) -> Domain | None:
return self.root.get(domain)

@override
def get_required_domain(self, domain: str) -> Domain:
"""Get a domain by code from this library, raising an error if not found."""
the_domain = self.get_domain(domain=domain)
if not the_domain:
msg = f"Domain '{domain}' not found. Check for typos and make sure it is declared in a pipeline library."
raise DomainLibraryError(msg)
return the_domain

@override
def teardown(self) -> None:
self.root = {}
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
class DomainLibraryAbstract(ABC):
@abstractmethod
def get_domain(self, domain: str) -> Domain | None:
pass
"""Get a domain by code from this library."""

@abstractmethod
def get_required_domain(self, domain: str) -> Domain:
pass
"""Get a domain by code from this library, raising an error if not found."""

@abstractmethod
def teardown(self) -> None:
Expand Down
Loading