44from pystac_client import Client
55import requests
66from pydantic_ai import Agent , RunContext
7- from pprint import pprint
7+ from pprint import pformat
88import os
9+ import logging
910
1011from stac_search .agents .collections_search import (
1112 collection_search ,
1213 CollectionWithExplanation ,
1314)
1415
15- GEODINI_API = os .getenv ("GEODINI_API" )
16+
17+ GEODINI_API = os .getenv ("GEODINI_API" , "https://geodini.k8s.labs.ds.io" )
18+
19+ logger = logging .getLogger (__name__ )
1620
1721
1822@dataclass
@@ -87,9 +91,9 @@ class CollectionSearchResult:
8791
8892
8993async def search_collections (query : str ) -> CollectionSearchResult | None :
90- # print ("Searching for relevant collections ...")
94+ logger . info ("Searching for relevant collections ..." )
9195 collection_query = await collection_query_framing_agent .run (query )
92- print ( "Framed collection query: " , collection_query .data .query )
96+ logger . info ( f "Framed collection query: { collection_query .data .query } " )
9397 if collection_query .data .is_specific :
9498 collections = await collection_search (collection_query .data .query )
9599 return CollectionSearchResult (collections = collections )
@@ -231,11 +235,11 @@ async def item_search(ctx: Context) -> ItemSearchResult:
231235 results = await search_items_agent .run (
232236 f"Find items for the query: { ctx .query } " , deps = ctx
233237 )
234- print (results .data )
238+ logger . info (results .data )
235239
236240 # determine the collections to search
237241 target_collections = await search_collections (ctx .query ) or []
238- print ( "Target collections: " , target_collections )
242+ logger . info ( f "Target collections: { pformat ( target_collections ) } " )
239243 default_target_collections = [
240244 "landsat-8-c2-l2" ,
241245 "sentinel-2-l2a" ,
@@ -267,17 +271,15 @@ async def item_search(ctx: Context) -> ItemSearchResult:
267271 "filter" : results .data .filter ,
268272 }
269273
270- print (f"Searching with params: { params } " )
274+ logger . info (f"Searching with params: { params } " )
271275
272276 polygon = get_polygon_from_geodini (results .data .location )
273277 if polygon :
274- print (f"Found polygon for { results .data .location } " )
278+ logger . info (f"Found polygon for { results .data .location } " )
275279 params ["intersects" ] = polygon
276280
277- # print(f"Searching with params: {params}")
278-
279281 if ctx .return_search_params_only :
280- print ("Returning STAC query parameters only" )
282+ logger . info ("Returning STAC query parameters only" )
281283 return ItemSearchResult (
282284 search_params = params , aoi = polygon , explanation = explanation
283285 )
@@ -291,7 +293,7 @@ async def item_search(ctx: Context) -> ItemSearchResult:
291293async def main ():
292294 ctx = Context (query = "NAIP imagery from Washington state" )
293295 results = await item_search (ctx )
294- pprint ( results )
296+ logger . info ( pformat ( results ) )
295297
296298
297299if __name__ == "__main__" :
0 commit comments