@@ -42,40 +42,22 @@ def __init__(
4242 self .run_state = run_state
4343 self .event_bus = event_bus
4444
45- def _validate_previous_frid_commits_exist (
46- self , module_name : str , plain_source : dict , render_range : list [str ]
47- ) -> None :
45+ def _ensure_module_folders_exist (self , module_name : str , first_render_frid : str ) -> tuple [str , str ]:
4846 """
49- Validate that all FRID commits before the render_range exist.
47+ Ensure that build and conformance test folders exist for the module .
5048
5149 Args:
5250 module_name: Name of the module being rendered
53- plain_source: The plain source tree
54- render_range: List of FRIDs to render
51+ first_render_frid: The first FRID in the render range
52+
53+ Returns:
54+ tuple[str, str]: (build_folder_path, conformance_tests_path)
5555
5656 Raises:
57- MissingPreviousFridCommitsError: If any previous FRID commits are missing
57+ MissingPreviousFridCommitsError: If any required folders are missing
5858 """
59- # Get all FRIDs from the plain source
60- all_frids = list (plain_spec .get_frids (plain_source ))
61- first_render_frid = render_range [0 ]
62-
63- # Find all FRIDs before the first FRID in render_range
64- previous_frids = []
65- for frid in all_frids :
66- if frid == first_render_frid :
67- break
68- previous_frids .append (frid )
69-
70- # If there are no previous FRIDs, nothing to validate
71- if not previous_frids :
72- return
73-
74- # Check if commits exist for all previous FRIDs
7559 build_folder_path = os .path .join (self .args .build_folder , module_name )
76- conformance_tests_path = os .path .join (
77- self .args .conformance_tests_folder , module_name
78- )
60+ conformance_tests_path = os .path .join (self .args .conformance_tests_folder , module_name )
7961
8062 if not os .path .exists (build_folder_path ):
8163 raise MissingPreviousFridCommitsError (
@@ -91,27 +73,82 @@ def _validate_previous_frid_commits_exist(
9173 f"Please render all previous FRIDs for module { module_name } first."
9274 )
9375
94- for prev_frid in previous_frids :
95- # Check in build folder
96- if not git_utils .has_commit_for_frid (
97- build_folder_path , prev_frid , module_name
98- ):
76+ return build_folder_path , conformance_tests_path
77+
78+ def _ensure_frid_commit_exists (
79+ self ,
80+ frid : str ,
81+ module_name : str ,
82+ build_folder_path : str ,
83+ conformance_tests_path : str ,
84+ first_render_frid : str ,
85+ ) -> None :
86+ """
87+ Ensure commit exists for a single FRID in both repositories.
88+
89+ Args:
90+ frid: The FRID to check
91+ module_name: Name of the module
92+ build_folder_path: Path to the build folder
93+ conformance_tests_path: Path to the conformance tests folder
94+ first_render_frid: The first FRID in the render range (for error messages)
95+
96+ Raises:
97+ MissingPreviousFridCommitsError: If the commit is missing
98+ """
99+ # Check in build folder
100+ if not git_utils .has_commit_for_frid (build_folder_path , frid , module_name ):
101+ raise MissingPreviousFridCommitsError (
102+ f"Cannot render from FRID { first_render_frid } : "
103+ f"Missing commit for previous FRID { frid } in { build_folder_path } . "
104+ f"Please render all previous FRIDs first."
105+ )
106+
107+ # Check in conformance tests folder (only if conformance tests are enabled)
108+ if self .args .render_conformance_tests :
109+ if not git_utils .has_commit_for_frid (conformance_tests_path , frid , module_name ):
99110 raise MissingPreviousFridCommitsError (
100111 f"Cannot render from FRID { first_render_frid } : "
101- f"Missing commit for previous FRID { prev_frid } in { build_folder_path } . "
112+ f"Missing commit for previous FRID { frid } in { conformance_tests_path } . "
102113 f"Please render all previous FRIDs first."
103114 )
104115
105- # Check in conformance tests folder (only if conformance tests are enabled)
106- if self .args .render_conformance_tests :
107- if not git_utils .has_commit_for_frid (
108- conformance_tests_path , prev_frid , module_name
109- ):
110- raise MissingPreviousFridCommitsError (
111- f"Cannot render from FRID { first_render_frid } : "
112- f"Missing commit for previous FRID { prev_frid } in { conformance_tests_path } . "
113- f"Please render all previous FRIDs first."
114- )
116+ def _ensure_previous_frid_commits_exist (
117+ self , module_name : str , plain_source : dict , render_range : list [str ]
118+ ) -> None :
119+ """
120+ Ensure that all FRID commits before the render_range exist.
121+
122+ This is a precondition check that must pass before rendering can proceed.
123+ Raises an exception if any previous FRID commits are missing.
124+
125+ Args:
126+ module_name: Name of the module being rendered
127+ plain_source: The plain source tree
128+ render_range: List of FRIDs to render
129+
130+ Raises:
131+ MissingPreviousFridCommitsError: If any previous FRID commits are missing
132+ """
133+ first_render_frid = render_range [0 ]
134+
135+ # Get all FRIDs that should have been rendered before this one
136+ previous_frids = plain_spec .get_frids_before (plain_source , first_render_frid )
137+ if not previous_frids :
138+ return
139+
140+ # Ensure the module folders exist
141+ build_folder_path , conformance_tests_path = self ._ensure_module_folders_exist (module_name , first_render_frid )
142+
143+ # Verify commits exist for all previous FRIDs
144+ for prev_frid in previous_frids :
145+ self ._ensure_frid_commit_exists (
146+ prev_frid ,
147+ module_name ,
148+ build_folder_path ,
149+ conformance_tests_path ,
150+ first_render_frid ,
151+ )
115152
116153 def _build_render_context_for_module (
117154 self ,
@@ -159,9 +196,9 @@ def _render_module(
159196 resources_list = []
160197 plain_spec .collect_linked_resources (plain_source , resources_list , None , True )
161198
162- # Validate that all previous FRID commits exist before proceeding with render_range
199+ # Ensure that all previous FRID commits exist before proceeding with render_range
163200 if render_range is not None :
164- self ._validate_previous_frid_commits_exist (module_name , plain_source , render_range )
201+ self ._ensure_previous_frid_commits_exist (module_name , plain_source , render_range )
165202
166203 required_modules = []
167204 has_any_required_module_changed = False
0 commit comments