@@ -97,6 +97,7 @@ async def fetch_all(
9797 repository : str = "biocontainers" ,
9898 params : Optional [Dict [str , str ]] = None ,
9999 headers : Optional [Dict [str , str ]] = None ,
100+ log_file : Path = Path (".quay.log" ),
100101 ) -> List [str ]:
101102 """Fetch all container images and their tags."""
102103 if headers is None :
@@ -115,6 +116,7 @@ async def fetch_all(
115116 images = await cls ._fetch_tags (
116117 client = client , repository = repository , names = names
117118 )
119+ log_images (log_file = log_file , images = images )
118120 return images
119121
120122 @classmethod
@@ -233,6 +235,7 @@ def fetch_all(
233235 cls ,
234236 urls : Iterable [str ],
235237 headers : Optional [Dict [str , str ]] = None ,
238+ log_file : Path = Path (".singularity.log" ),
236239 ) -> List [str ]:
237240 """Parse container images from each given URL."""
238241 if headers is None :
@@ -250,6 +253,10 @@ def fetch_all(
250253 images .extend (parser .images )
251254 else :
252255 logger .warning ("No images found at '%s'." , url )
256+ with log_file .open ("w" ) as handle :
257+ for img in images :
258+ handle .write (f"{ img } \n " )
259+ log_images (log_file = log_file , images = images )
253260 return images
254261
255262 @staticmethod
@@ -267,14 +274,22 @@ def _fetch_images(client: httpx.Client, url: str) -> Optional[str]:
267274 return response .text
268275
269276
277+ def log_images (log_file : Path , images : List [str ]) -> None :
278+ with log_file .open ("w" ) as handle :
279+ for img in images :
280+ handle .write (f"{ img } \n " )
281+
282+
270283def get_new_images (
271284 quay_images : Iterable [str ],
272285 singularity_images : Iterable [str ],
273286 denylist : Iterable [str ],
287+ log_file : Path = Path (".diff.log" ),
274288) -> List [str ]:
275289 """Identify new images from the given lists."""
276290 denylist = tuple (denylist )
277- result = frozenset (quay_images ) - frozenset (singularity_images )
291+ result = sorted (frozenset (quay_images ) - frozenset (singularity_images ))
292+ log_images (log_file = log_file , images = result )
278293 # Filter new images using the deny list.
279294 # FIXME: Is it necessary to sort bioconductor images to the end as before?
280295 return sorted (
@@ -366,17 +381,11 @@ def main(argv: Optional[List[str]] = None) -> None:
366381 logger .info ("Fetching quay.io BioContainers images." )
367382 quay_images = asyncio .run (QuayImageFetcher .fetch_all (api_url = args .quay_api ))
368383 logger .info (f"Found { len (quay_images ):,} images with tags." )
369- with open (".quay.log" , "w" ) as handle :
370- for img in quay_images :
371- handle .write (f"{ img } \n " )
372384 logger .info ("Fetching Singularity BioContainers images." )
373385 singularity_images = SingularityImageFetcher .fetch_all (
374386 urls = args .singularity .split ("," )
375387 )
376388 logger .info (f"Found { len (singularity_images ):,} images with tags." )
377- with open (".singularity.log" , "w" ) as handle :
378- for img in quay_images :
379- handle .write (f"{ img } \n " )
380389 logger .info ("Parsing container image deny list." )
381390 denylist = parse_denylist (args .denylist )
382391 images = get_new_images (quay_images , singularity_images , denylist )
0 commit comments