code: def notebook_complete(self, **kwargs):
          
          self.end_time = self.now()
          self.nb.metadata.papermill['end_time'] = self.end_time.isoformat()
          if self.nb.metadata.papermill.get('start_time'):
              self.nb.metadata.papermill['duration'] = (
                  self.end_time - self.start_time
              ).total_seconds()
  
          # Cleanup cell statuses in case callbacks were never called
          for cell in self.nb.cells:
              if cell.metadata.papermill['status'] == self.FAILED:
                  break
              elif cell.metadata.papermill['status'] == self.PENDING:
                  cell.metadata.papermill['status'] = self.COMPLETED
  
          self.complete_pbar()
          self.cleanup_pbar()
  
          # Force a final sync
          self.save()
docs: Finalize the metadata for a notebook and save the notebook to
          the output path.
  
          Called by Engine when execution concludes, regardless of exceptions.