def _transaction( self, project_uuid: str, pipeline_uuid: str, pipeline_path: str, project_dir: str, host_userdir: str, ): # Gate check to see if there is a Jupyter lab build active latest_jupyter_build = models.JupyterBuild.query.order_by( desc(models.JupyterBuild.requested_time)).first() if latest_jupyter_build is not None and latest_jupyter_build.status in [ "PENDING", "STARTED", ]: raise JupyterBuildInProgressException() interactive_session = { "project_uuid": project_uuid, "pipeline_uuid": pipeline_uuid, "status": "LAUNCHING", } db.session.add(models.InteractiveSession(**interactive_session)) self.collateral_kwargs["project_uuid"] = project_uuid self.collateral_kwargs["pipeline_uuid"] = pipeline_uuid self.collateral_kwargs["pipeline_path"] = pipeline_path self.collateral_kwargs["project_dir"] = project_dir self.collateral_kwargs["host_userdir"] = host_userdir
def post(self): """Launches an interactive session.""" post_data = request.get_json() # TODO: error handling. If it does not succeed then the initial # entry has to be removed from the database as otherwise # no session can be started in the future due to unique # constraint. # Add initial entry to database. pipeline_uuid = post_data["pipeline_uuid"] pipeline_path = post_data["pipeline_path"] project_uuid = post_data["project_uuid"] interactive_session = { "project_uuid": project_uuid, "pipeline_uuid": pipeline_uuid, "status": "LAUNCHING", } db.session.add(models.InteractiveSession(**interactive_session)) db.session.commit() session = InteractiveSession(docker_client, network="orchest") session.launch( pipeline_uuid, project_uuid, pipeline_path, post_data["project_dir"], post_data["settings"]["data_passing_memory_size"], post_data["host_userdir"], ) # Update the database entry with information to connect to the # launched resources. IP = session.get_containers_IP() interactive_session.update({ "status": "RUNNING", "container_ids": session.get_container_IDs(), "jupyter_server_ip": IP.jupyter_server, "notebook_server_info": session.notebook_server_info, }) models.InteractiveSession.query.filter_by( project_uuid=project_uuid, pipeline_uuid=pipeline_uuid).update(interactive_session) db.session.commit() return interactive_session, 201
def _transaction( self, project_uuid: str, pipeline_uuid: str, pipeline_path: str, project_dir: str, host_userdir: str, ): interactive_session = { "project_uuid": project_uuid, "pipeline_uuid": pipeline_uuid, "status": "LAUNCHING", } db.session.add(models.InteractiveSession(**interactive_session)) self.collateral_kwargs["project_uuid"] = project_uuid self.collateral_kwargs["pipeline_uuid"] = pipeline_uuid self.collateral_kwargs["pipeline_path"] = pipeline_path self.collateral_kwargs["project_dir"] = project_dir self.collateral_kwargs["host_userdir"] = host_userdir
def post(self): """Launches an interactive session.""" post_data = request.get_json() # TODO: error handling. If it does not succeed then the initial # entry has to be removed from the database as otherwise # no session can be started in the future due to unique # constraint. # Add initial entry to database. pipeline_uuid = post_data['pipeline_uuid'] interactive_session = { 'pipeline_uuid': pipeline_uuid, 'status': 'LAUNCHING', } db.session.add(models.InteractiveSession(**interactive_session)) db.session.commit() session = InteractiveSession(docker_client, network='orchest') session.launch(pipeline_uuid, post_data['pipeline_dir'], post_data['host_userdir']) # Update the database entry with information to connect to the # launched resources. IP = session.get_containers_IP() interactive_session.update({ 'status': 'RUNNING', 'container_ids': session.get_container_IDs(), 'jupyter_server_ip': IP.jupyter_server, 'notebook_server_info': session.notebook_server_info, }) models.InteractiveSession.query \ .filter_by(pipeline_uuid=pipeline_uuid) \ .update(interactive_session) db.session.commit() return interactive_session, 201