1313 BATCH_PREFIX ,
1414)
1515
16+ AILLY_CMD_BASE = [
17+ "ailly" ,
18+ "--max-depth" ,
19+ "10" ,
20+ "--root" ,
21+ str (AILLY_DIR_PATH ),
22+ ]
23+
1624logger = logging .getLogger (__file__ )
1725
1826
@@ -23,7 +31,7 @@ def handle_run_ailly(cmd: RunAilly, uow: None):
2331 total_start_time = time .time ()
2432
2533 for batch in resolved_batches :
26- run_ailly_single_batch (batch )
34+ run_ailly_single_batch (batch , cmd . packages )
2735
2836 total_end_time = time .time ()
2937 total_duration = total_end_time - total_start_time
@@ -56,19 +64,27 @@ def resolve_requested_batches(batch_names: List[str]) -> List[Path]:
5664 return batch_paths
5765
5866
59- def run_ailly_single_batch (batch : Path ) -> None :
67+ def run_ailly_single_batch (batch : Path , packages : List [ str ] = None ) -> None :
6068 """Run ailly and process files for a single batch."""
6169 batch_start_time = time .time ()
6270 iam_updates_path = AILLY_DIR_PATH / f"updates_{ batch .name } .json"
6371
64- cmd = [
65- "ailly" ,
66- "--max-depth" ,
67- "10" ,
68- "--root" ,
69- str (AILLY_DIR_PATH ),
70- batch .name ,
71- ]
72+ if packages :
73+ paths = []
74+ for package in packages :
75+ package_files = [
76+ f"{ batch .name } /{ p .name } " for p in batch .glob (f"*{ package } *.md" )
77+ ]
78+ paths .extend (package_files )
79+
80+ if not paths :
81+ logger .warning (f"No matching files found for packages: { packages } " )
82+ return
83+
84+ cmd = AILLY_CMD_BASE + paths
85+ else :
86+ cmd = AILLY_CMD_BASE + [batch .name ]
87+
7288 logger .info (f"Running { cmd } " )
7389 run (cmd )
7490
@@ -79,7 +95,9 @@ def run_ailly_single_batch(batch: Path) -> None:
7995 )
8096
8197 logger .info (f"Processing generated content for { batch .name } " )
82- process_ailly_files (input_dir = batch , output_file = iam_updates_path )
98+ process_ailly_files (
99+ input_dir = batch , output_file = iam_updates_path , packages = packages
100+ )
83101
84102
85103EXPECTED_KEYS : Set [str ] = set (["title" , "title_abbrev" ])
@@ -177,7 +195,10 @@ def parse_package_name(policy_update: Dict[str, str]) -> Optional[str]:
177195
178196
179197def process_ailly_files (
180- input_dir : Path , output_file : Path , file_pattern : str = "*.md.ailly.md"
198+ input_dir : Path ,
199+ output_file : Path ,
200+ file_pattern : str = "*.md.ailly.md" ,
201+ packages : List [str ] = None ,
181202) -> None :
182203 """
183204 Process all .md.ailly.md files in the input directory and write the results as JSON to the output file.
@@ -186,6 +207,7 @@ def process_ailly_files(
186207 input_dir: Directory containing .md.ailly.md files
187208 output_file: Path to the output JSON file
188209 file_pattern: Pattern to match files (default: "*.md.ailly.md")
210+ packages: Optional list of packages to filter by
189211 """
190212 results = defaultdict (list )
191213
@@ -197,6 +219,13 @@ def process_ailly_files(
197219 package_name = parse_package_name (policy_update )
198220 if not package_name :
199221 raise TypeError (f"Could not get package name from policy update." )
222+
223+ if packages and package_name not in packages :
224+ logger .info (
225+ f"Skipping package { package_name } (not in requested packages)"
226+ )
227+ continue
228+
200229 results [package_name ].append (policy_update )
201230
202231 with open (output_file , "w" , encoding = "utf-8" ) as out_file :
0 commit comments