@@ -291,6 +291,61 @@ def get_schema(self, type_overrides_file: Optional[Path] = None) -> Schema:
291
291
schema .merge (overrides_schema )
292
292
return schema
293
293
294
+ def get_pipelines_schema (self , pipeline_names : List [str ], type_overrides_file : Optional [Path ] = None ) -> Schema :
295
+ """Returns a `GraphSchema` representing only the specified pipelines.
296
+
297
+ This method generates a schema from only the specified pipelines,
298
+ allowing you to see what schema specific pipelines contribute without interference
299
+ from other pipelines in the project.
300
+
301
+ Args:
302
+ pipeline_names (List[str]): List of pipeline names to include in schema generation.
303
+ type_overrides_file (Optional[Path], optional): A path to a YAML file containing type overrides. Defaults to None.
304
+
305
+ Returns:
306
+ Schema: The schema representing only the specified pipelines.
307
+
308
+ Raises:
309
+ ValueError: If none of the specified pipelines are found.
310
+ """
311
+ # Create a temporary project to store only the specified pipelines
312
+ filtered_project = Project (
313
+ targets_by_name = self .targets_by_name ,
314
+ storage_configuration = self .storage_configuration ,
315
+ )
316
+
317
+ pipelines_found = []
318
+
319
+ for scope in self .scopes_by_name .values ():
320
+ filtered_scope = PipelineScope (
321
+ name = scope .name ,
322
+ config = scope .config ,
323
+ pipeline_configuration = scope .pipeline_configuration ,
324
+ )
325
+
326
+ for pipeline_name in pipeline_names :
327
+ if pipeline_name in scope .pipelines_by_name :
328
+ filtered_scope .add_pipeline_definition (
329
+ scope .pipelines_by_name [pipeline_name ]
330
+ )
331
+ pipelines_found .append (pipeline_name )
332
+
333
+ if filtered_scope .pipelines_by_name :
334
+ filtered_project .add_scope (filtered_scope )
335
+
336
+ if not pipelines_found :
337
+ available_pipelines = [
338
+ name for scope in self .scopes_by_name .values ()
339
+ for name in scope .pipelines_by_name .keys ()
340
+ ]
341
+ raise ValueError (f"None of the specified pipelines { pipeline_names } were found. Available pipelines: { available_pipelines } " )
342
+
343
+ schema = filtered_project .make_schema ()
344
+ if type_overrides_file is not None :
345
+ overrides_schema = Schema .read_from_file (type_overrides_file )
346
+ schema .merge (overrides_schema )
347
+ return schema
348
+
294
349
def get_child_expanders (self ) -> Iterable [ExpandsSchema ]:
295
350
return self .scopes_by_name .values ()
296
351
0 commit comments