Update active_task to active_index
Browse files- 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.
|
144 |
-
self._inner_tasks =
|
145 |
|
146 |
def render(self) -> None:
|
147 |
-
|
|
|
148 |
t.render()
|
149 |
|
150 |
@property
|
151 |
def component_id(self) -> gr.Textbox:
|
152 |
-
return self._inner_tasks[self.
|
153 |
|
154 |
@property
|
155 |
def visibilities(self) -> List[gr.Number]:
|
156 |
-
return [t.visible for t in self._inner_tasks
|
157 |
|
158 |
@property
|
159 |
def gr_components(self) -> List[gr.Box]:
|
160 |
-
return [t.gr_component for t in self._inner_tasks
|
161 |
|
162 |
@property
|
163 |
def output(self) -> gr.Textbox:
|
164 |
-
return self._inner_tasks[self.
|
165 |
|
166 |
@property
|
167 |
def inputs(self) -> List[gr.Textbox]:
|
168 |
-
return self._inner_tasks[self.
|
169 |
|
170 |
@property
|
171 |
def n_inputs(self) -> int:
|
172 |
-
return self._inner_tasks[self.
|
173 |
|
174 |
def execute(self, *args):
|
175 |
-
inner_task = self._inner_tasks[self.
|
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 |
|