lgaleana commited on
Commit
754049c
1 Parent(s): bcd56f8

Update active_task to active_index

Browse files
Files changed (1) hide show
  1. components.py +11 -10
components.py CHANGED
@@ -140,39 +140,40 @@ class Task:
140
 
141
  def __init__(self, id_: int):
142
  self._id = id_
143
- self._active_task = AITask.NAME # Default
144
- self._inner_tasks = {t.NAME: t(self._id, False) for t in self.AVAILABLE_TASKS}
145
 
146
  def render(self) -> None:
147
- for t in self._inner_tasks.values():
 
148
  t.render()
149
 
150
  @property
151
  def component_id(self) -> gr.Textbox:
152
- return self._inner_tasks[self._active_task].component_id
153
 
154
  @property
155
  def visibilities(self) -> List[gr.Number]:
156
- return [t.visible for t in self._inner_tasks.values()]
157
 
158
  @property
159
  def gr_components(self) -> List[gr.Box]:
160
- return [t.gr_component for t in self._inner_tasks.values()]
161
 
162
  @property
163
  def output(self) -> gr.Textbox:
164
- return self._inner_tasks[self._active_task].output
165
 
166
  @property
167
  def inputs(self) -> List[gr.Textbox]:
168
- return self._inner_tasks[self._active_task].inputs()
169
 
170
  @property
171
  def n_inputs(self) -> int:
172
- return self._inner_tasks[self._active_task].n_inputs
173
 
174
  def execute(self, *args):
175
- inner_task = self._inner_tasks[self._active_task]
176
  print(f"Executing {inner_task._source}: {inner_task._id}")
177
  return inner_task.execute(*args)
178
 
 
140
 
141
  def __init__(self, id_: int):
142
  self._id = id_
143
+ self._active_index = 0 # Default
144
+ self._inner_tasks = [t(self._id, False) for t in self.AVAILABLE_TASKS]
145
 
146
  def render(self) -> None:
147
+ self.active_index = gr.Number(self._active_index, visible=False)
148
+ for t in self._inner_tasks:
149
  t.render()
150
 
151
  @property
152
  def component_id(self) -> gr.Textbox:
153
+ return self._inner_tasks[self._active_index].component_id
154
 
155
  @property
156
  def visibilities(self) -> List[gr.Number]:
157
+ return [t.visible for t in self._inner_tasks]
158
 
159
  @property
160
  def gr_components(self) -> List[gr.Box]:
161
+ return [t.gr_component for t in self._inner_tasks]
162
 
163
  @property
164
  def output(self) -> gr.Textbox:
165
+ return self._inner_tasks[self._active_index].output
166
 
167
  @property
168
  def inputs(self) -> List[gr.Textbox]:
169
+ return self._inner_tasks[self._active_index].inputs()
170
 
171
  @property
172
  def n_inputs(self) -> int:
173
+ return self._inner_tasks[self._active_index].n_inputs
174
 
175
  def execute(self, *args):
176
+ inner_task = self._inner_tasks[self._active_index]
177
  print(f"Executing {inner_task._source}: {inner_task._id}")
178
  return inner_task.execute(*args)
179