Skip to content

Build AI methods with your coding agent, then run them anywhere: as an MCP for chatbots, as a webapp for people, or via API for your software.

Refactor/move plugin package up (#35)

Louis Choquel697fc73fa318
diff --git a/.cursor/rules/pytest.mdc b/.cursor/rules/pytest.mdc
index 268bb9428..b44f68fae 100644
--- a/.cursor/rules/pytest.mdc
+++ b/.cursor/rules/pytest.mdc
@@ -11,10 +11,12 @@ These rules apply when writing unit tests.
- Name test files with `test_` prefix
- Use descriptive names that match the functionality being tested
- Place test files in the appropriate subdirectory of `tests/`:
- - `tests/cogt/` for tests related to sub-package `pipelex.cogt`
- `tests/tools/` for tests related to sub-package `pipelex.tools`
- - `tests/pipelex/` for tests related to `pipelex`and not its sub-packages
-- More precisely, for `pipelex` and `pipelex.cogt` place the tests inside subdirectories named either `asynch` for async test functions and `synchro` for normal non-async test functions
+ - `tests/pipelex/` for tests related to `pipelex`and its sub-packages
+ - `tests/pipelex/cogt/` for tests related to sub-package `pipelex.cogt`
+- More precisely, for `pipelex` and `pipelex.cogt` the async tests are placed inside subdirectories named `cogt_asynch` and `pipelex_asynch`
+- Fixtures are defined in conftest.py modules at different levels of the hierarchy, their scope is handled by pytest
+- Test data is placed inside test_data.py at different levels of the hierarchy, they must be imported with package paths from the root like `tests.pipelex.test_data`. Their content is all constants, regrouped inside classes to keep things tidy.
## Markers
diff --git a/Makefile b/Makefile
index 6b34738f3..c6d586841 100644
--- a/Makefile
+++ b/Makefile
@@ -65,6 +65,8 @@ make init - Run pipelex init
make codex-tests - Run tests for Codex (exit on first failure) (no inference, no codex_disabled)
make gha-tests - Run tests for github actions (exit on first failure) (no inference, no gha_disabled)
make test - Run unit tests (no inference)
+make test-quiet - Run unit tests without prints (no inference)
+make tq - Shorthand -> test-quiet
make test-with-prints - Run tests with prints (no inference)
make t - Shorthand -> test-with-prints
make test-inference - Run unit tests only for inference (with prints)
@@ -88,7 +90,7 @@ export HELP
all help env lock install update build \
format lint pyright mypy \
cleanderived cleanenv cleanlibraries cleanall \
- test test-with-prints t test-inference ti \
+ test test-quiet tq test-with-prints t test-inference ti \
test-imgg tg test-ocr to codex-tests gha-tests \
run-all-tests run-manual-trigger-gha-tests run-gha_disabled-tests \
validate v check c cc \
@@ -228,6 +230,18 @@ test: env
$(VENV_PYTEST) -s -o log_cli=true -o log_level=WARNING $(if $(filter 2,$(VERBOSE)),-vv,$(if $(filter 3,$(VERBOSE)),-vvv,-v)); \
fi
+test-quiet: env
+ $(call PRINT_TITLE,"Unit testing without prints but displaying logs via pytest for WARNING level and above")
+ @echo "• Running unit tests"
+ @if [ -n "$(TEST)" ]; then \
+ $(VENV_PYTEST) -o log_cli=true -o log_level=WARNING -k "$(TEST)" $(if $(filter 2,$(VERBOSE)),-vv,$(if $(filter 3,$(VERBOSE)),-vvv,-v)); \
+ else \
+ $(VENV_PYTEST) -o log_cli=true -o log_level=WARNING $(if $(filter 2,$(VERBOSE)),-vv,$(if $(filter 3,$(VERBOSE)),-vvv,-v)); \
+ fi
+
+tq: test-quiet
+ @echo "> done: tq = test-quiet"
+
test-with-prints: env
$(call PRINT_TITLE,"Unit testing with prints and our rich logs")
@echo "• Running unit tests"
diff --git a/pipelex/cogt/config_cogt.py b/pipelex/cogt/config_cogt.py
index acaa440ca..a4a05145f 100644
--- a/pipelex/cogt/config_cogt.py
+++ b/pipelex/cogt/config_cogt.py
@@ -6,15 +6,15 @@ from pipelex.cogt.imgg.imgg_handle import ImggHandle
from pipelex.cogt.imgg.imgg_job_components import ImggJobConfig, ImggJobParams, ImggJobParamsDefaults
from pipelex.cogt.llm.llm_job_components import LLMJobConfig
from pipelex.cogt.llm.llm_models.llm_platform import LLMPlatform
-from pipelex.cogt.plugin.anthropic.anthropic_config import AnthropicConfig
-from pipelex.cogt.plugin.bedrock.bedrock_config import BedrockConfig
-from pipelex.cogt.plugin.mistral.mistral_config import MistralConfig
-from pipelex.cogt.plugin.openai.azure_openai_config import AzureOpenAIConfig
-from pipelex.cogt.plugin.openai.custom_endpoint_config import CustomEndpointConfig
-from pipelex.cogt.plugin.openai.openai_config import OpenAIOpenAIConfig
-from pipelex.cogt.plugin.openai.perplexity_config import PerplexityConfig
-from pipelex.cogt.plugin.openai.vertexai_config import VertexAIConfig
-from pipelex.cogt.plugin.openai.xai_config import XaiConfig
+from pipelex.plugin.anthropic.anthropic_config import AnthropicConfig
+from pipelex.plugin.bedrock.bedrock_config import BedrockConfig
+from pipelex.plugin.mistral.mistral_config import MistralConfig
+from pipelex.plugin.openai.azure_openai_config import AzureOpenAIConfig
+from pipelex.plugin.openai.custom_endpoint_config import CustomEndpointConfig
+from pipelex.plugin.openai.openai_config import OpenAIOpenAIConfig
+from pipelex.plugin.openai.perplexity_config import PerplexityConfig
+from pipelex.plugin.openai.vertexai_config import VertexAIConfig
+from pipelex.plugin.openai.xai_config import XaiConfig
from pipelex.tools.config.models import ConfigModel
diff --git a/pipelex/cogt/imgg/imgg_worker_factory.py b/pipelex/cogt/imgg/imgg_worker_factory.py
index 14ced57e5..ab174a1ad 100644
--- a/pipelex/cogt/imgg/imgg_worker_factory.py
+++ b/pipelex/cogt/imgg/imgg_worker_factory.py
@@ -6,9 +6,9 @@ from pipelex.cogt.imgg.imgg_platform import ImggPlatform
from pipelex.cogt.imgg.imgg_worker_abstract import ImggWorkerAbstract
from pipelex.cogt.inference.inference_report_delegate import InferenceReportDelegate
from pipelex.cogt.llm.llm_models.llm_platform import LLMPlatform
-from pipelex.cogt.plugin.openai.openai_imgg_worker import OpenAIImggWorker
from pipelex.cogt.plugin_manager import PluginHandle
from pipelex.hub import get_plugin_manager, get_secret
+from pipelex.plugin.openai.openai_imgg_worker import OpenAIImggWorker
from pipelex.tools.secrets.secrets_errors import SecretNotFoundError
@@ -39,7 +39,7 @@ class ImggWorkerFactory:
"fal-client", "fal", "The fal-client SDK is required to use FAL models (generation of images)."
) from exc
- from pipelex.cogt.plugin.fal.fal_imgg_worker import FalImggWorker
+ from pipelex.plugin.fal.fal_imgg_worker import FalImggWorker
imgg_sdk_instance = plugin_manager.get_imgg_sdk_instance(imgg_sdk_handle=imgg_sdk_handle) or plugin_manager.set_imgg_sdk_instance(
imgg_sdk_handle=imgg_sdk_handle,
@@ -52,7 +52,7 @@ class ImggWorkerFactory:
report_delegate=report_delegate,
)
case ImggPlatform.OPENAI:
- from pipelex.cogt.plugin.openai.openai_factory import OpenAIFactory
+ from pipelex.plugin.openai.openai_factory import OpenAIFactory
imgg_sdk_instance = plugin_manager.get_llm_sdk_instance(llm_sdk_handle=imgg_sdk_handle) or plugin_manager.set_llm_sdk_instance(
llm_sdk_handle=imgg_sdk_handle,
diff --git a/pipelex/cogt/llm/llm_worker_factory.py b/pipelex/cogt/llm/llm_worker_factory.py
index 6f309fc23..445e64554 100644
--- a/pipelex/cogt/llm/llm_worker_factory.py
+++ b/pipelex/cogt/llm/llm_worker_factory.py
@@ -22,13 +22,13 @@ class LLMWorkerFactory:
llm_worker: LLMWorkerAbstract
match llm_engine.llm_platform:
case LLMPlatform.OPENAI | LLMPlatform.AZURE_OPENAI | LLMPlatform.PERPLEXITY | LLMPlatform.XAI:
- from pipelex.cogt.plugin.openai.openai_factory import OpenAIFactory
+ from pipelex.plugin.openai.openai_factory import OpenAIFactory
structure_method: Optional[StructureMethod] = None
if get_config().cogt.llm_config.instructor_config.is_openai_structured_output_enabled:
structure_method = StructureMethod.INSTRUCTOR_OPENAI_STRUCTURED
- from pipelex.cogt.plugin.openai.openai_llm_worker import OpenAILLMWorker
+ from pipelex.plugin.openai.openai_llm_worker import OpenAILLMWorker
llm_sdk_instance = plugin_manager.get_llm_sdk_instance(llm_sdk_handle=llm_sdk_handle) or plugin_manager.set_llm_sdk_instance(
llm_sdk_handle=llm_sdk_handle,
@@ -47,8 +47,8 @@ class LLMWorkerFactory:
except ImportError as exc:
raise MissingDependencyError("google-auth-oauthlib", "google", "This dependency is required to connect to google.") from exc
- from pipelex.cogt.plugin.openai.openai_factory import OpenAIFactory
- from pipelex.cogt.plugin.openai.openai_llm_worker import OpenAILLMWorker
+ from pipelex.plugin.openai.openai_factory import OpenAIFactory
+ from pipelex.plugin.openai.openai_llm_worker import OpenAILLMWorker
llm_sdk_instance = plugin_manager.get_llm_sdk_instance(llm_sdk_handle=llm_sdk_handle) or plugin_manager.set_llm_sdk_instance(
llm_sdk_handle=llm_sdk_handle,
@@ -62,8 +62,8 @@ class LLMWorkerFactory:
report_delegate=report_delegate,
)
case LLMPlatform.CUSTOM_OPENAI:
- from pipelex.cogt.plugin.openai.openai_factory import OpenAIFactory
- from pipelex.cogt.plugin.openai.openai_llm_worker import OpenAILLMWorker
+ from pipelex.plugin.openai.openai_factory import OpenAIFactory
+ from pipelex.plugin.openai.openai_llm_worker import OpenAILLMWorker
llm_sdk_instance = plugin_manager.get_llm_sdk_instance(llm_sdk_handle=llm_sdk_handle) or plugin_manager.set_llm_sdk_instance(
llm_sdk_handle=llm_sdk_handle,
@@ -88,8 +88,8 @@ class LLMWorkerFactory:
(eg: bedrock-anthropic-claude)",
) from exc
- from pipelex.cogt.plugin.anthropic.anthropic_factory import AnthropicFactory
- from pipelex.cogt.plugin.anthropic.anthropic_llm_worker import AnthropicLLMWorker
+ from pipelex.plugin.anthropic.anthropic_factory import AnthropicFactory
+ from pipelex.plugin.anthropic.anthropic_llm_worker import AnthropicLLMWorker
llm_sdk_instance = plugin_manager.get_llm_sdk_instance(llm_sdk_handle=llm_sdk_handle) or plugin_manager.set_llm_sdk_instance(
llm_sdk_handle=llm_sdk_handle,
@@ -114,8 +114,8 @@ class LLMWorkerFactory:
(eg: bedrock-mistral-large)",
) from exc
- from pipelex.cogt.plugin.mistral.mistral_factory import MistralFactory
- from pipelex.cogt.plugin.mistral.mistral_llm_worker import MistralLLMWorker
+ from pipelex.plugin.mistral.mistral_factory import MistralFactory
+ from pipelex.plugin.mistral.mistral_llm_worker import MistralLLMWorker
llm_sdk_instance = plugin_manager.get_llm_sdk_instance(llm_sdk_handle=llm_sdk_handle) or plugin_manager.set_llm_sdk_instance(
llm_sdk_handle=llm_sdk_handle,
@@ -137,8 +137,8 @@ class LLMWorkerFactory:
"boto3,aioboto3", "bedrock", "The boto3 and aioboto3 SDKs are required to use Bedrock models."
) from exc
- from pipelex.cogt.plugin.bedrock.bedrock_factory import BedrockFactory
- from pipelex.cogt.plugin.bedrock.bedrock_llm_worker import BedrockLLMWorker
+ from pipelex.plugin.bedrock.bedrock_factory import BedrockFactory
+ from pipelex.plugin.bedrock.bedrock_llm_worker import BedrockLLMWorker
llm_sdk_instance = plugin_manager.get_llm_sdk_instance(llm_sdk_handle=llm_sdk_handle) or plugin_manager.set_llm_sdk_instance(
llm_sdk_handle=llm_sdk_handle,
diff --git a/pipelex/cogt/ocr/ocr_worker_factory.py b/pipelex/cogt/ocr/ocr_worker_factory.py
index 42ffa78c7..06a85f14d 100644
--- a/pipelex/cogt/ocr/ocr_worker_factory.py
+++ b/pipelex/cogt/ocr/ocr_worker_factory.py
@@ -29,8 +29,8 @@ class OcrWorkerFactory:
"The mistralai SDK is required to use Mistral OCR models through the mistralai client.",
) from exc
- from pipelex.cogt.plugin.mistral.mistral_factory import MistralFactory
- from pipelex.cogt.plugin.mistral.mistral_ocr_worker import MistralOcrWorker
+ from pipelex.plugin.mistral.mistral_factory import MistralFactory
+ from pipelex.plugin.mistral.mistral_ocr_worker import MistralOcrWorker
ocr_sdk_instance = plugin_manager.get_ocr_sdk_instance(ocr_sdk_handle=ocr_sdk_handle) or plugin_manager.set_ocr_sdk_instance(
ocr_sdk_handle=ocr_sdk_handle,
diff --git a/pipelex/cogt/plugin/__init__.py b/pipelex/plugin/__init__.py
similarity index 100%
rename from pipelex/cogt/plugin/__init__.py
rename to pipelex/plugin/__init__.py
diff --git a/pipelex/cogt/plugin/anthropic/__init__.py b/pipelex/plugin/anthropic/__init__.py
similarity index 100%
rename from pipelex/cogt/plugin/anthropic/__init__.py
rename to pipelex/plugin/anthropic/__init__.py
diff --git a/pipelex/cogt/plugin/anthropic/anthropic_config.py b/pipelex/plugin/anthropic/anthropic_config.py
similarity index 100%
rename from pipelex/cogt/plugin/anthropic/anthropic_config.py
rename to pipelex/plugin/anthropic/anthropic_config.py
diff --git a/pipelex/cogt/plugin/anthropic/anthropic_factory.py b/pipelex/plugin/anthropic/anthropic_factory.py
similarity index 100%
rename from pipelex/cogt/plugin/anthropic/anthropic_factory.py
rename to pipelex/plugin/anthropic/anthropic_factory.py
diff --git a/pipelex/cogt/plugin/anthropic/anthropic_llm_worker.py b/pipelex/plugin/anthropic/anthropic_llm_worker.py
similarity index 98%
rename from pipelex/cogt/plugin/anthropic/anthropic_llm_worker.py
rename to pipelex/plugin/anthropic/anthropic_llm_worker.py
index 1fded6d34..57d2461c2 100644
--- a/pipelex/cogt/plugin/anthropic/anthropic_llm_worker.py
+++ b/pipelex/plugin/anthropic/anthropic_llm_worker.py
@@ -13,8 +13,8 @@ from pipelex.cogt.llm.llm_models.llm_engine import LLMEngine
from pipelex.cogt.llm.llm_models.llm_platform import LLMPlatform
from pipelex.cogt.llm.llm_worker_abstract import LLMWorkerAbstract
from pipelex.cogt.llm.structured_output import StructureMethod
-from pipelex.cogt.plugin.anthropic.anthropic_factory import AnthropicFactory
from pipelex.config import get_config
+from pipelex.plugin.anthropic.anthropic_factory import AnthropicFactory
from pipelex.tools.typing.pydantic_utils import BaseModelTypeVar
diff --git a/pipelex/cogt/plugin/anthropic/anthropic_llms.py b/pipelex/plugin/anthropic/anthropic_llms.py
similarity index 93%
rename from pipelex/cogt/plugin/anthropic/anthropic_llms.py
rename to pipelex/plugin/anthropic/anthropic_llms.py
index c1b21c4be..5975ddffa 100644
--- a/pipelex/cogt/plugin/anthropic/anthropic_llms.py
+++ b/pipelex/plugin/anthropic/anthropic_llms.py
@@ -5,7 +5,7 @@ from anthropic.types import ModelInfo
from pipelex.cogt.exceptions import LLMModelProviderError, LLMSDKError
from pipelex.cogt.llm.llm_models.llm_platform import LLMPlatform
-from pipelex.cogt.plugin.anthropic.anthropic_factory import AnthropicFactory
+from pipelex.plugin.anthropic.anthropic_factory import AnthropicFactory
async def anthropic_list_anthropic_models(llm_platform: LLMPlatform) -> List[ModelInfo]:
diff --git a/pipelex/cogt/plugin/bedrock/__init__.py b/pipelex/plugin/bedrock/__init__.py
similarity index 100%
rename from pipelex/cogt/plugin/bedrock/__init__.py
rename to pipelex/plugin/bedrock/__init__.py
diff --git a/pipelex/cogt/plugin/bedrock/bedrock_client_aioboto3.py b/pipelex/plugin/bedrock/bedrock_client_aioboto3.py
similarity index 91%
rename from pipelex/cogt/plugin/bedrock/bedrock_client_aioboto3.py
rename to pipelex/plugin/bedrock/bedrock_client_aioboto3.py
index 9fe1d4237..ee0f5bfd7 100644
--- a/pipelex/cogt/plugin/bedrock/bedrock_client_aioboto3.py
+++ b/pipelex/plugin/bedrock/bedrock_client_aioboto3.py
@@ -6,8 +6,8 @@ from typing_extensions import override
from pipelex import log
from pipelex.cogt.llm.token_category import NbTokensByCategoryDict, TokenCategory
-from pipelex.cogt.plugin.bedrock.bedrock_client_protocol import BedrockClientProtocol
-from pipelex.cogt.plugin.bedrock.bedrock_message import BedrockMessageDictList
+from pipelex.plugin.bedrock.bedrock_client_protocol import BedrockClientProtocol
+from pipelex.plugin.bedrock.bedrock_message import BedrockMessageDictList
class BedrockClientAioboto3(BedrockClientProtocol):
diff --git a/pipelex/cogt/plugin/bedrock/bedrock_client_boto3.py b/pipelex/plugin/bedrock/bedrock_client_boto3.py
similarity index 91%
rename from pipelex/cogt/plugin/bedrock/bedrock_client_boto3.py
rename to pipelex/plugin/bedrock/bedrock_client_boto3.py
index 27d818adf..7c64fabf4 100644
--- a/pipelex/cogt/plugin/bedrock/bedrock_client_boto3.py
+++ b/pipelex/plugin/bedrock/bedrock_client_boto3.py
@@ -6,8 +6,8 @@ from typing_extensions import override
from pipelex import log
from pipelex.cogt.llm.token_category import NbTokensByCategoryDict, TokenCategory
-from pipelex.cogt.plugin.bedrock.bedrock_client_protocol import BedrockClientProtocol
-from pipelex.cogt.plugin.bedrock.bedrock_message import BedrockMessageDictList
+from pipelex.plugin.bedrock.bedrock_client_protocol import BedrockClientProtocol
+from pipelex.plugin.bedrock.bedrock_message import BedrockMessageDictList
class BedrockClientBoto3(BedrockClientProtocol):
diff --git a/pipelex/cogt/plugin/bedrock/bedrock_client_protocol.py b/pipelex/plugin/bedrock/bedrock_client_protocol.py
similarity index 84%
rename from pipelex/cogt/plugin/bedrock/bedrock_client_protocol.py
rename to pipelex/plugin/bedrock/bedrock_client_protocol.py
index f1f39c4d7..c94dd13f1 100644
--- a/pipelex/cogt/plugin/bedrock/bedrock_client_protocol.py
+++ b/pipelex/plugin/bedrock/bedrock_client_protocol.py
@@ -1,7 +1,7 @@
from typing import Optional, Protocol, Tuple, runtime_checkable
from pipelex.cogt.llm.token_category import NbTokensByCategoryDict
-from pipelex.cogt.plugin.bedrock.bedrock_message import BedrockMessageDictList
+from pipelex.plugin.bedrock.bedrock_message import BedrockMessageDictList
@runtime_checkable
diff --git a/pipelex/cogt/plugin/bedrock/bedrock_config.py b/pipelex/plugin/bedrock/bedrock_config.py
similarity index 100%
rename from pipelex/cogt/plugin/bedrock/bedrock_config.py
rename to pipelex/plugin/bedrock/bedrock_config.py
diff --git a/pipelex/cogt/plugin/bedrock/bedrock_factory.py b/pipelex/plugin/bedrock/bedrock_factory.py
similarity index 83%
rename from pipelex/cogt/plugin/bedrock/bedrock_factory.py
rename to pipelex/plugin/bedrock/bedrock_factory.py
index a4800f5e2..4572c24e0 100644
--- a/pipelex/cogt/plugin/bedrock/bedrock_factory.py
+++ b/pipelex/plugin/bedrock/bedrock_factory.py
@@ -2,11 +2,11 @@ from pipelex import log
from pipelex.cogt.exceptions import LLMCapabilityError, PromptImageFormatError
from pipelex.cogt.image.prompt_image import PromptImageBytes
from pipelex.cogt.llm.llm_job import LLMJob
-from pipelex.cogt.plugin.bedrock.bedrock_client_protocol import BedrockClientProtocol
-from pipelex.cogt.plugin.bedrock.bedrock_config import BedrockClientMethod
-from pipelex.cogt.plugin.bedrock.bedrock_message import BedrockContentItem, BedrockImage, BedrockMessage, BedrockSource, ImageFormat
from pipelex.config import get_config
from pipelex.hub import get_secrets_provider
+from pipelex.plugin.bedrock.bedrock_client_protocol import BedrockClientProtocol
+from pipelex.plugin.bedrock.bedrock_config import BedrockClientMethod
+from pipelex.plugin.bedrock.bedrock_message import BedrockContentItem, BedrockImage, BedrockMessage, BedrockSource, ImageFormat
class BedrockFactory:
@@ -23,11 +23,11 @@ class BedrockFactory:
log.verbose(f"Using '{client_method}' for BedrockClient")
match client_method:
case BedrockClientMethod.AIBOTO3:
- from pipelex.cogt.plugin.bedrock.bedrock_client_aioboto3 import BedrockClientAioboto3
+ from pipelex.plugin.bedrock.bedrock_client_aioboto3 import BedrockClientAioboto3
bedrock_async_client = BedrockClientAioboto3(aws_region=aws_region)
case BedrockClientMethod.BOTO3:
- from pipelex.cogt.plugin.bedrock.bedrock_client_boto3 import BedrockClientBoto3
+ from pipelex.plugin.bedrock.bedrock_client_boto3 import BedrockClientBoto3
bedrock_async_client = BedrockClientBoto3(aws_region=aws_region)
diff --git a/pipelex/cogt/plugin/bedrock/bedrock_llm_worker.py b/pipelex/plugin/bedrock/bedrock_llm_worker.py
similarity index 94%
rename from pipelex/cogt/plugin/bedrock/bedrock_llm_worker.py
rename to pipelex/plugin/bedrock/bedrock_llm_worker.py
index 7dee3c7a2..3ce16976f 100644
--- a/pipelex/cogt/plugin/bedrock/bedrock_llm_worker.py
+++ b/pipelex/plugin/bedrock/bedrock_llm_worker.py
@@ -10,8 +10,8 @@ from pipelex.cogt.llm.llm_job_func import llm_job_func
from pipelex.cogt.llm.llm_models.llm_engine import LLMEngine
from pipelex.cogt.llm.llm_worker_abstract import LLMWorkerAbstract
from pipelex.cogt.llm.structured_output import StructureMethod
-from pipelex.cogt.plugin.bedrock.bedrock_client_protocol import BedrockClientProtocol
-from pipelex.cogt.plugin.bedrock.bedrock_factory import BedrockFactory
+from pipelex.plugin.bedrock.bedrock_client_protocol import BedrockClientProtocol
+from pipelex.plugin.bedrock.bedrock_factory import BedrockFactory
from pipelex.tools.typing.pydantic_utils import BaseModelTypeVar
diff --git a/pipelex/cogt/plugin/bedrock/bedrock_message.py b/pipelex/plugin/bedrock/bedrock_message.py
similarity index 100%
rename from pipelex/cogt/plugin/bedrock/bedrock_message.py
rename to pipelex/plugin/bedrock/bedrock_message.py
diff --git a/pipelex/cogt/plugin/fal/__init__.py b/pipelex/plugin/fal/__init__.py
similarity index 100%
rename from pipelex/cogt/plugin/fal/__init__.py
rename to pipelex/plugin/fal/__init__.py
diff --git a/pipelex/cogt/plugin/fal/fal_factory.py b/pipelex/plugin/fal/fal_factory.py
similarity index 100%
rename from pipelex/cogt/plugin/fal/fal_factory.py
rename to pipelex/plugin/fal/fal_factory.py
diff --git a/pipelex/cogt/plugin/fal/fal_imgg_worker.py b/pipelex/plugin/fal/fal_imgg_worker.py
similarity index 98%
rename from pipelex/cogt/plugin/fal/fal_imgg_worker.py
rename to pipelex/plugin/fal/fal_imgg_worker.py
index 2b863f4d3..bf5e3fd00 100644
--- a/pipelex/cogt/plugin/fal/fal_imgg_worker.py
+++ b/pipelex/plugin/fal/fal_imgg_worker.py
@@ -10,7 +10,7 @@ from pipelex.cogt.imgg.imgg_engine import ImggEngine
from pipelex.cogt.imgg.imgg_job import ImggJob
from pipelex.cogt.imgg.imgg_worker_abstract import ImggWorkerAbstract, imgg_job_func
from pipelex.cogt.inference.inference_report_delegate import InferenceReportDelegate
-from pipelex.cogt.plugin.fal.fal_factory import FalFactory
+from pipelex.plugin.fal.fal_factory import FalFactory
class FalImggWorker(ImggWorkerAbstract):
diff --git a/pipelex/cogt/plugin/mistral/__init__.py b/pipelex/plugin/mistral/__init__.py
similarity index 100%
rename from pipelex/cogt/plugin/mistral/__init__.py
rename to pipelex/plugin/mistral/__init__.py
diff --git a/pipelex/cogt/plugin/mistral/mistral_config.py b/pipelex/plugin/mistral/mistral_config.py
similarity index 100%
rename from pipelex/cogt/plugin/mistral/mistral_config.py
rename to pipelex/plugin/mistral/mistral_config.py
diff --git a/pipelex/cogt/plugin/mistral/mistral_factory.py b/pipelex/plugin/mistral/mistral_factory.py
similarity index 98%
rename from pipelex/cogt/plugin/mistral/mistral_factory.py
rename to pipelex/plugin/mistral/mistral_factory.py
index 8bf0e706a..640f1fffc 100644
--- a/pipelex/cogt/plugin/mistral/mistral_factory.py
+++ b/pipelex/plugin/mistral/mistral_factory.py
@@ -24,9 +24,9 @@ from pipelex.cogt.image.prompt_image import PromptImage, PromptImageBytes, Promp
from pipelex.cogt.llm.llm_job import LLMJob
from pipelex.cogt.llm.token_category import NbTokensByCategoryDict, TokenCategory
from pipelex.cogt.ocr.ocr_output import ExtractedImageFromPage, OcrOutput, Page
-from pipelex.cogt.plugin.openai.openai_factory import OpenAIFactory
from pipelex.config import get_config
from pipelex.hub import get_secrets_provider
+from pipelex.plugin.openai.openai_factory import OpenAIFactory
from pipelex.tools.misc.base_64_utils import encode_to_base64, load_binary_as_base64
diff --git a/pipelex/cogt/plugin/mistral/mistral_llm_worker.py b/pipelex/plugin/mistral/mistral_llm_worker.py
similarity index 98%
rename from pipelex/cogt/plugin/mistral/mistral_llm_worker.py
rename to pipelex/plugin/mistral/mistral_llm_worker.py
index b13ba1876..d556a2f6e 100644
--- a/pipelex/cogt/plugin/mistral/mistral_llm_worker.py
+++ b/pipelex/plugin/mistral/mistral_llm_worker.py
@@ -13,7 +13,7 @@ from pipelex.cogt.llm.llm_job_func import llm_job_func
from pipelex.cogt.llm.llm_models.llm_engine import LLMEngine
from pipelex.cogt.llm.llm_worker_abstract import LLMWorkerAbstract
from pipelex.cogt.llm.structured_output import StructureMethod
-from pipelex.cogt.plugin.mistral.mistral_factory import MistralFactory
+from pipelex.plugin.mistral.mistral_factory import MistralFactory
from pipelex.tools.typing.pydantic_utils import BaseModelTypeVar
diff --git a/pipelex/cogt/plugin/mistral/mistral_llms.py b/pipelex/plugin/mistral/mistral_llms.py
similarity index 88%
rename from pipelex/cogt/plugin/mistral/mistral_llms.py
rename to pipelex/plugin/mistral/mistral_llms.py
index 579f13fad..a4dceac17 100644
--- a/pipelex/cogt/plugin/mistral/mistral_llms.py
+++ b/pipelex/plugin/mistral/mistral_llms.py
@@ -3,7 +3,7 @@ from typing import List
from mistralai.models import Data
from pipelex.cogt.exceptions import LLMModelProviderError
-from pipelex.cogt.plugin.mistral.mistral_factory import MistralFactory
+from pipelex.plugin.mistral.mistral_factory import MistralFactory
def list_mistral_models() -> List[Data]:
diff --git a/pipelex/cogt/plugin/mistral/mistral_ocr_worker.py b/pipelex/plugin/mistral/mistral_ocr_worker.py
similarity index 97%
rename from pipelex/cogt/plugin/mistral/mistral_ocr_worker.py
rename to pipelex/plugin/mistral/mistral_ocr_worker.py
index 5e84f8dc7..0f62070b5 100644
--- a/pipelex/cogt/plugin/mistral/mistral_ocr_worker.py
+++ b/pipelex/plugin/mistral/mistral_ocr_worker.py
@@ -11,8 +11,8 @@ from pipelex.cogt.ocr.ocr_input import OcrInputError
from pipelex.cogt.ocr.ocr_job import OcrJob
from pipelex.cogt.ocr.ocr_output import OcrOutput
from pipelex.cogt.ocr.ocr_worker_abstract import OcrWorkerAbstract, ocr_job_func
-from pipelex.cogt.plugin.mistral.mistral_factory import MistralFactory
-from pipelex.cogt.plugin.mistral.mistral_utils import upload_file_for_ocr
+from pipelex.plugin.mistral.mistral_factory import MistralFactory
+from pipelex.plugin.mistral.mistral_utils import upload_file_for_ocr
from pipelex.tools.misc.base_64_utils import load_binary_as_base64_async
from pipelex.tools.misc.path_utils import clarify_path_or_url
diff --git a/pipelex/cogt/plugin/mistral/mistral_utils.py b/pipelex/plugin/mistral/mistral_utils.py
similarity index 100%
rename from pipelex/cogt/plugin/mistral/mistral_utils.py
rename to pipelex/plugin/mistral/mistral_utils.py
diff --git a/pipelex/cogt/plugin/openai/__init__.py b/pipelex/plugin/openai/__init__.py
similarity index 100%
rename from pipelex/cogt/plugin/openai/__init__.py
rename to pipelex/plugin/openai/__init__.py
diff --git a/pipelex/cogt/plugin/openai/azure_openai_config.py b/pipelex/plugin/openai/azure_openai_config.py
similarity index 100%
rename from pipelex/cogt/plugin/openai/azure_openai_config.py
rename to pipelex/plugin/openai/azure_openai_config.py
diff --git a/pipelex/cogt/plugin/openai/custom_endpoint_config.py b/pipelex/plugin/openai/custom_endpoint_config.py
similarity index 100%
rename from pipelex/cogt/plugin/openai/custom_endpoint_config.py
rename to pipelex/plugin/openai/custom_endpoint_config.py
diff --git a/pipelex/cogt/plugin/openai/openai_config.py b/pipelex/plugin/openai/openai_config.py
similarity index 100%
rename from pipelex/cogt/plugin/openai/openai_config.py
rename to pipelex/plugin/openai/openai_config.py
diff --git a/pipelex/cogt/plugin/openai/openai_factory.py b/pipelex/plugin/openai/openai_factory.py
similarity index 100%
rename from pipelex/cogt/plugin/openai/openai_factory.py
rename to pipelex/plugin/openai/openai_factory.py
diff --git a/pipelex/cogt/plugin/openai/openai_func.py b/pipelex/plugin/openai/openai_func.py
similarity index 100%
rename from pipelex/cogt/plugin/openai/openai_func.py
rename to pipelex/plugin/openai/openai_func.py
diff --git a/pipelex/cogt/plugin/openai/openai_imgg_factory.py b/pipelex/plugin/openai/openai_imgg_factory.py
similarity index 100%
rename from pipelex/cogt/plugin/openai/openai_imgg_factory.py
rename to pipelex/plugin/openai/openai_imgg_factory.py
diff --git a/pipelex/cogt/plugin/openai/openai_imgg_worker.py b/pipelex/plugin/openai/openai_imgg_worker.py
similarity index 97%
rename from pipelex/cogt/plugin/openai/openai_imgg_worker.py
rename to pipelex/plugin/openai/openai_imgg_worker.py
index b043c7309..c91634b00 100644
--- a/pipelex/cogt/plugin/openai/openai_imgg_worker.py
+++ b/pipelex/plugin/openai/openai_imgg_worker.py
@@ -12,7 +12,7 @@ from pipelex.cogt.imgg.imgg_job import ImggJob
from pipelex.cogt.imgg.imgg_job_components import Quality
from pipelex.cogt.imgg.imgg_worker_abstract import ImggWorkerAbstract, imgg_job_func
from pipelex.cogt.inference.inference_report_delegate import InferenceReportDelegate
-from pipelex.cogt.plugin.openai.openai_imgg_factory import OpenAIImggFactory
+from pipelex.plugin.openai.openai_imgg_factory import OpenAIImggFactory
from pipelex.tools.misc.base_64_utils import save_base64_to_binary_file
from pipelex.tools.misc.file_utils import ensure_path
diff --git a/pipelex/cogt/plugin/openai/openai_llm_worker.py b/pipelex/plugin/openai/openai_llm_worker.py
similarity index 99%
rename from pipelex/cogt/plugin/openai/openai_llm_worker.py
rename to pipelex/plugin/openai/openai_llm_worker.py
index 3c3ddddd2..66bb1a3b3 100644
--- a/pipelex/cogt/plugin/openai/openai_llm_worker.py
+++ b/pipelex/plugin/openai/openai_llm_worker.py
@@ -15,7 +15,7 @@ from pipelex.cogt.llm.llm_models.llm_engine import LLMEngine
from pipelex.cogt.llm.llm_models.llm_family import LLMFamily
from pipelex.cogt.llm.llm_worker_abstract import LLMWorkerAbstract
from pipelex.cogt.llm.structured_output import StructureMethod
-from pipelex.cogt.plugin.openai.openai_factory import OpenAIFactory
+from pipelex.plugin.openai.openai_factory import OpenAIFactory
from pipelex.tools.typing.pydantic_utils import BaseModelTypeVar
diff --git a/pipelex/cogt/plugin/openai/openai_llms.py b/pipelex/plugin/openai/openai_llms.py
similarity index 91%
rename from pipelex/cogt/plugin/openai/openai_llms.py
rename to pipelex/plugin/openai/openai_llms.py
index 805854ec0..603caed75 100644
--- a/pipelex/cogt/plugin/openai/openai_llms.py
+++ b/pipelex/plugin/openai/openai_llms.py
@@ -4,7 +4,7 @@ from openai.types import Model
from pipelex.cogt.exceptions import LLMSDKError
from pipelex.cogt.llm.llm_models.llm_platform import LLMPlatform
-from pipelex.cogt.plugin.openai.openai_factory import OpenAIFactory
+from pipelex.plugin.openai.openai_factory import OpenAIFactory
async def openai_list_available_models(llm_platform: LLMPlatform) -> List[Model]:
diff --git a/pipelex/cogt/plugin/openai/perplexity_config.py b/pipelex/plugin/openai/perplexity_config.py
similarity index 100%
rename from pipelex/cogt/plugin/openai/perplexity_config.py
rename to pipelex/plugin/openai/perplexity_config.py
diff --git a/pipelex/cogt/plugin/openai/vertexai_config.py b/pipelex/plugin/openai/vertexai_config.py
similarity index 100%
rename from pipelex/cogt/plugin/openai/vertexai_config.py
rename to pipelex/plugin/openai/vertexai_config.py
diff --git a/pipelex/cogt/plugin/openai/xai_config.py b/pipelex/plugin/openai/xai_config.py
similarity index 100%
rename from pipelex/cogt/plugin/openai/xai_config.py
rename to pipelex/plugin/openai/xai_config.py
diff --git a/pyproject.toml b/pyproject.toml
index e8fc81734..6b7a55302 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -60,9 +60,10 @@ dev = [
"pyright==1.1.398",
"pandas-stubs>=2.2.3.241126",
"pytest>=8.3.3",
+ "pytest-asyncio>=0.24.0",
"pytest-cov>=6.1.1",
"pytest-sugar>=1.0.0",
- "pytest-asyncio>=0.24.0",
+ "pytest-xdist>= 3.6.1",
"ruff>=0.6.8",
"types-aioboto3[bedrock,bedrock-runtime]>=13.4.0",
"types-aiofiles>=24.1.0.20240626",
@@ -193,9 +194,10 @@ strictSetInference = true
typeCheckingMode = "strict"
[tool.pytest.ini_options]
-addopts = "--import-mode=importlib -ra -m 'not inference and not llm and not imgg and not ocr'"
+addopts = "--import-mode=importlib -ra -m 'not inference and not llm and not imgg and not ocr and not needs_output'"
asyncio_default_fixture_loop_scope = "session"
markers = [
+ "needs_output: tests that need output to be displayed",
"inference: slow and costly due to inference calls",
"llm: slow and costly due to llm inference calls",
"imgg: slow and costly due to imgg inference calls",
diff --git a/tests/pipelex/cogt/asynch/content_generator/conftest.py b/tests/pipelex/cogt/asynch/content_generator/conftest.py
deleted file mode 100644
index 6afb61501..000000000
--- a/tests/pipelex/cogt/asynch/content_generator/conftest.py
+++ /dev/null
@@ -1,18 +0,0 @@
-from typing import AsyncGenerator
-
-import pytest_asyncio
-from pytest import FixtureRequest
-from rich import print
-
-from pipelex.cogt.content_generation.content_generator import ContentGenerator
-
-
-@pytest_asyncio.fixture # pyright: ignore[reportUntypedFunctionDecorator, reportUnknownMemberType]
-async def content_generator(request: FixtureRequest) -> AsyncGenerator[ContentGenerator, None]:
- # Code to run before each test
- print("\n[magenta]ContentGenerator setup[/magenta]")
- content_generator = ContentGenerator()
- # Return it for use in tests
- yield content_generator
- # Code to run after each test
- print("\n[magenta]ContentGenerator teardown[/magenta]")
diff --git a/tests/pipelex/cogt/asynch/imgg/test_imgg_fal.py b/tests/pipelex/cogt/asynch/imgg/test_imgg_fal.py
deleted file mode 100644
index 3e2350bb5..000000000
--- a/tests/pipelex/cogt/asynch/imgg/test_imgg_fal.py
+++ /dev/null
@@ -1,23 +0,0 @@
-import pytest
-
-from pipelex import pretty_print
-from pipelex.cogt.imgg.imgg_handle import ImggHandle
-from pipelex.cogt.imgg.imgg_job_factory import ImggJobFactory
-from pipelex.hub import get_imgg_worker
-from tests.pipelex.cogt.test_data import IMGGTestCases
-
-
[email protected](loop_scope="class")
-class TestFalAsync:
- @pytest.mark.parametrize("topic, imgg_prompt_text", IMGGTestCases.IMAGE_DESC)
- async def test_fal_async(self, topic: str, imgg_prompt_text: str, imgg_handle: ImggHandle):
- fal_worker_async = get_imgg_worker(imgg_handle=imgg_handle)
- imgg_job = ImggJobFactory.make_imgg_job_from_prompt_contents(
- positive_text=imgg_prompt_text,
- )
- generated_image = await fal_worker_async.gen_image(
- imgg_job=imgg_job,
- )
- pretty_print(generated_image, title=f"Generated Image, topic={topic}")
diff --git a/tests/pipelex/cogt/asynch/llm_async/__init__.py b/tests/pipelex/cogt/asynch/llm_async/__init__.py
deleted file mode 100644
index 8b1378917..000000000
--- a/tests/pipelex/cogt/asynch/llm_async/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/tests/pipelex/cogt/asynch/llm_providers/__init__.py b/tests/pipelex/cogt/asynch/llm_providers/__init__.py
deleted file mode 100644
index 8b1378917..000000000
--- a/tests/pipelex/cogt/asynch/llm_providers/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/tests/pipelex/asynch/__init__.py b/tests/pipelex/cogt/cogt_asynch/__init__.py
similarity index 100%
rename from tests/pipelex/asynch/__init__.py
rename to tests/pipelex/cogt/cogt_asynch/__init__.py
diff --git a/tests/pipelex/cogt/asynch/content_generator/test_content_generator.py b/tests/pipelex/cogt/cogt_asynch/test_content_generator.py
similarity index 86%
rename from tests/pipelex/cogt/asynch/content_generator/test_content_generator.py
rename to tests/pipelex/cogt/cogt_asynch/test_content_generator.py
index 0a60ffec8..c6945d651 100644
--- a/tests/pipelex/cogt/asynch/content_generator/test_content_generator.py
+++ b/tests/pipelex/cogt/cogt_asynch/test_content_generator.py
@@ -4,7 +4,6 @@ import pytest
from pytest import FixtureRequest
from pipelex import pretty_print
-from pipelex.cogt.content_generation.content_generator import ContentGenerator
from pipelex.cogt.exceptions import LLMHandleNotFoundError
from pipelex.cogt.image.generated_image import GeneratedImage
from pipelex.cogt.imgg.imgg_handle import ImggHandle
@@ -15,7 +14,7 @@ from pipelex.cogt.ocr.ocr_handle import OcrHandle
from pipelex.cogt.ocr.ocr_input import OcrInput
from pipelex.cogt.ocr.ocr_job_components import OcrJobConfig, OcrJobParams
from pipelex.cogt.ocr.ocr_output import OcrOutput
-from pipelex.hub import get_llm_deck
+from pipelex.hub import get_content_generator, get_llm_deck
from pipelex.mission.job_metadata import JobMetadata
from tests.pipelex.cogt.test_data import Employee
from tests.test_data import ImageTestCases
@@ -51,14 +50,20 @@ Write a haiku about the meaning of life
"""
+# The ContentGenerator has features that xork without inference (jinja2) or with LLM, Image generation, OCR
+# So to run them all you need to bypass the marker restrictions defined in the pyproject.toml pytest section
+# like this:
+# pytest -m "" -k TestContentGenerator
+# and if you cant more prints:
+# pytest -m "" -k TestContentGenerator -s -vv
@pytest.mark.asyncio(loop_scope="class")
class TestContentGenerator:
@pytest.mark.llm
@pytest.mark.inference
- async def test_make_llm_text_only(self, request: FixtureRequest, content_generator: ContentGenerator):
+ async def test_make_llm_text_only(self, request: FixtureRequest):
llm_setting_main = get_llm_deck().get_llm_setting(llm_setting_or_preset_id="llm_for_testing_gen_text")
- text: str = await content_generator.make_llm_text(
+ text: str = await get_content_generator().make_llm_text(
job_metadata=JobMetadata(
top_job_id=cast(str, request.node.originalname), # pyright: ignore[reportUnknownMemberType]
),
@@ -71,10 +76,10 @@ class TestContentGenerator:
@pytest.mark.llm
@pytest.mark.inference
- async def test_make_object_direct(self, request: FixtureRequest, content_generator: ContentGenerator):
+ async def test_make_object_direct(self, request: FixtureRequest):
llm_setting_for_object = get_llm_deck().get_llm_setting(llm_setting_or_preset_id="llm_for_testing_gen_object")
- person_direct: Employee = await content_generator.make_object_direct(
+ person_direct: Employee = await get_content_generator().make_object_direct(
job_metadata=JobMetadata(
top_job_id=cast(str, request.node.originalname), # pyright: ignore[reportUnknownMemberType]
),
@@ -88,10 +93,10 @@ class TestContentGenerator:
@pytest.mark.llm
@pytest.mark.inference
- async def test_make_object_list_direct(self, request: FixtureRequest, content_generator: ContentGenerator):
+ async def test_make_object_list_direct(self, request: FixtureRequest):
llm_setting_for_object = get_llm_deck().get_llm_setting(llm_setting_or_preset_id="llm_for_testing_gen_object")
- person_list_direct: List[Employee] = await content_generator.make_object_list_direct(
+ person_list_direct: List[Employee] = await get_content_generator().make_object_list_direct(
job_metadata=JobMetadata(
top_job_id=cast(str, request.node.originalname), # pyright: ignore[reportUnknownMemberType]
),
@@ -106,8 +111,8 @@ class TestContentGenerator:
@pytest.mark.imgg
@pytest.mark.inference
- async def test_make_image(self, request: FixtureRequest, content_generator: ContentGenerator):
- image: GeneratedImage = await content_generator.make_single_image(
+ async def test_make_image(self, request: FixtureRequest):
+ image: GeneratedImage = await get_content_generator().make_single_image(
job_metadata=JobMetadata(
top_job_id=cast(str, request.node.originalname), # pyright: ignore[reportUnknownMemberType]
),
@@ -119,12 +124,12 @@ class TestContentGenerator:
pretty_print(image, title="make_image")
assert isinstance(image, GeneratedImage)
- async def test_make_jinja2_text(self, request: FixtureRequest, content_generator: ContentGenerator):
+ async def test_make_jinja2_text(self, request: FixtureRequest):
context = {
"the_answer": "elementary, my dear Watson",
}
- jinja2_text: str = await content_generator.make_jinja2_text(
+ jinja2_text: str = await get_content_generator().make_jinja2_text(
context=context,
jinja2="The answer is: {{ the_answer }}",
)
@@ -134,8 +139,8 @@ class TestContentGenerator:
@pytest.mark.ocr
@pytest.mark.inference
- async def test_make_ocr_extract_pages(self, request: FixtureRequest, content_generator: ContentGenerator):
- ocr_output = await content_generator.make_ocr_extract_pages(
+ async def test_make_ocr_extract_pages(self, request: FixtureRequest):
+ ocr_output = await get_content_generator().make_ocr_extract_pages(
job_metadata=JobMetadata(
top_job_id=cast(str, request.node.originalname), # pyright: ignore[reportUnknownMemberType]
),
@@ -149,11 +154,11 @@ class TestContentGenerator:
@pytest.mark.llm
@pytest.mark.inference
- async def test_make_llm_text_with_error(self, request: FixtureRequest, content_generator: ContentGenerator):
+ async def test_make_llm_text_with_error(self, request: FixtureRequest):
BAD_HANDLE_TO_TEST_FAILURE = "bad_handle_to_test_failure"
llm_setting_main = LLMSetting(llm_handle=BAD_HANDLE_TO_TEST_FAILURE, temperature=0.5, max_tokens=100)
with pytest.raises(LLMHandleNotFoundError) as excinfo:
- await content_generator.make_llm_text(
+ await get_content_generator().make_llm_text(
job_metadata=JobMetadata(
top_job_id=cast(str, request.node.originalname), # pyright: ignore[reportUnknownMemberType]
),
diff --git a/tests/pipelex/cogt/asynch/imgg/test_image_gen.py b/tests/pipelex/cogt/cogt_asynch/test_image_gen.py
similarity index 94%
rename from tests/pipelex/cogt/asynch/imgg/test_image_gen.py
rename to tests/pipelex/cogt/cogt_asynch/test_image_gen.py
index 23888c720..510488aa5 100644
--- a/tests/pipelex/cogt/asynch/imgg/test_image_gen.py
+++ b/tests/pipelex/cogt/cogt_asynch/test_image_gen.py
@@ -3,7 +3,7 @@ import pytest
from pipelex import pretty_print
from pipelex.cogt.imgg.imgg_job_factory import ImggJobFactory
from pipelex.hub import get_imgg_worker
-from tests.pipelex.cogt.test_data import IMGGTestCases
+from tests.pipelex.test_data import IMGGTestCases
@pytest.mark.imgg
diff --git a/tests/pipelex/cogt/asynch/llm_async/test_llm_engines.py b/tests/pipelex/cogt/cogt_asynch/test_llm_engines.py
similarity index 100%
rename from tests/pipelex/cogt/asynch/llm_async/test_llm_engines.py
rename to tests/pipelex/cogt/cogt_asynch/test_llm_engines.py
diff --git a/tests/pipelex/cogt/asynch/llm_async/test_llm_gen_object.py b/tests/pipelex/cogt/cogt_asynch/test_llm_gen_object.py
similarity index 100%
rename from tests/pipelex/cogt/asynch/llm_async/test_llm_gen_object.py
rename to tests/pipelex/cogt/cogt_asynch/test_llm_gen_object.py
diff --git a/tests/pipelex/cogt/asynch/llm_async/test_llm_gen_text.py b/tests/pipelex/cogt/cogt_asynch/test_llm_gen_text.py
similarity index 100%
rename from tests/pipelex/cogt/asynch/llm_async/test_llm_gen_text.py
rename to tests/pipelex/cogt/cogt_asynch/test_llm_gen_text.py
diff --git a/tests/pipelex/cogt/asynch/llm_async/test_llm_job_async_factory.py b/tests/pipelex/cogt/cogt_asynch/test_llm_job_async_factory.py
similarity index 100%
rename from tests/pipelex/cogt/asynch/llm_async/test_llm_job_async_factory.py
rename to tests/pipelex/cogt/cogt_asynch/test_llm_job_async_factory.py
diff --git a/tests/pipelex/cogt/asynch/llm_async/test_llm_report.py b/tests/pipelex/cogt/cogt_asynch/test_llm_report.py
similarity index 100%
rename from tests/pipelex/cogt/asynch/llm_async/test_llm_report.py
rename to tests/pipelex/cogt/cogt_asynch/test_llm_report.py
diff --git a/tests/pipelex/cogt/asynch/llm_async/test_llm_vision.py b/tests/pipelex/cogt/cogt_asynch/test_llm_vision.py
similarity index 100%
rename from tests/pipelex/cogt/asynch/llm_async/test_llm_vision.py
rename to tests/pipelex/cogt/cogt_asynch/test_llm_vision.py
diff --git a/tests/pipelex/cogt/asynch/ocr/test_ocr.py b/tests/pipelex/cogt/cogt_asynch/test_ocr.py
similarity index 100%
rename from tests/pipelex/cogt/asynch/ocr/test_ocr.py
rename to tests/pipelex/cogt/cogt_asynch/test_ocr.py
diff --git a/tests/pipelex/cogt/synchro/__init__.py b/tests/pipelex/cogt/synchro/__init__.py
deleted file mode 100644
index 8b1378917..000000000
--- a/tests/pipelex/cogt/synchro/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/tests/pipelex/cogt/synchro/llm_providers/__init__.py b/tests/pipelex/cogt/synchro/llm_providers/__init__.py
deleted file mode 100644
index 8b1378917..000000000
--- a/tests/pipelex/cogt/synchro/llm_providers/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/tests/pipelex/cogt/synchro/llm_providers/conftest.py b/tests/pipelex/cogt/synchro/llm_providers/conftest.py
deleted file mode 100644
index 19a5312f2..000000000
--- a/tests/pipelex/cogt/synchro/llm_providers/conftest.py
+++ /dev/null
@@ -1,13 +0,0 @@
-import pytest
-
-
[email protected](params=["anthropic", "mistral", "meta", "amazon"])
-def bedrock_provider(request: pytest.FixtureRequest) -> str:
- assert isinstance(request.param, str)
- return request.param
-
-
[email protected](params=["us-east-1", "us-west-2"])
-def bedrock_region_name(request: pytest.FixtureRequest) -> str:
- assert isinstance(request.param, str)
- return request.param
diff --git a/tests/pipelex/cogt/synchro/serde/__init__.py b/tests/pipelex/cogt/synchro/serde/__init__.py
deleted file mode 100644
index 8b1378917..000000000
--- a/tests/pipelex/cogt/synchro/serde/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/tests/pipelex/cogt/synchro/serde/conftest.py b/tests/pipelex/cogt/synchro/serde/conftest.py
deleted file mode 100644
index ecbde1d94..000000000
--- a/tests/pipelex/cogt/synchro/serde/conftest.py
+++ /dev/null
@@ -1,62 +0,0 @@
-from typing import Any, ClassVar, Dict, List
-
-from pydantic import BaseModel
-
-from pipelex.cogt.image.prompt_image import PromptImagePath
-from pipelex.cogt.llm.llm_prompt import LLMPrompt
-from pipelex.cogt.llm.llm_prompt_template import LLMPromptTemplate
-from pipelex.cogt.llm.llm_prompt_template_inputs import LLMPromptTemplateInputs
-
-proto_prompt = LLMPrompt(
- user_text="Some user text in the template",
-)
-
-base_template_inputs_1 = LLMPromptTemplateInputs(
- root={"foo": "bar"},
-)
-
-my_prompt_template_model_1 = LLMPromptTemplate(
- proto_prompt=proto_prompt,
- base_template_inputs=base_template_inputs_1,
-)
-
-base_template_inputs_2 = LLMPromptTemplateInputs(
- root={},
-)
-
-my_prompt_template_model_2 = LLMPromptTemplate(
- proto_prompt=proto_prompt,
- base_template_inputs=base_template_inputs_2,
-)
-
-dict_1 = {
- "proto_prompt": LLMPrompt(
- system_text=None,
- user_text="Some user text in the template",
- user_images=[],
- ),
- "base_template_inputs": LLMPromptTemplateInputs(root={}),
- "source_system_template_name": None,
- "source_user_template_name": "markdown_reordering_vision_claude3_5_sonnet",
-}
-
-prompt_with_image_path = LLMPrompt(
- system_text="Some system text",
- user_text="Some user text",
- user_images=[
- PromptImagePath(file_path="some_file_path"),
- ],
-)
-
-
-class SerDeTestCases:
- PYDANTIC_EXAMPLES: ClassVar[List[BaseModel]] = [
- my_prompt_template_model_1,
- my_prompt_template_model_2,
- ]
- PYDANTIC_EXAMPLES_USING_SUBCLASS: ClassVar[List[BaseModel]] = [
- prompt_with_image_path,
- ]
- PYDANTIC_EXAMPLES_DICT: ClassVar[List[Dict[str, Any]]] = [
- dict_1,
- ]
diff --git a/tests/pipelex/cogt/test_data.py b/tests/pipelex/cogt/test_data.py
index 57f2785ad..7a9e6efc5 100644
--- a/tests/pipelex/cogt/test_data.py
+++ b/tests/pipelex/cogt/test_data.py
@@ -1,8 +1,12 @@
from enum import StrEnum
-from typing import ClassVar, List, Tuple
+from typing import Any, ClassVar, Dict, List, Tuple
from pydantic import BaseModel, Field, field_validator
+from pipelex.cogt.image.prompt_image import PromptImagePath
+from pipelex.cogt.llm.llm_prompt import LLMPrompt
+from pipelex.cogt.llm.llm_prompt_template import LLMPromptTemplate
+from pipelex.cogt.llm.llm_prompt_template_inputs import LLMPromptTemplateInputs
from tests.pipelex.test_data import PipeTestCases
@@ -133,16 +137,59 @@ How tall do you think he was when he was 12? and at 15?
]
-class IMGGTestCases:
- IMGG_PROMPT_1 = "woman wearing marino cargo pants"
- IMGG_PROMPT_2 = "wide legged denim pants with hippy addition"
- IMGG_PROMPT_3 = """
-Woman typing on a laptop. On the laptop screen you see python code to generate code to write a prompt for an AI model.
-"""
+class SerDeTestLLMCases:
+ """Constants and example objects used for SerDe unit tests."""
+
+ # Base building blocks -------------------------------------------------
+ PROTO_PROMPT: ClassVar[LLMPrompt] = LLMPrompt(
+ user_text="Some user text in the template",
+ )
+
+ BASE_TEMPLATE_INPUTS_1: ClassVar[LLMPromptTemplateInputs] = LLMPromptTemplateInputs(
+ root={"foo": "bar"},
+ )
+ MY_PROMPT_TEMPLATE_MODEL_1: ClassVar[LLMPromptTemplate] = LLMPromptTemplate(
+ proto_prompt=PROTO_PROMPT,
+ base_template_inputs=BASE_TEMPLATE_INPUTS_1,
+ )
+
+ BASE_TEMPLATE_INPUTS_2: ClassVar[LLMPromptTemplateInputs] = LLMPromptTemplateInputs(
+ root={},
+ )
+ MY_PROMPT_TEMPLATE_MODEL_2: ClassVar[LLMPromptTemplate] = LLMPromptTemplate(
+ proto_prompt=PROTO_PROMPT,
+ base_template_inputs=BASE_TEMPLATE_INPUTS_2,
+ )
+
+ # Dictionary representation example ------------------------------------
+ DICT_1: ClassVar[Dict[str, Any]] = {
+ "proto_prompt": LLMPrompt(
+ system_text=None,
+ user_text="Some user text in the template",
+ user_images=[],
+ ),
+ "base_template_inputs": LLMPromptTemplateInputs(root={}),
+ "source_system_template_name": None,
+ "source_user_template_name": "markdown_reordering_vision_claude3_5_sonnet",
+ }
+
+ # Prompt containing an image path --------------------------------------
+ PROMPT_WITH_IMAGE_PATH: ClassVar[LLMPrompt] = LLMPrompt(
+ system_text="Some system text",
+ user_text="Some user text",
+ user_images=[
+ PromptImagePath(file_path="some_file_path"),
+ ],
+ )
- IMAGE_DESC: ClassVar[List[Tuple[str, str]]] = [ # topic, imgg_prompt_text
- # (IMGG_PROMPT_1, IMGG_PROMPT_1),
- # (IMGG_PROMPT_2, IMGG_PROMPT_2),
- # (IMGG_PROMPT_3, IMGG_PROMPT_3),
- ("coding girl", "a girl with a dragon tatoo, coding in python"),
+ # Group constants for parametrization ----------------------------------
+ PYDANTIC_EXAMPLES: ClassVar[List[BaseModel]] = [
+ MY_PROMPT_TEMPLATE_MODEL_1,
+ MY_PROMPT_TEMPLATE_MODEL_2,
+ ]
+ PYDANTIC_EXAMPLES_USING_SUBCLASS: ClassVar[List[BaseModel]] = [
+ PROMPT_WITH_IMAGE_PATH,
+ ]
+ PYDANTIC_EXAMPLES_DICT: ClassVar[List[Dict[str, Any]]] = [
+ DICT_1,
]
diff --git a/tests/pipelex/cogt/synchro/test_llm_model_provider.py b/tests/pipelex/cogt/test_llm_models_library.py
similarity index 100%
rename from tests/pipelex/cogt/synchro/test_llm_model_provider.py
rename to tests/pipelex/cogt/test_llm_models_library.py
diff --git a/tests/pipelex/cogt/synchro/serde/test_serde_llm_classes.py b/tests/pipelex/cogt/test_serde_llm_classes.py
similarity index 87%
rename from tests/pipelex/cogt/synchro/serde/test_serde_llm_classes.py
rename to tests/pipelex/cogt/test_serde_llm_classes.py
index d2aae88f7..a89f0e824 100644
--- a/tests/pipelex/cogt/synchro/serde/test_serde_llm_classes.py
+++ b/tests/pipelex/cogt/test_serde_llm_classes.py
@@ -6,12 +6,11 @@ from pydantic import BaseModel
from pipelex import pretty_print
from pipelex.cogt.llm.llm_prompt_template import LLMPromptTemplate
-
-from .conftest import SerDeTestCases
+from tests.pipelex.cogt.test_data import SerDeTestLLMCases
class TestSerDeLLMClasses:
- @pytest.mark.parametrize("test_obj", SerDeTestCases.PYDANTIC_EXAMPLES + SerDeTestCases.PYDANTIC_EXAMPLES_USING_SUBCLASS)
+ @pytest.mark.parametrize("test_obj", SerDeTestLLMCases.PYDANTIC_EXAMPLES + SerDeTestLLMCases.PYDANTIC_EXAMPLES_USING_SUBCLASS)
def test_serde_by_str(self, test_obj: Any):
# Serialize the model to a json string
serialized_str: str = kajson.dumps(test_obj, indent=4) # pyright: ignore[reportUnknownMemberType]
@@ -22,7 +21,7 @@ class TestSerDeLLMClasses:
# Assertions to ensure the process worked correctly
assert test_obj == deserialized
- @pytest.mark.parametrize("test_obj", SerDeTestCases.PYDANTIC_EXAMPLES)
+ @pytest.mark.parametrize("test_obj", SerDeTestLLMCases.PYDANTIC_EXAMPLES)
def test_serde_by_dump(
self,
test_obj: BaseModel,
@@ -40,7 +39,7 @@ class TestSerDeLLMClasses:
assert test_obj == deserialized
- @pytest.mark.parametrize("test_dict", SerDeTestCases.PYDANTIC_EXAMPLES_DICT)
+ @pytest.mark.parametrize("test_dict", SerDeTestLLMCases.PYDANTIC_EXAMPLES_DICT)
def test_serde_model_validate_from_dict(
self,
test_dict: Dict[str, Any],
@@ -61,7 +60,7 @@ class TestSerDeLLMClasses:
assert the_obj == deserialized
- @pytest.mark.parametrize("test_dict", SerDeTestCases.PYDANTIC_EXAMPLES_DICT)
+ @pytest.mark.parametrize("test_dict", SerDeTestLLMCases.PYDANTIC_EXAMPLES_DICT)
def test_serde_instantiate_from_kwargs(
self,
test_dict: Dict[str, Any],
diff --git a/tests/pipelex/cogt/synchro/test_setup_workers.py b/tests/pipelex/cogt/test_setup_inference_workers.py
similarity index 88%
rename from tests/pipelex/cogt/synchro/test_setup_workers.py
rename to tests/pipelex/cogt/test_setup_inference_workers.py
index 165f30161..27321c84f 100644
--- a/tests/pipelex/cogt/synchro/test_setup_workers.py
+++ b/tests/pipelex/cogt/test_setup_inference_workers.py
@@ -5,7 +5,7 @@ from pipelex.hub import get_inference_manager
@pytest.mark.gha_disabled
@pytest.mark.codex_disabled
-class TestCogtSetupWorkers:
+class TestSetupInferenceWorkers:
def test_setup_inference_manager(self):
get_inference_manager().setup_llm_workers()
get_inference_manager().setup_imgg_workers()
diff --git a/tests/pipelex/cogt/asynch/__init__.py b/tests/pipelex/pipelex_asynch/__init__.py
similarity index 100%
rename from tests/pipelex/cogt/asynch/__init__.py
rename to tests/pipelex/pipelex_asynch/__init__.py
diff --git a/tests/pipelex/asynch/conftest.py b/tests/pipelex/pipelex_asynch/conftest.py
similarity index 77%
rename from tests/pipelex/asynch/conftest.py
rename to tests/pipelex/pipelex_asynch/conftest.py
index 5ce3a3fa8..0b78a8552 100644
--- a/tests/pipelex/asynch/conftest.py
+++ b/tests/pipelex/pipelex_asynch/conftest.py
@@ -1,31 +1,17 @@
import os
-from typing import AsyncGenerator, AsyncIterator, Awaitable, Callable
+from typing import AsyncIterator, Awaitable, Callable
import pytest_asyncio
from pytest import FixtureRequest
-from rich import print
from pipelex.core.pipe_output import PipeOutput
from pipelex.hub import get_activity_manager
from pipelex.mission.activity.activity_handler import ActivityHandlerForResultFiles
-from pipelex.pipe_works.pipe_router import PipeRouter
-from pipelex.pipe_works.pipe_router_protocol import PipeRouterProtocol
from pipelex.tools.misc.file_utils import get_incremental_directory_path, remove_folder
from pipelex.tools.misc.json_utils import save_as_json_to_path
from tests.conftest import TEST_OUTPUTS_DIR
-@pytest_asyncio.fixture # pyright: ignore[reportUntypedFunctionDecorator, reportUnknownMemberType]
-async def pipe_router(request: FixtureRequest) -> AsyncGenerator[PipeRouterProtocol, None]:
- # Code to run before each PipeRouter
- print("\n[magenta]PipeRouter setup[/magenta]")
- the_pipe_router = PipeRouter()
- # Return it for use in tests
- yield the_pipe_router
- # Code to run after each test
- print("\n[magenta]PipeRouter teardown[/magenta]")
-
-
@pytest_asyncio.fixture # pyright: ignore[reportUntypedFunctionDecorator, reportUnknownMemberType]
async def pipe_result_handler(request: FixtureRequest) -> AsyncIterator[tuple[str, ActivityHandlerForResultFiles]]:
"""
diff --git a/tests/pipelex/asynch/test_client.py b/tests/pipelex/pipelex_asynch/test_client.py
similarity index 100%
rename from tests/pipelex/asynch/test_client.py
rename to tests/pipelex/pipelex_asynch/test_client.py
diff --git a/tests/pipelex/asynch/test_pipe_batch.py b/tests/pipelex/pipelex_asynch/test_pipe_batch.py
similarity index 80%
rename from tests/pipelex/asynch/test_pipe_batch.py
rename to tests/pipelex/pipelex_asynch/test_pipe_batch.py
index 0aa502d84..4adac5ddb 100644
--- a/tests/pipelex/asynch/test_pipe_batch.py
+++ b/tests/pipelex/pipelex_asynch/test_pipe_batch.py
@@ -1,5 +1,4 @@
import pytest
-from pytest import FixtureRequest
from pipelex import pretty_print
from pipelex.core.pipe_output import PipeOutput
@@ -7,19 +6,14 @@ from pipelex.core.pipe_run_params_factory import PipeRunParamsFactory
from pipelex.core.stuff_content import ListContent, TextContent
from pipelex.core.stuff_factory import StuffFactory
from pipelex.core.working_memory_factory import WorkingMemoryFactory
-from pipelex.hub import get_mission_tracker, get_report_delegate
-from pipelex.pipe_works.pipe_router_protocol import PipeRouterProtocol
+from pipelex.hub import get_mission_tracker, get_pipe_router, get_report_delegate
@pytest.mark.llm
@pytest.mark.inference
@pytest.mark.asyncio(loop_scope="class")
class TestPipeBatch:
- async def test_pipe_batch_basic(
- self,
- request: FixtureRequest,
- pipe_router: PipeRouterProtocol,
- ):
+ async def test_pipe_batch_basic(self):
# Create Stuff objects
invoice_list_stuff = StuffFactory.make_stuff(
concept_code="test_pipe_batch.TestPipeBatchItem",
@@ -36,7 +30,7 @@ class TestPipeBatch:
working_memory = WorkingMemoryFactory.make_from_single_stuff(invoice_list_stuff)
# Run the pipe
- pipe_output: PipeOutput = await pipe_router.run_pipe_code(
+ pipe_output: PipeOutput = await get_pipe_router().run_pipe_code(
pipe_code="test_pipe_batch",
pipe_run_params=PipeRunParamsFactory.make_run_params(),
working_memory=working_memory,
diff --git a/tests/pipelex/asynch/test_pipe_imgg.py b/tests/pipelex/pipelex_asynch/test_pipe_imgg.py
similarity index 95%
rename from tests/pipelex/asynch/test_pipe_imgg.py
rename to tests/pipelex/pipelex_asynch/test_pipe_imgg.py
index 8b7fc38f4..053660213 100644
--- a/tests/pipelex/asynch/test_pipe_imgg.py
+++ b/tests/pipelex/pipelex_asynch/test_pipe_imgg.py
@@ -6,7 +6,7 @@ from pipelex.core.concept_native import NativeConcept
from pipelex.hub import get_pipe_router
from pipelex.pipe_operators.pipe_img_gen import PipeImgGen, PipeImgGenOutput
from pipelex.pipe_works.pipe_job_factory import PipeJobFactory
-from tests.pipelex.cogt.test_data import IMGGTestCases
+from tests.pipelex.test_data import IMGGTestCases
@pytest.mark.imgg
diff --git a/tests/pipelex/asynch/test_pipe_llm.py b/tests/pipelex/pipelex_asynch/test_pipe_llm.py
similarity index 87%
rename from tests/pipelex/asynch/test_pipe_llm.py
rename to tests/pipelex/pipelex_asynch/test_pipe_llm.py
index d78717a23..bf13ef7d8 100644
--- a/tests/pipelex/asynch/test_pipe_llm.py
+++ b/tests/pipelex/pipelex_asynch/test_pipe_llm.py
@@ -6,11 +6,10 @@ from pipelex import log, pretty_print
from pipelex.core.concept_native import NativeConcept
from pipelex.core.stuff import Stuff
from pipelex.core.working_memory_factory import WorkingMemoryFactory
-from pipelex.hub import get_report_delegate
+from pipelex.hub import get_pipe_router, get_report_delegate
from pipelex.pipe_operators.pipe_llm import PipeLLM, PipeLLMOutput
from pipelex.pipe_operators.pipe_llm_prompt import PipeLLMPrompt
from pipelex.pipe_works.pipe_job_factory import PipeJobFactory
-from pipelex.pipe_works.pipe_router_protocol import PipeRouterProtocol
from tests.pipelex.test_data import PipeTestCases
@@ -18,7 +17,7 @@ from tests.pipelex.test_data import PipeTestCases
@pytest.mark.inference
@pytest.mark.asyncio(loop_scope="class")
class TestPipeLLM:
- async def test_pipe_llm(self, pipe_router: PipeRouterProtocol):
+ async def test_pipe_llm(self):
pipe_job = PipeJobFactory.make_pipe_job(
pipe=PipeLLM(
code="adhoc_for_test_pipe_llm",
@@ -32,7 +31,7 @@ class TestPipeLLM:
),
),
)
- pipe_llm_output: PipeLLMOutput = await pipe_router.run_pipe_job(
+ pipe_llm_output: PipeLLMOutput = await get_pipe_router().run_pipe_job(
pipe_job=pipe_job,
)
@@ -47,7 +46,6 @@ class TestPipeLLM:
@pytest.mark.parametrize("stuff, attribute_paths", PipeTestCases.STUFFS_IMAGE_ATTRIBUTES)
async def test_pipe_llm_attribute_image(
self,
- pipe_router: PipeRouterProtocol,
stuff: Stuff,
attribute_paths: List[str],
):
@@ -68,7 +66,7 @@ class TestPipeLLM:
),
),
)
- pipe_llm_output: PipeLLMOutput = await pipe_router.run_pipe_job(
+ pipe_llm_output: PipeLLMOutput = await get_pipe_router().run_pipe_job(
pipe_job=pipe_job,
)
diff --git a/tests/pipelex/asynch/test_pipe_ocr.py b/tests/pipelex/pipelex_asynch/test_pipe_ocr.py
similarity index 89%
rename from tests/pipelex/asynch/test_pipe_ocr.py
rename to tests/pipelex/pipelex_asynch/test_pipe_ocr.py
index e5e3e3eed..1120d1db5 100644
--- a/tests/pipelex/asynch/test_pipe_ocr.py
+++ b/tests/pipelex/pipelex_asynch/test_pipe_ocr.py
@@ -4,9 +4,9 @@ from pipelex import pretty_print
from pipelex.core.concept_native import NativeConcept
from pipelex.core.stuff_content import PageContent
from pipelex.core.working_memory_factory import WorkingMemoryFactory
+from pipelex.hub import get_pipe_router
from pipelex.pipe_operators.pipe_ocr import PipeOcr, PipeOcrOutput
from pipelex.pipe_works.pipe_job_factory import PipeJobFactory
-from pipelex.pipe_works.pipe_router_protocol import PipeRouterProtocol
from tests.pipelex.test_data import PipeOcrTestCases
@@ -17,7 +17,6 @@ class TestPipeOCR:
@pytest.mark.parametrize("image_url", PipeOcrTestCases.PIPE_OCR_IMAGE_TEST_CASES)
async def test_pipe_ocr_image(
self,
- pipe_router: PipeRouterProtocol,
image_url: str,
):
pipe_job = PipeJobFactory.make_pipe_job(
@@ -37,7 +36,7 @@ class TestPipeOCR:
name="page_scan",
),
)
- pipe_ocr_output: PipeOcrOutput = await pipe_router.run_pipe_job(
+ pipe_ocr_output: PipeOcrOutput = await get_pipe_router().run_pipe_job(
pipe_job=pipe_job,
)
ocr_text = pipe_ocr_output.main_stuff_as_list(item_type=PageContent)
@@ -46,7 +45,6 @@ class TestPipeOCR:
@pytest.mark.parametrize("pdf_url", PipeOcrTestCases.PIPE_OCR_PDF_TEST_CASES)
async def test_pipe_ocr_pdf(
self,
- pipe_router: PipeRouterProtocol,
pdf_url: str,
):
pipe_job = PipeJobFactory.make_pipe_job(
@@ -66,7 +64,7 @@ class TestPipeOCR:
name="pdf",
),
)
- pipe_ocr_output: PipeOcrOutput = await pipe_router.run_pipe_job(
+ pipe_ocr_output: PipeOcrOutput = await get_pipe_router().run_pipe_job(
pipe_job=pipe_job,
)
ocr_text = pipe_ocr_output.main_stuff_as_list(item_type=PageContent)
diff --git a/tests/pipelex/asynch/test_simple_pipe_run.py b/tests/pipelex/pipelex_asynch/test_pipe_run.py
similarity index 98%
rename from tests/pipelex/asynch/test_simple_pipe_run.py
rename to tests/pipelex/pipelex_asynch/test_pipe_run.py
index 76687e0fa..df7ed7d82 100644
--- a/tests/pipelex/asynch/test_simple_pipe_run.py
+++ b/tests/pipelex/pipelex_asynch/test_pipe_run.py
@@ -15,7 +15,7 @@ from tests.pipelex.test_data import PipeTestCases
@pytest.mark.ocr
@pytest.mark.inference
@pytest.mark.asyncio(loop_scope="class")
-class TestSimplePipeRun:
+class TestPipeRun:
async def test_pipe_run(self):
working_memory = WorkingMemoryFactory.make_from_text(
text=PipeTestCases.USER_TEXT_COLORS,
diff --git a/tests/pipelex/asynch/test_pipe_router.py b/tests/pipelex/pipelex_asynch/test_pipe_running_variants.py
similarity index 92%
rename from tests/pipelex/asynch/test_pipe_router.py
rename to tests/pipelex/pipelex_asynch/test_pipe_running_variants.py
index 3b28fb352..2d7b4bf8c 100644
--- a/tests/pipelex/asynch/test_pipe_router.py
+++ b/tests/pipelex/pipelex_asynch/test_pipe_running_variants.py
@@ -14,7 +14,6 @@ from pipelex.core.working_memory_factory import WorkingMemoryFactory
from pipelex.hub import get_mission_tracker, get_pipe_router, get_report_delegate
from pipelex.mission.activity.activity_handler import ActivityHandlerForResultFiles
from pipelex.mission.job_metadata import JobMetadata
-from pipelex.pipe_works.pipe_router_protocol import PipeRouterProtocol
from tests.pipelex.test_data import PipeTestCases
@@ -32,11 +31,10 @@ class TestPipeRouter:
topic: str,
blueprint: StuffBlueprint,
pipe_code: str,
- pipe_router: PipeRouterProtocol,
):
log.verbose(blueprint, title=f"{topic}: start from '{blueprint.name}', run pipe '{pipe_code}'")
working_memory = WorkingMemoryFactory.make_from_single_blueprint(blueprint=blueprint)
- pipe_output: PipeOutput = await pipe_router.run_pipe_code(
+ pipe_output: PipeOutput = await get_pipe_router().run_pipe_code(
pipe_code=pipe_code,
pipe_run_params=PipeRunParamsFactory.make_run_params(),
working_memory=working_memory,
@@ -62,11 +60,10 @@ class TestPipeRouter:
topic: str,
stuff: Stuff,
pipe_code: str,
- pipe_router: PipeRouterProtocol,
):
log.verbose(stuff, title=f"{topic}: start from '{stuff.stuff_name}', run pipe '{pipe_code}'")
working_memory = WorkingMemoryFactory.make_from_single_stuff(stuff=stuff)
- pipe_output: PipeOutput = await pipe_router.run_pipe_code(
+ pipe_output: PipeOutput = await get_pipe_router().run_pipe_code(
pipe_code=pipe_code,
pipe_run_params=PipeRunParamsFactory.make_run_params(),
working_memory=working_memory,
@@ -88,10 +85,9 @@ class TestPipeRouter:
save_working_memory: Any,
topic: str,
pipe_code: str,
- pipe_router: PipeRouterProtocol,
):
log.verbose(f"{topic}: just run pipe '{pipe_code}'")
- pipe_output: PipeOutput = await pipe_router.run_pipe_code(
+ pipe_output: PipeOutput = await get_pipe_router().run_pipe_code(
pipe_code=pipe_code,
pipe_run_params=PipeRunParamsFactory.make_run_params(),
working_memory=WorkingMemory(),
@@ -114,7 +110,6 @@ class TestPipeRouter:
async def test_pipe_batch_no_input(
self,
request: FixtureRequest,
- pipe_router: PipeRouterProtocol,
pipe_result_handler: Tuple[str, ActivityHandlerForResultFiles],
save_working_memory: Any,
topic: str,
@@ -122,7 +117,7 @@ class TestPipeRouter:
output_multiplicity: Optional[PipeOutputMultiplicity],
):
log.verbose(f"{topic}: just run pipe '{pipe_code}'")
- pipe_output: PipeOutput = await pipe_router.run_pipe_code(
+ pipe_output: PipeOutput = await get_pipe_router().run_pipe_code(
pipe_code=pipe_code,
pipe_run_params=PipeRunParamsFactory.make_run_params(
output_multiplicity=output_multiplicity,
@@ -149,14 +144,13 @@ class TestPipeRouter:
request: FixtureRequest,
pipe_result_handler: Tuple[str, ActivityHandlerForResultFiles],
save_working_memory: Any,
- pipe_router: PipeRouterProtocol,
pipe_code: str,
stuff: Stuff,
input_list_stuff_name: str,
input_item_stuff_name: str,
):
working_memory = WorkingMemoryFactory.make_from_single_stuff(stuff=stuff)
- pipe_output: PipeOutput = await pipe_router.run_pipe_code(
+ pipe_output: PipeOutput = await get_pipe_router().run_pipe_code(
pipe_code=pipe_code,
pipe_run_params=PipeRunParamsFactory.make_run_params(
batch_params=BatchParams(
diff --git a/tests/pipelex/cogt/asynch/imgg/__init__.py b/tests/pipelex/plugin/__init__.py
similarity index 100%
rename from tests/pipelex/cogt/asynch/imgg/__init__.py
rename to tests/pipelex/plugin/__init__.py
diff --git a/tests/pipelex/cogt/asynch/llm_providers/conftest.py b/tests/pipelex/plugin/conftest.py
similarity index 57%
rename from tests/pipelex/cogt/asynch/llm_providers/conftest.py
rename to tests/pipelex/plugin/conftest.py
index 0072729b4..b109439bf 100644
--- a/tests/pipelex/cogt/asynch/llm_providers/conftest.py
+++ b/tests/pipelex/plugin/conftest.py
@@ -13,3 +13,15 @@ def llm_platform_for_openai_sdk(request: pytest.FixtureRequest) -> LLMPlatform:
def llm_platform_for_anthropic_sdk(request: pytest.FixtureRequest) -> LLMPlatform:
assert isinstance(request.param, LLMPlatform)
return request.param
+
+
[email protected](params=["anthropic", "mistral", "meta", "amazon"])
+def bedrock_provider(request: pytest.FixtureRequest) -> str:
+ assert isinstance(request.param, str)
+ return request.param
+
+
[email protected](params=["us-east-1", "us-west-2"])
+def bedrock_region_name(request: pytest.FixtureRequest) -> str:
+ assert isinstance(request.param, str)
+ return request.param
diff --git a/tests/pipelex/cogt/asynch/llm_providers/test_anthropic.py b/tests/pipelex/plugin/test_anthropic.py
similarity index 94%
rename from tests/pipelex/cogt/asynch/llm_providers/test_anthropic.py
rename to tests/pipelex/plugin/test_anthropic.py
index 51b4a698c..3117040c6 100644
--- a/tests/pipelex/cogt/asynch/llm_providers/test_anthropic.py
+++ b/tests/pipelex/plugin/test_anthropic.py
@@ -5,11 +5,10 @@ from rich.table import Table
from pipelex.cogt.exceptions import LLMSDKError
from pipelex.cogt.llm.llm_models.llm_platform import LLMPlatform
-from pipelex.cogt.plugin.anthropic.anthropic_llms import anthropic_list_anthropic_models
+from pipelex.plugin.anthropic.anthropic_llms import anthropic_list_anthropic_models
# make t VERBOSE=2 TEST=TestAnthropic
@pytest.mark.gha_disabled
@pytest.mark.codex_disabled
@pytest.mark.asyncio(loop_scope="class")
diff --git a/tests/pipelex/cogt/synchro/llm_providers/test_bedrock.py b/tests/pipelex/plugin/test_bedrock.py
similarity index 90%
rename from tests/pipelex/cogt/synchro/llm_providers/test_bedrock.py
rename to tests/pipelex/plugin/test_bedrock.py
index 8eb1c9a2f..0b4d10d42 100644
--- a/tests/pipelex/cogt/synchro/llm_providers/test_bedrock.py
+++ b/tests/pipelex/plugin/test_bedrock.py
@@ -1,3 +1,4 @@
+import warnings
from typing import Any, Dict, List
import boto3
@@ -6,9 +7,16 @@ from rich import box
from rich.console import Console
from rich.table import Table
+warnings.filterwarnings(
+ "ignore",
+ message=r".*datetime\.datetime\.utcnow\(\).*",
+ category=DeprecationWarning,
+)
+# Apply pytest-level filter to ensure the warning is suppressed during test collection and execution
+pytestmark = pytest.mark.filterwarnings("ignore:.*datetime\\.datetime\\.utcnow\\(\\).*:DeprecationWarning")
+
# make t VERBOSE=2 TEST=TestBedrock
@pytest.mark.gha_disabled
@pytest.mark.codex_disabled
class TestBedrock:
diff --git a/tests/pipelex/cogt/synchro/llm_providers/test_mistral.py b/tests/pipelex/plugin/test_mistral.py
similarity index 94%
rename from tests/pipelex/cogt/synchro/llm_providers/test_mistral.py
rename to tests/pipelex/plugin/test_mistral.py
index b404a2fcd..c484d4894 100644
--- a/tests/pipelex/cogt/synchro/llm_providers/test_mistral.py
+++ b/tests/pipelex/plugin/test_mistral.py
@@ -4,11 +4,10 @@ from rich.console import Console
from rich.table import Table
from pipelex import pretty_print
-from pipelex.cogt.plugin.mistral.mistral_llms import list_mistral_models
+from pipelex.plugin.mistral.mistral_llms import list_mistral_models
# make t VERBOSE=2 TEST=TestMistral
@pytest.mark.gha_disabled
@pytest.mark.codex_disabled
class TestMistral:
diff --git a/tests/pipelex/cogt/asynch/llm_providers/test_openai.py b/tests/pipelex/plugin/test_openai.py
similarity index 93%
rename from tests/pipelex/cogt/asynch/llm_providers/test_openai.py
rename to tests/pipelex/plugin/test_openai.py
index 570deba4d..9ece86ff8 100644
--- a/tests/pipelex/cogt/asynch/llm_providers/test_openai.py
+++ b/tests/pipelex/plugin/test_openai.py
@@ -3,13 +3,12 @@ import pytest
from pipelex import pretty_print
from pipelex.cogt.exceptions import LLMSDKError
from pipelex.cogt.llm.llm_models.llm_platform import LLMPlatform
-from pipelex.cogt.plugin.openai.openai_llms import openai_list_available_models
from pipelex.config import get_config
from pipelex.hub import get_secrets_provider
+from pipelex.plugin.openai.openai_llms import openai_list_available_models
# make t VERBOSE=2 TEST=TestOpenAI
@pytest.mark.gha_disabled
@pytest.mark.codex_disabled
@pytest.mark.asyncio(loop_scope="class")
diff --git a/tests/pipelex/cogt/asynch/imgg/test_imgg_openai.py b/tests/pipelex/plugin/test_openai_image_gen.py
similarity index 93%
rename from tests/pipelex/cogt/asynch/imgg/test_imgg_openai.py
rename to tests/pipelex/plugin/test_openai_image_gen.py
index 01b6615c7..67ef3e594 100644
--- a/tests/pipelex/cogt/asynch/imgg/test_imgg_openai.py
+++ b/tests/pipelex/plugin/test_openai_image_gen.py
@@ -2,11 +2,11 @@ import pytest
from pipelex.cogt.exceptions import ImggGenerationError
from pipelex.cogt.llm.llm_models.llm_platform import LLMPlatform
-from pipelex.cogt.plugin.openai.openai_factory import OpenAIFactory
+from pipelex.plugin.openai.openai_factory import OpenAIFactory
from pipelex.tools.misc.base_64_utils import save_base64_to_binary_file
from pipelex.tools.misc.file_utils import ensure_path, get_incremental_file_path
from tests.conftest import TEST_OUTPUTS_DIR
-from tests.pipelex.cogt.test_data import IMGGTestCases
+from tests.pipelex.test_data import IMGGTestCases
@pytest.mark.imgg
diff --git a/tests/pipelex/synchro/__init__.py b/tests/pipelex/synchro/__init__.py
deleted file mode 100644
index 8b1378917..000000000
--- a/tests/pipelex/synchro/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/tests/pipelex/test_data.py b/tests/pipelex/test_data.py
index c2b93eefd..8f49e2982 100644
--- a/tests/pipelex/test_data.py
+++ b/tests/pipelex/test_data.py
@@ -298,7 +298,7 @@ class LibraryTestCases:
KNOWN_CONCEPTS_AND_PIPES: ClassVar[List[Tuple[str, str]]] = [ # concept, pipe
("cars.CarDescription", "generate_car_description"),
("animals.AnimalDescription", "generate_animal_description"),
- ("gpu.GPUDescription", "generate_gpu_description"),
+ ("flowers.FlowerDescription", "generate_flower_description"),
]
@@ -308,3 +308,18 @@ class PipeOcrTestCases:
ImageTestCases.IMAGE_URL,
]
PIPE_OCR_PDF_TEST_CASES: ClassVar[List[str]] = PDFTestCases.DOCUMENT_FILE_PATHS + PDFTestCases.DOCUMENT_URLS
+
+
+class IMGGTestCases:
+ IMGG_PROMPT_1 = "woman wearing marino cargo pants"
+ IMGG_PROMPT_2 = "wide legged denim pants with hippy addition"
+ IMGG_PROMPT_3 = """
+Woman typing on a laptop. On the laptop screen you see python code to generate code to write a prompt for an AI model.
+"""
+
+ IMAGE_DESC: ClassVar[List[Tuple[str, str]]] = [ # topic, imgg_prompt_text
+ # (IMGG_PROMPT_1, IMGG_PROMPT_1),
+ # (IMGG_PROMPT_2, IMGG_PROMPT_2),
+ # (IMGG_PROMPT_3, IMGG_PROMPT_3),
+ ("coding girl", "a girl with a dragon tatoo, coding in python"),
+ ]
diff --git a/tests/pipelex/synchro/test_libraries.py b/tests/pipelex/test_libraries.py
similarity index 100%
rename from tests/pipelex/synchro/test_libraries.py
rename to tests/pipelex/test_libraries.py
diff --git a/tests/test_pipelines/misc_tests/subfolder_2/subfolder/flowers.toml b/tests/test_pipelines/misc_tests/subfolder_2/subfolder/flowers.toml
new file mode 100644
index 000000000..394464d88
--- /dev/null
+++ b/tests/test_pipelines/misc_tests/subfolder_2/subfolder/flowers.toml
@@ -0,0 +1,18 @@
+domain = "flowers"
+definition = "A test domain related to flowers"
+system_prompt = "You are an expert at describing flowers based on their species and color."
+
+[concept]
+Flower = "A flower reference, including its species and color"
+FlowerDescription = "A detailed description of a flower"
+
+[pipe]
+[pipe.generate_flower_description]
+PipeLLM = "Generate a description of a flower"
+input = "Flower"
+output = "FlowerDescription"
+prompt_template = """
+Given the reference to a flower, generate a description of the flower.
+
+@flower
+"""
diff --git a/tests/test_pipelines/misc_tests/subfolder_2/subfolder/gpu.toml b/tests/test_pipelines/misc_tests/subfolder_2/subfolder/gpu.toml
deleted file mode 100644
index f4058566f..000000000
--- a/tests/test_pipelines/misc_tests/subfolder_2/subfolder/gpu.toml
+++ /dev/null
@@ -1,21 +0,0 @@
-
-
-domain = "gpu"
-definition = "The test domain for handling GPU descriptions"
-system_prompt = "You are an expert at describing GPUs based on their brand, model, and price."
-
-[concept]
-GPU = "A GPU reference, including its brand, model, and price"
-GPUDescription = "A detailed description of a GPU"
-
-[pipe]
-[pipe.generate_gpu_description]
-PipeLLM = "Generate a description of a GPU"
-input = "GPU"
-output = "GPUDescription"
-prompt_template = """
-Given the reference to a GPU, generate a description of the GPU.
-
-GPU:
-{{ gpu|tag }}
-"""
diff --git a/tests/tools/misc/test_pretty.py b/tests/tools/misc/test_pretty.py
index 8020ea4de..35b76aca4 100644
--- a/tests/tools/misc/test_pretty.py
+++ b/tests/tools/misc/test_pretty.py
@@ -148,8 +148,13 @@ class TestPrettyPrint:
assert output == expected_output, f"Output did not match expected:\n{output}"
+ # This test needs output to be displayed, so we disabled it by default in pyproject.toml
+ # So to run it you must bypass the marker restrictions defined in the pyproject.toml pytest section
+ # and make sure you turn on outputs with -s like this:
+ # pytest -m "" -k test_pretty_print_pydantic_object -s
@pytest.mark.gha_disabled
@pytest.mark.codex_disabled
+ @pytest.mark.needs_output
def test_pretty_print_pydantic_object(self, capsys: CaptureFixture[str]):
# Create a complex nested object
user = ComplexUser(
diff --git a/uv.lock b/uv.lock
index 131db01ef..80e3d6263 100644
--- a/uv.lock
+++ b/uv.lock
@@ -435,6 +435,15 @@ wheels = [
{ url = "https://files.pythonhosted.org/packages/ce/31/55cd413eaccd39125368be33c46de24a1f639f2e12349b0361b4678f3915/eval_type_backport-0.2.2-py3-none-any.whl", hash = "sha256:cb6ad7c393517f476f96d456d0412ea80f0a8cf96f6892834cd9340149111b0a", size = 5830, upload-time = "2024-12-21T20:09:44.175Z" },
]
+[[package]]
+name = "execnet"
+version = "2.1.1"
+source = { registry = "https://pypi.org/simple" }
+sdist = { url = "https://files.pythonhosted.org/packages/bb/ff/b4c0dc78fbe20c3e59c0c7334de0c27eb4001a2b2017999af398bf730817/execnet-2.1.1.tar.gz", hash = "sha256:5189b52c6121c24feae288166ab41b32549c7e2348652736540b9e6e7d4e72e3", size = 166524, upload-time = "2024-04-08T09:04:19.245Z" }
+wheels = [
+ { url = "https://files.pythonhosted.org/packages/43/09/2aea36ff60d16dd8879bdb2f5b3ee0ba8d08cbbdcdfe870e695ce3784385/execnet-2.1.1-py3-none-any.whl", hash = "sha256:26dee51f1b80cebd6d0ca8e74dd8745419761d3bef34163928cbebbdc4749fdc", size = 40612, upload-time = "2024-04-08T09:04:17.414Z" },
+]
+
[[package]]
name = "fal-client"
version = "0.7.0"
@@ -1240,6 +1249,7 @@ dev = [
{ name = "pytest-asyncio" },
{ name = "pytest-cov" },
{ name = "pytest-sugar" },
+ { name = "pytest-xdist" },
{ name = "ruff" },
{ name = "types-aioboto3", extra = ["bedrock", "bedrock-runtime"] },
{ name = "types-aiofiles" },
@@ -1292,6 +1302,7 @@ requires-dist = [
{ name = "pytest-asyncio", marker = "extra == 'dev'", specifier = ">=0.24.0" },
{ name = "pytest-cov", marker = "extra == 'dev'", specifier = ">=6.1.1" },
{ name = "pytest-sugar", marker = "extra == 'dev'", specifier = ">=1.0.0" },
+ { name = "pytest-xdist", marker = "extra == 'dev'", specifier = ">=3.6.1" },
{ name = "python-dotenv", specifier = ">=1.0.1" },
{ name = "pyyaml", specifier = ">=6.0.2" },
{ name = "rich", specifier = ">=13.8.1" },
@@ -1579,6 +1590,19 @@ wheels = [
{ url = "https://files.pythonhosted.org/packages/92/fb/889f1b69da2f13691de09a111c16c4766a433382d44aa0ecf221deded44a/pytest_sugar-1.0.0-py3-none-any.whl", hash = "sha256:70ebcd8fc5795dc457ff8b69d266a4e2e8a74ae0c3edc749381c64b5246c8dfd", size = 10171, upload-time = "2024-02-01T18:30:29.395Z" },
]
+[[package]]
+name = "pytest-xdist"
+version = "3.7.0"
+source = { registry = "https://pypi.org/simple" }
+dependencies = [
+ { name = "execnet" },
+ { name = "pytest" },
+]
+sdist = { url = "https://files.pythonhosted.org/packages/49/dc/865845cfe987b21658e871d16e0a24e871e00884c545f246dd8f6f69edda/pytest_xdist-3.7.0.tar.gz", hash = "sha256:f9248c99a7c15b7d2f90715df93610353a485827bc06eefb6566d23f6400f126", size = 87550, upload-time = "2025-05-26T21:18:20.251Z" }
+wheels = [
+ { url = "https://files.pythonhosted.org/packages/0d/b2/0e802fde6f1c5b2f7ae7e9ad42b83fd4ecebac18a8a8c2f2f14e39dce6e1/pytest_xdist-3.7.0-py3-none-any.whl", hash = "sha256:7d3fbd255998265052435eb9daa4e99b62e6fb9cfb6efd1f858d4d8c0c7f0ca0", size = 46142, upload-time = "2025-05-26T21:18:18.759Z" },
+]
+
[[package]]
name = "python-dateutil"
version = "2.9.0.post0"