(self, task_id=None, api=None)
| 227 | return self.id |
| 228 | |
| 229 | def end(self, task_id=None, api=None): |
| 230 | import modules.devices |
| 231 | if debug_output: |
| 232 | log.trace(f'State end: {self}') |
| 233 | if task_id is not None: |
| 234 | prev_job = self.find(task_id) |
| 235 | if prev_job is not None: |
| 236 | self.id = prev_job['id'] |
| 237 | self.job = prev_job['job'] |
| 238 | self.duration = round(time.time() - prev_job['timestamp'], 3) if prev_job['timestamp'] is not None else None |
| 239 | self.time_start = time.time() |
| 240 | if api is not None: |
| 241 | self.api = api |
| 242 | self.history('end', task_id or self.id) |
| 243 | self.clear() |
| 244 | modules.devices.torch_gc() |
| 245 | |
| 246 | def step(self, step:int=1): |
| 247 | self.sampling_step += step |
no test coverage detected