@@ -113,7 +113,7 @@ def _process_iterator_item(item: Any, openapi_schema: dict) -> Any:
113
113
# If items are file URLs, download them
114
114
if items_schema .get ("type" ) == "string" and items_schema .get ("format" ) == "uri" :
115
115
if isinstance (item , str ) and item .startswith (("http://" , "https://" )):
116
- return _download_file (item )
116
+ return PathProxy (item )
117
117
118
118
return item
119
119
@@ -208,6 +208,37 @@ def __str__(self) -> str:
208
208
return str (self .iterator_factory ())
209
209
210
210
211
+ class PathProxy (Path ):
212
+ def __init__ (self , target : str ) -> None :
213
+ path : Path | None = None
214
+
215
+ def ensure_path () -> Path :
216
+ nonlocal path
217
+ if path is None :
218
+ path = _download_file (target )
219
+ return path
220
+
221
+ object .__setattr__ (self , "__target__" , target )
222
+ object .__setattr__ (self , "__path__" , ensure_path )
223
+
224
+ def __getattribute__ (self , name ) -> Any :
225
+ if name in ("__path__" , "__target__" ):
226
+ return object .__getattribute__ (self , name )
227
+
228
+ return getattr (object .__getattribute__ (self , "__path__" )(), name )
229
+
230
+ def __setattr__ (self , name , value ) -> None :
231
+ if name in ("__path__" , "__target__" ):
232
+ raise ValueError ()
233
+
234
+ object .__setattr__ (object .__getattribute__ (self , "__path__" )(), name , value )
235
+
236
+ def __delattr__ (self , name ) -> None :
237
+ if name in ("__path__" , "__target__" ):
238
+ raise ValueError ()
239
+ delattr (object .__getattribute__ (self , "__path__" )(), name )
240
+
241
+
211
242
@dataclass
212
243
class Run :
213
244
"""
0 commit comments