Просмотр исходного кода

jupyter查看状态地址修改

liweiquan 1 год назад
Родитель
Сommit
6ad394762e
1 измененных файлов с 6 добавлено и 4 удалено
  1. 6 4
      app/crud/programme.py

+ 6 - 4
app/crud/programme.py

@@ -72,9 +72,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()
@@ -111,8 +109,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()
@@ -124,6 +125,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)