File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ name : ' Setup Python and Poetry'
2+ description : ' Setup Python environment and install Poetry'
3+ runs :
4+ using : ' composite'
5+ steps :
6+ - name : Set up Python
7+ uses : actions/setup-python@v4
8+ with :
9+ python-version : ' 3.12'
10+
11+ - name : Install dependencies
12+ shell : bash
13+ run : |
14+ pip install --upgrade pip
15+ pip install poetry==1.8.4
16+ poetry install --no-root
Original file line number Diff line number Diff line change 1+ import importlib .machinery
2+ import importlib .util
3+ import traceback
4+ from pathlib import Path
5+
6+ # List all entry points here
7+ entry_points : list [Path ] = list (
8+ map (
9+ Path ("bin" ).joinpath ,
10+ [
11+ "chat-chainlit.py" ,
12+ "chat-fastapi.py" ,
13+ "embeddings_manager" ,
14+ ],
15+ )
16+ )
17+
18+ failed_imports : list [str ] = []
19+
20+ location : Path
21+ for location in entry_points :
22+ name : str = location .stem
23+ try :
24+ loader = importlib .machinery .SourceFileLoader (name , str (location ))
25+ spec = importlib .util .spec_from_loader (name , loader )
26+ if spec is None :
27+ raise ModuleNotFoundError (name )
28+ module = importlib .util .module_from_spec (spec )
29+ loader .exec_module (module )
30+ except ImportError :
31+ failed_imports .append (name )
32+ print (f"Failed to import { location } due to ImportError:" )
33+ traceback .print_exc ()
34+ except Exception as e :
35+ print (f"Non-import error for { location } : { e } " )
36+ traceback .print_exc ()
37+
38+ if failed_imports :
39+ print (f"Failed to import: { ", " .join (failed_imports )} " )
40+ exit (1 )
41+ else :
42+ print ("All entry points imported successfully." )
Original file line number Diff line number Diff line change @@ -21,23 +21,43 @@ jobs:
2121 steps :
2222 - uses : actions/checkout@v4
2323
24- - name : Set up Python
25- uses : actions/setup-python@v4
26- with :
27- python-version : ' 3.12'
28-
29- - name : Install dependencies
30- run : |
31- python -m pip install --upgrade pip
32- pip install poetry
33- poetry install --no-root
24+ - name : Set up Python and Poetry
25+ uses : ./.github/actions/install_python_poetry
3426
3527 - name : Run linters
3628 run : |
3729 poetry run ruff check .
3830 poetry run mypy .
3931 poetry run isort --check .
4032
33+ poetry-check :
34+ if : ${{ github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch' }}
35+ runs-on : ${{ matrix.os }}
36+ strategy :
37+ matrix :
38+ os : [ubuntu-latest, macos-13]
39+
40+ steps :
41+ - uses : actions/checkout@v4
42+
43+ - name : Check poetry.lock for changes
44+ id : check-poetry-lock
45+ uses : tj-actions/changed-files@v45
46+ with :
47+ files : poetry.lock
48+
49+ - name : Set up Python and Poetry
50+ if : steps.check-poetry-lock.outputs.any_changed == 'true'
51+ uses : ./.github/actions/install_python_poetry
52+
53+ - name : Verify Python imports
54+ if : steps.check-poetry-lock.outputs.any_changed == 'true'
55+ env :
56+ PYTHONPATH : ./bin:./src
57+ run : |
58+ poetry check
59+ poetry run python ./.github/actions/verify_imports.py
60+
4161 docker-build :
4262 runs-on : ubuntu-latest
4363
You can’t perform that action at this time.
0 commit comments