@@ -441,34 +441,35 @@ async def query(
441
441
def fetch_kwargs_from_manifest (
442
442
file_location : str , manifest : dict [str , Any ], manifest_fallback_location : str
443
443
) -> dict [str , Any ]:
444
- manifest_entry : DocDetails | None = manifest .get (file_location ) or manifest .get (
444
+ manifest_entry : dict [ str , Any ] | None = manifest .get (file_location ) or manifest .get (
445
445
manifest_fallback_location
446
446
)
447
447
if manifest_entry :
448
- return manifest_entry .model_dump ()
448
+ return DocDetails ( ** manifest_entry ) .model_dump ()
449
449
return {}
450
450
451
451
452
452
async def maybe_get_manifest (
453
453
filename : anyio .Path | None = None ,
454
- ) -> dict [str , DocDetails ]:
454
+ ) -> dict [str , dict [ str , Any ] ]:
455
455
if not filename :
456
456
return {}
457
457
if filename .suffix == ".csv" :
458
458
try :
459
459
async with await anyio .open_file (filename , mode = "r" ) as file :
460
460
content = await file .read ()
461
- records = [DocDetails (** r ) for r in csv .DictReader (content .splitlines ())]
462
461
file_loc_to_records = {
463
- str (r .file_location ): r for r in records if r .file_location
462
+ str (r .get ("file_location" )): r
463
+ for r in csv .DictReader (content .splitlines ())
464
+ if r .get ("file_location" )
464
465
}
465
466
if not file_loc_to_records :
466
467
raise ValueError ( # noqa: TRY301
467
468
"No mapping of file location to details extracted from manifest"
468
469
f" file { filename } ."
469
470
)
470
471
logger .debug (
471
- f"Found manifest file at { filename } , read { len (records )} records"
472
+ f"Found manifest file at { filename } , read { len (file_loc_to_records )} records"
472
473
f" from it, which maps to { len (file_loc_to_records )} locations."
473
474
)
474
475
except FileNotFoundError :
0 commit comments