jupyter url

chromesetting
guange 5 years ago
parent b74a090510
commit 843e44976f

@ -14,7 +14,7 @@ class ChallengesController < ApplicationController
include ChallengesHelper
helper_method :jupyter_url
# 新建实践题
def new
@ -163,22 +163,7 @@ class ChallengesController < ApplicationController
@shixun.increment!(:visits)
end
def jupyter_url(shixun)
#打开tpm - juypter接口
if shixun.is_jupyter?
shixun_tomcat = edu_setting('cloud_bridge')
uri = "#{shixun_tomcat}/bridge/jupyter/get"
tpiID = "tpm#{shixun.id}"
params = {tpiID: tpiID, :containers => "#{Base64.urlsafe_encode64(shixun_container_limit(shixun))}"}
logger.info "test_juypter: uri->#{uri}, params->#{params}"
res = uri_post uri, params
logger.info "test_juypter: #{res}"
return "https://#{res['port']}.jupyter.educoder.net/notebooks/data/workspace/myshixun_#{tpiID}/01.ipynb"
end
end
def show
@tab = params[:tab].nil? ? 1 : params[:tab].to_i

@ -24,6 +24,10 @@ class ShixunsController < ApplicationController
before_action :special_allowed, only: [:send_to_course, :search_user_courses]
helper_method :jupyter_url
## 获取课程列表
def index
@shixuns = current_laboratory.shixuns.unhidden
@ -528,6 +532,23 @@ class ShixunsController < ApplicationController
# @evaluate_scirpt = @shixun.evaluate_script || "无"
end
def jupyter_url(shixun)
#打开tpm - juypter接口
if shixun.is_jupyter?
shixun_tomcat = edu_setting('cloud_bridge')
uri = "#{shixun_tomcat}/bridge/jupyter/get"
tpiID = "tpm#{shixun.id}"
params = {tpiID: tpiID, :containers => "#{Base64.urlsafe_encode64(shixun_container_limit(shixun))}"}
logger.info "test_juypter: uri->#{uri}, params->#{params}"
res = uri_post uri, params
logger.info "test_juypter: #{res}"
return "https://#{res['port']}.jupyter.educoder.net/notebooks/data/workspace/myshixun_#{tpiID}/01.ipynb"
end
end
# 获取脚本内容
def get_script_contents
mirrir_script = MirrorScript.find(params[:script_id])

@ -5,7 +5,7 @@ json.power @editable
json.shixun_identifier @shixun.identifier
json.shixun_status @shixun.status
json.allow_skip @shixun.task_pass
json.jupyter_url jupyter_url(@shixun)
# 列表
if @challenges.present?

@ -42,6 +42,9 @@ json.shixun do
json.(config, :cpu_limit, :lower_cpu_limit, :memory_limit, :request_limit, :mirror_repository_id)
end
end
json.jupyter_url jupyter_url(@shixun)
end

Loading…
Cancel
Save