22import time
33from typing import Any
44
5- import httpx
65from pydantic import BaseModel
76
87from oxylabs_ai_studio .client import OxyStudioAIClient
@@ -57,7 +56,7 @@ def map(
5756 try :
5857 get_response = self .call_api (
5958 client = client ,
60- url = "/map/run" ,
59+ url = "/map/run/data " ,
6160 method = "GET" ,
6261 params = {"run_id" : run_id },
6362 )
@@ -72,7 +71,7 @@ def map(
7271 return AiMapJob (
7372 run_id = run_id ,
7473 message = resp_body .get ("message" , None ),
75- data = self . _get_data ( client = client , run_id = run_id ) ,
74+ data = resp_body . get ( "data" , {}) or {} ,
7675 )
7776 if resp_body ["status" ] == "failed" :
7877 return AiMapJob (
@@ -88,14 +87,6 @@ def map(
8887 raise e
8988 raise TimeoutError (f"Failed to map { url } : timeout." )
9089
91- def _get_data (self , client : httpx .Client , run_id : str ) -> dict [str , Any ]:
92- get_response = self .call_api (
93- client = client , url = "/map/run/data" , method = "GET" , params = {"run_id" : run_id }
94- )
95- if get_response .status_code != 200 :
96- raise Exception (f"Failed to get data for run { run_id } : { get_response .text } " )
97- return get_response .json ().get ("data" , {}) or {}
98-
9990 async def map_async (
10091 self ,
10192 url : str ,
@@ -126,7 +117,7 @@ async def map_async(
126117 try :
127118 get_response = await self .call_api_async (
128119 client = client ,
129- url = "/map/run" ,
120+ url = "/map/run/data " ,
130121 method = "GET" ,
131122 params = {"run_id" : run_id },
132123 )
@@ -138,11 +129,10 @@ async def map_async(
138129 continue
139130 resp_body = get_response .json ()
140131 if resp_body ["status" ] == "completed" :
141- data = await self .get_data_async (client , run_id = run_id )
142132 return AiMapJob (
143133 run_id = run_id ,
144134 message = resp_body .get ("message" , None ),
145- data = data ,
135+ data = resp_body . get ( " data" , {}) or {} ,
146136 )
147137 if resp_body ["status" ] == "failed" :
148138 return AiMapJob (
@@ -157,13 +147,3 @@ async def map_async(
157147 except Exception as e :
158148 raise e
159149 raise TimeoutError (f"Failed to map { url } : timeout." )
160-
161- async def get_data_async (
162- self , client : httpx .AsyncClient , run_id : str
163- ) -> dict [str , Any ]:
164- get_response = await self .call_api_async (
165- client = client , url = "/map/run/data" , method = "GET" , params = {"run_id" : run_id }
166- )
167- if get_response .status_code != 200 :
168- raise Exception (f"Failed to get data for run { run_id } : { get_response .text } " )
169- return get_response .json ().get ("data" , {}) or {}
0 commit comments