[docs]classContentFilerStrategy(FilerStrategy):"""Content filer, if the content is given in the request."""def__init__(self,payload:TesInput|TesOutput):"""Initialize the content filer strategy. Args: payload: The payload to instantiate the strategy implementation. """super().__init__(payload)self.input=self.payloadifisinstance(self.payload,TesInput)elseNoneself.output=self.payloadifisinstance(self.payload,TesOutput)elseNone
[docs]asyncdefdownload_input_file(self,container_path:str)->None:"""Get the content from request and mount to PVC. Args: container_path: The path inside the container where the file needs to be downloaded to. """assertself.inputisnotNoneifself.input.contentisNone:raiseValueError("Content is required for content filer strategy.")content=self.input.content.encode("utf-8")withopen(container_path,"wb")asf:f.write(content)logger.info(f"Created file with content at {container_path}.")
[docs]asyncdefdownload_input_directory(self,container_path:str):"""Download input directory. Raises: NotImplementedError: Content filer doesn't support downloading directories. """raiseNotImplementedError("Content filer doesn't support downloading directories.")
[docs]asyncdefupload_output_file(self,container_path:str)->None:"""Mount the content to PVC. Content filer does not support uploads according to TES spec. Args: container_path: The path inside the container from where the file needs to be uploaded from. """logger.error(f"Attempted to upload content from {container_path} which is not supported")raiseNotImplementedError("Content filer does not support uploads according to TES spec.")
[docs]asyncdefupload_output_directory(self,container_path:str):"""Upload output dir. Raises: NotImplementedError: Content filer doesn't support uploading directories. """raiseNotImplementedError("Content filer does not support uploads according to TES spec.")
[docs]asyncdefupload_glob(self,glob_files:list[tuple[str,str,bool]]):"""Upload output dir. Raises: NotImplementedError: Content filer doesn't support uploading directories. """raiseNotImplementedError("Content filer does not support uploads according to TES spec.")