
from gws_core import (ConfigParams, ConfigSpecs, InputSpec, InputSpecs, OutputSpec, OutputSpecs, Resource, Task, TaskInputs, TaskOutputs, task_decorator)
from gws_core import Table, ReportResource


@task_decorator(unique_name="Pylivetask")
class Pylivetask(Task):

	input_specs: InputSpecs = InputSpecs({'resource_1': InputSpec(Resource), 'resource_2': InputSpec(Resource)})
	output_specs: OutputSpecs = OutputSpecs({'resource_1': OutputSpec(Resource)})
	config_specs: ConfigSpecs = {}

	def run(self, params: ConfigParams, inputs: TaskInputs) -> TaskOutputs:# This is a snippet template for a python live task.
		# This code is executed in the same context as the run method of a Task.
		# This mean you can import brick or packages and call method of the Task object.
		
		# HOW TO?
		# 2 variables are reserved in a python live task
		# - sources: array containing the input resource
		# - targets: array that must be filled with output resources
		
		
		# Import modules
		
		report = sources[0]
		# Transpose the input table
		table: Table = sources[1]
		name = table.column_names[0]
		
		report.replace_variable('test', name)
		report.replace_variable('figure_1', 'SALUUUT')
		report.save()
		# set the new table a output or the live task
		targets = [report]

