1919
2020
2121def get_manifest (prefix : str ):
22- paths = pathlib .Path (prefix ).rglob ('manifest.json' )
23- try :
24- path = next (paths )
25- except StopIteration as e :
22+ paths = list (pathlib .Path (prefix ).rglob ('manifest.json' ))
23+ if len (paths ) == 0 :
2624 logging .error (f'No manifest.json file found in path { prefix } ' )
27- raise SystemExit ('Failed' ) from e
25+ raise SystemExit ('Failed' )
26+ elif len (paths ) > 1 :
27+ logging .warning (f'Multiple manifest.json files found in path { prefix } this can lead to unexpected behaviour' )
28+ path = paths [0 ]
2829 with open (path , 'r' ) as f :
2930 raw_manifest = json .load (f )
3031 parser .validate_manifest (raw_manifest ) # FIX
@@ -33,12 +34,13 @@ def get_manifest(prefix: str):
3334
3435
3536def get_catalog (prefix : str ):
36- paths = pathlib .Path (prefix ).rglob ('catalog.json' )
37- try :
38- path = next (paths )
39- except StopIteration as e :
37+ paths = list (pathlib .Path (prefix ).rglob ('catalog.json' ))
38+ if len (paths ) == 0 :
4039 logging .error (f'No catalog.json file found in path { prefix } ' )
41- raise SystemExit ('Failed' ) from e
40+ raise SystemExit ('Failed' )
41+ elif len (paths ) > 1 :
42+ logging .warning (f'Multiple catalog.json files found in path { prefix } this can lead to unexpected behaviour' )
43+ path = paths [0 ]
4244 with open (path , 'r' ) as f :
4345 raw_catalog = json .load (f )
4446 parser .validate_catalog (raw_catalog )
@@ -47,12 +49,13 @@ def get_catalog(prefix: str):
4749
4850
4951def get_dbt_project_config (prefix : str ):
50- paths = pathlib .Path (prefix ).rglob ('dbt_project.yml' )
51- try :
52- path = next (paths )
53- except StopIteration as e :
52+ paths = list (pathlib .Path (prefix ).rglob ('dbt_project.yml' ))
53+ if len (paths ) == 0 :
5454 logging .error (f'No dbt_project.yml file found in path { prefix } ' )
55- raise SystemExit ('Failed' ) from e
55+ raise SystemExit ('Failed' )
56+ elif len (paths ) > 1 :
57+ logging .warning (f'Multiple dbt_project.yml files found in path { prefix } this can lead to unexpected behaviour' )
58+ path = paths [0 ]
5659 with open (path , 'r' ) as f :
5760 project_config = yaml .load (f , Loader = Loader )
5861 logging .debug (f'Detected valid dbt config at { path } ' )
0 commit comments