def post(self, request, *args, **kwargs): obj = self.get_object() if obj.has_notebook: commit = request.data.get('commit') commit = to_bool(commit) if commit is not None else True if commit: # Commit changes git.commit(obj.repo.path, request.user.email, request.user.username) else: # Reset changes git.undo(obj.repo.path) celery_app.send_task(SchedulerCeleryTasks.PROJECTS_NOTEBOOK_STOP, kwargs={ 'project_name': obj.unique_name, 'project_uuid': obj.uuid.hex, 'notebook_job_name': obj.notebook.unique_name, 'notebook_job_uuid': obj.notebook.uuid.hex, 'update_status': True }) auditor.record(event_type=NOTEBOOK_STOPPED_TRIGGERED, instance=obj.notebook, target='project', actor_id=self.request.user.id, countdown=1) elif obj.notebook and obj.notebook.is_running: obj.notebook.set_status(status=ExperimentLifeCycle.STOPPED, message='Notebook was stopped') return Response(status=status.HTTP_200_OK)
def handle_code(self, request): commit = request.data.get('commit') commit = to_bool(commit) if commit is not None else True if commit and conf.get(NOTEBOOKS_MOUNT_CODE) and self.project.has_repo: # Commit changes git.commit(self.project.repo.path, request.user.email, request.user.username) else: # Reset changes git.undo(self.project.repo.path)