extension.sh 2.34 KB
Newer Older
chenpangpang's avatar
chenpangpang committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
echo "启动jupyter 检查文件中..."

WORKSPACE="/tmp/jupyter-extension"

content=$(nohup jupyter lab --allow-root --ip=0.0.0.0 --port=8888 > /tmp/start.log 2>&1 & sleep 20s; cat /tmp/start.log| grep "JupyterLab application directory")
 
echo $content

if [ -z "$content" ]; then
        echo "content Not Found! please retry!"

else
        jupyter_file_path=$(echo "$content" | grep -oP '(?<=is\s)(\/[^ ]+)')
fi

# ls "${jupyter_file_path}/static/index.html"
# echo "jupyter sourcecode path is :${jupyter_file_path}/static"


file_check=$(if [ -d "${jupyter_file_path}/static" ]; then echo "success"; else echo "file check failed"; fi)
echo $file_check
if [ "failed" == "$file_check" ]; then
        echo "image jupyter sourcecode  path check failed! please retry!"
fi

# 获取index的内容 那去js名 替换
js_content=$(cat ${jupyter_file_path}/static/index.html)

echo $js_content
js_path=$(echo "$js_content" | grep -oP '{{page_config\.fullStaticUrl}}/main\.[^"]+\.js\?v=[^"]+' )

js_path2=$(echo "$js_content" | grep -oP '{{page_config\.fullStaticUrl}}/vendors~main\.[^"]+\.js\?v=[^"]+' )

js_path3=$(echo "$js_content" | grep -oP '{{page_config\.fullStaticUrl}}/vendors~main\.[^"]+\.js' )

echo "jupyter js source path is: $js_path"

if [ -z "$js_path" ];then
    if [ -z "$js_path2" ];then
            if [ -z "$js_path3" ];then
                    echo "image jupyter sourcecode main js path check failed!please retry!"
            else
                    js_path=$js_path3
            fi
    else
            js_path=$js_path2
    fi   
fi

cat $WORKSPACE/static/index-base.html > $WORKSPACE/static/index.html

sed -i "s#mainJsParam#${js_path}#g" $WORKSPACE/static/index.html

cp -a $WORKSPACE/static/index.html ${jupyter_file_path}/static/index.html

cp -a $WORKSPACE/static/scnet-loading.gif ${jupyter_file_path}/static/scnet-loading.gif


pip3 uninstall -r $WORKSPACE/requirements.txt

pip3 install --no-index --find-links=$WORKSPACE/ -r $WORKSPACE/requirements.txt

chenpangpang's avatar
chenpangpang committed
63
if  pip list | grep -E 'jupyter_ext_platform' && pip list | grep -E 'jupyter_ext_model' && pip list | grep -E 'jupyterlab-language-pack-zh-CN' && [ "$(jupyter lab --version | cut -d. -f1)" -gt 2 ];then echo "安装成功";else echo \"安装失败!! \" | tee /jupyter-ext/errorImages.txt; fi
chenpangpang's avatar
chenpangpang committed
64

chenpangpang's avatar
chenpangpang committed
65
66
67
68
# 禁用splash插件
jupyter labextension disable @jupyterlab/apputils-extension:splash

rm -r $WORKSPACE