"""TIF service CLI commands."""importasyncioimportjsonfromtypingimportAnyimportclickfrompydanticimportValidationErrorfrompoiesis.api.tes.modelsimportTesInputfrompoiesis.cli.commands.poiesis.baseimportBaseCommandfrompoiesis.core.services.filer.filer_strategy_factoryimportSTRATEGY_MAPfrompoiesis.core.services.filer.tifimportTif
[docs]classTifCommand(BaseCommand):"""TIF CLI command implementation."""name="tif"help="Task Input Filer service"description="Task Input Filer service for handling task input files."
[docs]defadd_run_command(self,group:click.Group)->None:"""Add TIF run command. Args: group: Click group to add the command to """@group.command(name="run",help="Execute a TIF task to download input files",)@click.option("--name",required=True,help="Name of the task")@click.option("--inputs",required=True,help="List of task inputs as JSON")defrun(name:str,inputs:str):"""Execute a TIF task with the provided parameters."""try:inputs_json=json.loads(inputs)_inputs=[TesInput(**input_)forinput_ininputs_json]file_count=len(_inputs)click.echo("--- TIF Task Information ---")click.echo(f"Task: {name}")click.echo(f"Input files: {file_count}")click.echo("--------------------------")click.echo("Downloading input files...")asyncio.run(Tif(name,_inputs).execute())exceptjson.JSONDecodeErrorase:raiseclick.ClickException(f"JSON parsing error: {str(e)}")fromeexceptValidationErrorase:raiseclick.ClickException(f"Validation error: {str(e)}")fromeexceptExceptionase:raiseclick.ClickException(f"Error: {str(e)}")frome
[docs]defget_info(self)->dict[str,Any]:"""Get TIF service information. Returns: Dictionary with TIF service information """info=super().get_info()info.update({"description":"Task Input Filer service for handling task input files","supported_protocols":", ".join([v.nameifv.inputelse""forvinSTRATEGY_MAP.values()ifv.input]),})returndict(sorted({k.replace("_"," ").title():vfork,vininfo.items()}.items()))