@@ -375,15 +375,17 @@ def _patch_resource(
375375 raise MPRestError (str (ex ))
376376
377377 def _query_open_data (
378- self , bucket : str , key : str , decoder : Callable , fields : list [str ]
378+ self ,
379+ bucket : str ,
380+ key : str ,
381+ decoder : Callable ,
379382 ) -> tuple [list [dict ] | list [bytes ], int ]:
380383 """Query and deserialize Materials Project AWS open data s3 buckets.
381384
382385 Args:
383386 bucket (str): Materials project bucket name
384387 key (str): Key for file including all prefixes
385388 decoder(Callable): Callable used to deserialize data
386- fields (list[str]): List of fields to project out of the retrieved data
387389
388390 Returns:
389391 dict: MontyDecoded data
@@ -398,19 +400,10 @@ def _query_open_data(
398400 decoded_data = [decoder (jline ) for jline in file .read ().splitlines ()]
399401 else :
400402 decoded_data = decoder (file .read ())
403+ if not isinstance (decoded_data , list ):
404+ decoded_data = [decoded_data ]
401405
402- decoded_data = (
403- [decoded_data ] if not isinstance (decoded_data , list ) else decoded_data
404- )
405-
406- unzipped_data = []
407- for doc in decoded_data :
408- if fields :
409- doc = {key : value for key , value in doc .items () if key in fields }
410-
411- unzipped_data .append (doc )
412-
413- return unzipped_data , len (unzipped_data ) # type: ignore
406+ return decoded_data , len (decoded_data ) # type: ignore
414407
415408 def _query_resource (
416409 self ,
@@ -456,16 +449,8 @@ def _query_resource(
456449 criteria = {}
457450
458451 # Query s3 if no query is passed and all documents are asked for
459- query_s3 = (
460- not bool (
461- {
462- field
463- for field in criteria
464- if field [0 ] != "_" and field != "deprecated"
465- }
466- )
467- and num_chunks is None
468- )
452+ no_query = not {field for field in criteria if field [0 ] != "_" }
453+ query_s3 = no_query and num_chunks is None
469454
470455 if fields :
471456 if isinstance (fields , str ):
@@ -517,6 +502,11 @@ def _query_resource(
517502 timeout = timeout ,
518503 )
519504
505+ if fields :
506+ warnings .warn (
507+ "Ignoring `fields` argument: All fields are always included when downloading full collections."
508+ )
509+
520510 decoder = (
521511 MontyDecoder ().decode if self .monty_decode else json_util .loads
522512 )
@@ -527,7 +517,6 @@ def _query_resource(
527517 "bucket" : bucket ,
528518 "key" : key ,
529519 "decoder" : decoder ,
530- "fields" : fields ,
531520 }
532521 for key in keys
533522 }
0 commit comments