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- import importlib
1+ import importlib .machinery
2+ import importlib .util
23import traceback
4+ from pathlib import Path
35
46# List all entry points here
5- entry_points = [
6- "chat-chainlit" ,
7- "chat-fastapi" ,
8- ".embeddings_manager"
9- ]
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+ )
1017
11- failed_imports = []
18+ failed_imports : list [ str ] = []
1219
13- for entry in entry_points :
20+ location : Path
21+ for location in entry_points :
22+ name : str = location .stem
1423 try :
15- importlib .import_module (entry )
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 )
1630 except ImportError :
17- failed_imports .append (entry )
18- print (f"Failed to import { entry } due to ImportError:" )
31+ failed_imports .append (name )
32+ print (f"Failed to import { location } due to ImportError:" )
1933 traceback .print_exc ()
2034 except Exception as e :
21- print (f"Non-import error for { entry } : { e } " )
35+ print (f"Non-import error for { location } : { e } " )
2236 traceback .print_exc ()
2337
2438if failed_imports :
Original file line number Diff line number Diff line change 5656 PYTHONPATH : ./bin:./src
5757 run : |
5858 poetry check
59- poetry run python -m ./.github/actions/verify_imports.py
59+ poetry run python ./.github/actions/verify_imports.py
6060
6161 docker-build :
6262 runs-on : ubuntu-latest
You can’t perform that action at this time.
0 commit comments