Skip to content

Commit a10c3d3

Browse files
fix/Pipelex config fixed path(Pipelex#151)
1 parent 7c84c52 commit a10c3d3

31 files changed

Lines changed: 328 additions & 114 deletions
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: Manual trigger tests check
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- dev
7+
- "release/v[0-9]+.[0-9]+.[0-9]+"
8+
workflow_dispatch:
9+
10+
jobs:
11+
trigger-tests:
12+
runs-on: ubuntu-latest
13+
environment:
14+
name: manual-trigger-tests-check
15+
url: ${{ github.server_url }}/${{ github.repository }}/deployments/activity_log?environment=manual-trigger-tests-check
16+
steps:
17+
- name: Initialize check
18+
run: |
19+
echo "Initializing manual trigger tests check..."
20+
21+
matrix-test:
22+
name: Manual trigger tests check
23+
needs: [trigger-tests]
24+
runs-on: ubuntu-latest
25+
strategy:
26+
fail-fast: false
27+
matrix:
28+
python-version: ["3.10", "3.11", "3.12", "3.13"]
29+
permissions:
30+
contents: read
31+
id-token: write
32+
packages: read
33+
actions: read
34+
repository-projects: read
35+
env:
36+
VIRTUAL_ENV: ${{ github.workspace }}/.venv
37+
ENV: dev
38+
39+
steps:
40+
- uses: actions/checkout@v4
41+
42+
- name: Configure AWS Credentials
43+
uses: aws-actions/configure-aws-credentials@v4
44+
with:
45+
role-to-assume: arn:aws:iam::975050286103:role/GitHubActionsRole
46+
aws-region: eu-west-3
47+
48+
- name: Set up Python ${{ matrix.python-version }}
49+
uses: actions/setup-python@v4
50+
with:
51+
python-version: ${{ matrix.python-version }}
52+
53+
- name: Check UV installation
54+
run: make check-uv
55+
56+
- name: Verify UV installation
57+
run: uv --version
58+
59+
- name: Install dependencies
60+
run: PYTHON_VERSION=${{ matrix.python-version }} make install
61+
62+
- name: Boot test
63+
run: make tp TEST=TestFundamentals
64+
65+
- name: Run tests
66+
run: make run-manual-trigger-gha-tests

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
# Changelog
22

3+
## [v0.6.0] - 2025-07-12
4+
5+
### Changed
6+
- The `Pipelex.make()` now takes a `relative_config_folder_path` argument, which is considered to be a relative path to the current working directory, pointing to the config folder path of pipelex. The argument `from_file` indicates if the path is relative to the caller's file path. If False, the path is considered to be absolute from where the process was started.
7+
8+
### Added
9+
- Added github action for inference tests
10+
- `load_json_list_from_path` function in `pipelex.tools.misc.file_utils`: Loads a JSON file and ensures it contains a list.
11+
312
## [v0.5.2] - 2025-07-11
413

514
- log a warning when dry running a `PipeFunc`

pipelex/cli/_cli.py

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def init_libraries(
4747
"""
4848
try:
4949
# TODO: Have a more proper print message regarding the overwrited files (e.g. list of files that were overwritten or not)
50-
LibraryConfig.export_libraries(overwrite=overwrite)
50+
LibraryConfig().export_libraries(overwrite=overwrite)
5151
if overwrite:
5252
typer.echo("Successfully initialized pipelex libraries (all files overwritten)")
5353
else:
@@ -76,10 +76,15 @@ def init_config(
7676

7777

7878
@app.command()
79-
def validate() -> None:
79+
def validate(
80+
relative_config_folder_path: Annotated[
81+
str, typer.Option("--config-folder-path", "-c", help="Relative path to the config folder path")
82+
] = "pipelex_libraries",
83+
) -> None:
8084
"""Run the setup sequence."""
81-
LibraryConfig.export_libraries()
82-
pipelex_instance = Pipelex.make()
85+
config_folder_path = os.path.join(os.getcwd(), relative_config_folder_path)
86+
LibraryConfig(config_folder_path=config_folder_path).export_libraries()
87+
pipelex_instance = Pipelex.make(relative_config_folder_path=relative_config_folder_path, from_file=False)
8388
pipelex_instance.validate_libraries()
8489
asyncio.run(dry_run_all_pipes())
8590
log.info("Setup sequence passed OK, config and pipelines are validated.")
@@ -96,9 +101,13 @@ def show_config() -> None:
96101

97102

98103
@app.command()
99-
def list_pipes() -> None:
104+
def list_pipes(
105+
relative_config_folder_path: Annotated[
106+
str, typer.Option("--config-folder-path", "-c", help="Relative path to the config folder path")
107+
] = "pipelex_libraries",
108+
) -> None:
100109
"""List all available pipes."""
101-
Pipelex.make()
110+
Pipelex.make(relative_config_folder_path=relative_config_folder_path, from_file=False)
102111

103112
try:
104113
get_pipe_provider().pretty_list_pipes()

pipelex/cogt/llm/llm_models/llm_model_library.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import os
2-
from typing import Any, Dict, List, Optional
2+
from typing import Any, ClassVar, Dict, List, Optional
33

44
from pydantic import Field, RootModel
55
from typing_extensions import override
@@ -32,6 +32,12 @@ class LLMModelLibraryError(ToolException):
3232

3333
class LLMModelLibrary(LLMModelProviderAbstract, RootModel[LLMModelLibraryRoot]):
3434
root: LLMModelLibraryRoot = Field(default_factory=list)
35+
library_config: ClassVar[LibraryConfig]
36+
37+
@classmethod
38+
def make_empty(cls, config_folder_path: str) -> "LLMModelLibrary":
39+
cls.library_config = LibraryConfig(config_folder_path=config_folder_path)
40+
return cls()
3541

3642
@override
3743
def setup(self):
@@ -63,7 +69,7 @@ def desc(self) -> str:
6369

6470
@classmethod
6571
def load_llm_model_library_dict(cls) -> LLMModelLibraryDict:
66-
libraries_path = LibraryConfig.exported_llm_integrations_path
72+
libraries_path = cls.library_config.llm_integrations_path
6773
if not os.path.exists(libraries_path):
6874
raise LLMModelLibraryError(f"LLM model library path `{libraries_path}` not found. Please run `pipelex init-libraries` to create it.")
6975
llm_library: LLMModelLibraryDict = {}

pipelex/libraries/library_config.py

Lines changed: 72 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -3,99 +3,117 @@
33
from pipelex.tools.config.models import ConfigModel
44
from pipelex.tools.misc.file_utils import copy_file_from_package, copy_folder_from_package, find_files_in_dir
55

6+
PIPELEX_LIBRARIES_PATH = "libraries"
7+
68

79
class LibraryConfig(ConfigModel):
8-
# Class variables
910
package_name: ClassVar[str] = "pipelex"
10-
internal_library_root: ClassVar[str] = "libraries"
11-
exported_library_root: ClassVar[str] = "pipelex_libraries"
12-
internal_base_pipelines_path: ClassVar[str] = f"{internal_library_root}/pipelines"
13-
exported_pipelines_path: ClassVar[str] = f"{exported_library_root}/pipelines"
14-
exported_base_pipelines_path: ClassVar[str] = f"{exported_library_root}/pipelines/base_library"
15-
loaded_pipelines_path: ClassVar[str] = f"{exported_library_root}/pipelines"
16-
test_pipelines_path: ClassVar[str] = "tests/test_pipelines"
17-
internal_llm_integrations_path: ClassVar[str] = f"{internal_library_root}/llm_integrations"
18-
exported_llm_integrations_path: ClassVar[str] = f"{exported_library_root}/llm_integrations"
19-
internal_llm_deck_path: ClassVar[str] = f"{internal_library_root}/llm_deck"
20-
exported_llm_deck_path: ClassVar[str] = f"{exported_library_root}/llm_deck"
21-
internal_templates_path: ClassVar[str] = f"{internal_library_root}/templates"
22-
exported_templates_path: ClassVar[str] = f"{exported_library_root}/templates"
23-
internal_plugins_path: ClassVar[str] = f"{internal_library_root}/plugins"
24-
exported_plugins_path: ClassVar[str] = f"{exported_library_root}/plugins"
25-
failing_pipelines_path: ClassVar[str] = "tests/test_pipelines/failing_pipelines.toml"
26-
27-
@classmethod
28-
def get_llm_deck_paths(cls) -> List[str]:
29-
llm_deck_paths = [str(path) for path in find_files_in_dir(dir_path=cls.exported_llm_deck_path, pattern="*.toml", is_recursive=True)]
11+
config_folder_path: str = "pipelex_libraries"
12+
13+
@property
14+
def config_file(self) -> str:
15+
return f"{self.config_folder_path}/config.toml"
16+
17+
@property
18+
def pipelines_path(self) -> str:
19+
return f"{self.config_folder_path}/pipelines"
20+
21+
@property
22+
def base_pipelines_path(self) -> str:
23+
return f"{self.config_folder_path}/pipelines/base_library"
24+
25+
@property
26+
def llm_integrations_path(self) -> str:
27+
return f"{self.config_folder_path}/llm_integrations"
28+
29+
@property
30+
def llm_deck_path(self) -> str:
31+
return f"{self.config_folder_path}/llm_deck"
32+
33+
@property
34+
def templates_path(self) -> str:
35+
return f"{self.config_folder_path}/templates"
36+
37+
@property
38+
def plugins_path(self) -> str:
39+
return f"{self.config_folder_path}/plugins"
40+
41+
@property
42+
def test_pipelines_path(self) -> str:
43+
return "tests/test_pipelines"
44+
45+
@property
46+
def failing_pipelines_path(self) -> str:
47+
return "tests/test_pipelines/failing_pipelines.toml"
48+
49+
def get_llm_deck_paths(self) -> List[str]:
50+
llm_deck_paths = [str(path) for path in find_files_in_dir(dir_path=self.llm_deck_path, pattern="*.toml", is_recursive=True)]
3051
llm_deck_paths.sort()
3152
return llm_deck_paths
3253

33-
@classmethod
34-
def get_templates_paths(cls) -> List[str]:
35-
return [str(path) for path in find_files_in_dir(dir_path=cls.exported_templates_path, pattern="*.toml", is_recursive=True)]
54+
def get_templates_paths(self) -> List[str]:
55+
return [str(path) for path in find_files_in_dir(dir_path=self.templates_path, pattern="*.toml", is_recursive=True)]
3656

37-
@classmethod
38-
def get_plugin_config_path(cls) -> str:
39-
return f"{cls.exported_plugins_path}/plugin_config.toml"
57+
def get_default_plugin_config_path(self) -> str:
58+
"""Get the default plugin config path."""
59+
return f"{self.plugins_path}/plugin_config.toml"
4060

41-
@classmethod
42-
def export_libraries(cls, overwrite: bool = False) -> None:
61+
def export_libraries(self, overwrite: bool = False) -> None:
4362
"""Duplicate pipelex libraries files in the client project, preserving directory structure."""
4463
# pipelines
4564
copy_folder_from_package(
46-
package_name=cls.package_name,
47-
folder_path_in_package=cls.internal_base_pipelines_path,
48-
target_dir=cls.exported_base_pipelines_path,
65+
package_name=self.package_name,
66+
folder_path_in_package=f"{PIPELEX_LIBRARIES_PATH}/pipelines",
67+
target_dir=self.base_pipelines_path,
4968
overwrite=overwrite,
5069
)
5170
copy_file_from_package(
52-
package_name=cls.package_name,
53-
file_path_in_package=f"{cls.internal_library_root}/__init__.py",
54-
target_path=f"{cls.exported_library_root}/__init__.py",
71+
package_name=self.package_name,
72+
file_path_in_package=f"{PIPELEX_LIBRARIES_PATH}/__init__.py",
73+
target_path=f"{self.config_folder_path}/__init__.py",
5574
overwrite=overwrite,
5675
)
5776
copy_file_from_package(
58-
package_name=cls.package_name,
59-
file_path_in_package=f"{cls.internal_base_pipelines_path}/__init__.py",
60-
target_path=f"{cls.exported_pipelines_path}/__init__.py",
77+
package_name=self.package_name,
78+
file_path_in_package=f"{PIPELEX_LIBRARIES_PATH}/pipelines/__init__.py",
79+
target_path=f"{self.pipelines_path}/__init__.py",
6180
overwrite=overwrite,
6281
)
6382
copy_file_from_package(
64-
package_name=cls.package_name,
65-
file_path_in_package=f"{cls.internal_base_pipelines_path}/__init__.py",
66-
target_path=f"{cls.exported_base_pipelines_path}/__init__.py",
83+
package_name=self.package_name,
84+
file_path_in_package=f"{PIPELEX_LIBRARIES_PATH}/pipelines/__init__.py",
85+
target_path=f"{self.base_pipelines_path}/__init__.py",
6786
overwrite=overwrite,
6887
)
69-
7088
# llm_integrations
7189
copy_folder_from_package(
72-
package_name=cls.package_name,
73-
folder_path_in_package=cls.internal_llm_integrations_path,
74-
target_dir=cls.exported_llm_integrations_path,
90+
package_name=self.package_name,
91+
folder_path_in_package=f"{PIPELEX_LIBRARIES_PATH}/llm_integrations",
92+
target_dir=self.llm_integrations_path,
7593
overwrite=overwrite,
7694
)
7795

7896
# llm_deck
7997
copy_folder_from_package(
80-
package_name=cls.package_name,
81-
folder_path_in_package=cls.internal_llm_deck_path,
82-
target_dir=cls.exported_llm_deck_path,
98+
package_name=self.package_name,
99+
folder_path_in_package=f"{PIPELEX_LIBRARIES_PATH}/llm_deck",
100+
target_dir=self.llm_deck_path,
83101
overwrite=overwrite,
84102
non_overwrite_files=["overrides.toml"],
85103
)
86104

87105
# templates
88106
copy_folder_from_package(
89-
package_name=cls.package_name,
90-
folder_path_in_package=cls.internal_templates_path,
91-
target_dir=cls.exported_templates_path,
107+
package_name=self.package_name,
108+
folder_path_in_package=f"{PIPELEX_LIBRARIES_PATH}/templates",
109+
target_dir=self.templates_path,
92110
overwrite=overwrite,
93111
)
94112

95113
# plugins
96114
copy_folder_from_package(
97-
package_name=cls.package_name,
98-
folder_path_in_package=cls.internal_plugins_path,
99-
target_dir=cls.exported_plugins_path,
115+
package_name=self.package_name,
116+
folder_path_in_package=f"{PIPELEX_LIBRARIES_PATH}/plugins",
117+
target_dir=self.plugins_path,
100118
overwrite=overwrite,
101119
)

0 commit comments

Comments
 (0)