"""Entry point for the TIF service."""importloggingfrompoiesis.api.tes.modelsimportTesInputfrompoiesis.core.ports.message_brokerimportMessage,MessageStatusfrompoiesis.core.services.filer.filerimportFilerfrompoiesis.core.services.filer.filer_strategy_factoryimportFilerStrategyFactorylogger=logging.getLogger(__name__)
[docs]classTif(Filer):"""Task input filer. Args: name: Name of the task. inputs: List of task inputs. Attributes: name: Name of the task. inputs: List of task inputs. message_broker: Message broker. """def__init__(self,name:str,inputs:list[TesInput])->None:"""Task input filer. Args: name: Name of the task. inputs: List of task inputs. Attributes: name: Name of the task. inputs: List of task inputs. message_broker: Message broker. """super().__init__()self._name=nameself.inputs=inputs@propertydefname(self)->str:"""Name of the filer."""returnself._name
[docs]asyncdeffile(self)->None:"""Filing logic, download. Raises: Exception: If the file cannot be downloaded. """forinputinself.inputs:logger.info(f"Downloading {input.url} to {input.path}")filer_strategy=FilerStrategyFactory.create_strategy(input.url,input)logger.debug(f"Filer strategy: {filer_strategy.__class__.__name__}")try:awaitfiler_strategy.download()exceptExceptionase:logger.error(f"Error downloading {input.url}: {str(e)}")self.message(Message(status=MessageStatus.ERROR,message=f"TIF failed: {str(e)}"))raise