浏览代码

jupyter查看状态地址修改

liweiquan 1 年之前
父节点
当前提交
a6fc87cf82
共有 1 个文件被更改,包括 6 次插入4 次删除
  1. 6 4
      app/crud/programme.py

+ 6 - 4
app/crud/programme.py

@@ -70,9 +70,7 @@ def start_jupyter(db: Session, item: schemas.ProgrammeId):
     c_res = send_util.create_jupyter(jupyter_create_data)
     j_data = c_res['data'] if 'data' in c_res.keys() else None
     if not j_data:
-        # send_util.stop_jupyter({'namespace': namespace,'release_name': db_item.release_name})
         raise Exception("启动结构化编码失败")
-    url = f"http://{j_data['host']}{j_data['base_url']}/lab"
     db_item.status = 0
     db.commit()
     db.flush()
@@ -109,8 +107,11 @@ def get_programme(db: Session):
     db_items: List[models.Programme] = db.query(models.Programme).filter(models.Programme.project_id == g.project_id).all()
     res = []
     for item in db_items:
-        complete_url =f'http://{host}{item.base_url}/lab'
-        jupyter_status = get_programme_status(complete_url)
+        # 前端与本地访问使用
+        complete_url = f'http://{host}{item.base_url}/lab'
+        # 集群内部访问使用
+        request_url = f'http://{item.release_name}-jupyterlab:8888{item.base_url}/lab'
+        jupyter_status = get_programme_status(request_url)
         item.status = jupyter_status
         db.commit()
         db.flush()
@@ -122,6 +123,7 @@ def get_programme(db: Session):
 
 
 def get_programme_status(url: str):
+    print(url)
     res_header= send_util.get_jupyter_html(url)
     # 若为启动状态,则Server中包含Tornado,否则没有启动
     print(res_header)