在modelscope 基础镜像中添加 jupyter lab 插件,用于收集用户在notebook 中的鼠标、键盘事件,来支持静默关闭功能。 主要改变如下: 1. 新增jupyterlab_active_log 插件的源码和编译后的文件 2. 修改Dockerfile.ubuntu 文件,将上述源码文件拷贝的jupyter的插件目录中。 3. 修改pip和conda 的镜像地址为阿里云的 Link: https://code.alibaba-inc.com/Ali-MaaS/MaaS-lib/codereview/10690152master
@@ -7,6 +7,7 @@ ENV PATH="${CONDA_DIR}/bin:${PATH}" | |||
ENV arch=x86_64 | |||
SHELL ["/bin/bash", "-c"] | |||
COPY docker/rcfiles /tmp/resources | |||
COPY docker/jupyter_plugins /tmp/resources/jupyter_plugins | |||
RUN apt-get update && apt-get install -y --reinstall ca-certificates && \ | |||
cp /tmp/resources/ubuntu20.04_sources.tuna /etc/apt/sources.list && \ | |||
apt-get update && \ | |||
@@ -26,7 +27,7 @@ ENV LANG=zh_CN.UTF-8 LANGUAGE=zh_CN.UTF-8 LC_ALL=zh_CN.UTF-8 | |||
#install and config python | |||
ARG PYTHON_VERSION=3.7.13 | |||
RUN wget --quiet https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-${arch}.sh -O ./miniconda.sh && \ | |||
RUN wget --quiet https://mirrors.aliyun.com/anaconda/miniconda/Miniconda3-latest-Linux-${arch}.sh -O ./miniconda.sh && \ | |||
/bin/bash miniconda.sh -b -p /opt/conda && \ | |||
rm -f miniconda.sh && \ | |||
ln -s /opt/conda/etc/profile.d/conda.sh /etc/profile.d/conda.sh && \ | |||
@@ -34,8 +35,8 @@ RUN wget --quiet https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-${a | |||
cp /tmp/resources/conda.tuna ~/.condarc && \ | |||
source /root/.bashrc && \ | |||
conda install --yes python==${PYTHON_VERSION} && \ | |||
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple && \ | |||
pip config set install.trusted-host pypi.tuna.tsinghua.edu.cn | |||
pip config set global.index-url https://mirrors.aliyun.com/pypi/simple && \ | |||
pip config set install.trusted-host mirrors.aliyun.com | |||
ARG USE_GPU=True | |||
@@ -83,3 +84,7 @@ RUN if [ "$USE_GPU" = "True" ] ; then \ | |||
else \ | |||
pip install --no-cache-dir dgl dglgo -f https://data.dgl.ai/wheels/repo.html; \ | |||
fi | |||
# install jupyter plugin | |||
RUN mkdir -p /root/.local/share/jupyter/labextensions/ && \ | |||
cp -r /tmp/resources/jupyter_plugins/* /root/.local/share/jupyter/labextensions/ |
@@ -0,0 +1,99 @@ | |||
{ | |||
"name": "jupyterlab_active_log", | |||
"version": "0.1.0", | |||
"description": "A JupyterLab extension.", | |||
"keywords": [ | |||
"jupyter", | |||
"jupyterlab", | |||
"jupyterlab-extension" | |||
], | |||
"homepage": "https://github.com/github_username/jupyterlab_active_log", | |||
"bugs": { | |||
"url": "https://github.com/github_username/jupyterlab_active_log/issues" | |||
}, | |||
"license": "BSD-3-Clause", | |||
"files": [ | |||
"lib/**/*.{d.ts,eot,gif,html,jpg,js,js.map,json,png,svg,woff2,ttf}", | |||
"style/**/*.{css,js,eot,gif,html,jpg,json,png,svg,woff2,ttf}" | |||
], | |||
"main": "lib/index.js", | |||
"types": "lib/index.d.ts", | |||
"style": "style/index.css", | |||
"repository": { | |||
"type": "git", | |||
"url": "https://github.com/github_username/jupyterlab_active_log.git" | |||
}, | |||
"scripts": { | |||
"build": "jlpm build:lib && jlpm build:labextension:dev", | |||
"build:prod": "jlpm clean && jlpm build:lib && jlpm build:labextension", | |||
"build:labextension": "jupyter labextension build .", | |||
"build:labextension:dev": "jupyter labextension build --development True .", | |||
"build:lib": "tsc", | |||
"clean": "jlpm clean:lib", | |||
"clean:lib": "rimraf lib tsconfig.tsbuildinfo", | |||
"clean:lintcache": "rimraf .eslintcache .stylelintcache", | |||
"clean:labextension": "rimraf jupyterlab_active_log/labextension", | |||
"clean:all": "jlpm clean:lib && jlpm clean:labextension && jlpm clean:lintcache", | |||
"eslint": "jlpm eslint:check --fix", | |||
"eslint:check": "eslint . --cache --ext .ts,.tsx", | |||
"install:extension": "jlpm build", | |||
"lint": "jlpm stylelint && jlpm prettier && jlpm eslint", | |||
"lint:check": "jlpm stylelint:check && jlpm prettier:check && jlpm eslint:check", | |||
"prettier": "jlpm prettier:base --write --list-different", | |||
"prettier:base": "prettier \"**/*{.ts,.tsx,.js,.jsx,.css,.json,.md}\"", | |||
"prettier:check": "jlpm prettier:base --check", | |||
"stylelint": "jlpm stylelint:check --fix", | |||
"stylelint:check": "stylelint --cache \"style/**/*.css\"", | |||
"watch": "run-p watch:src watch:labextension", | |||
"watch:src": "tsc -w", | |||
"watch:labextension": "jupyter labextension watch ." | |||
}, | |||
"dependencies": { | |||
"@jupyterlab/application": "^3.1.0" | |||
}, | |||
"devDependencies": { | |||
"@jupyterlab/builder": "^3.1.0", | |||
"@typescript-eslint/eslint-plugin": "^4.8.1", | |||
"@typescript-eslint/parser": "^4.8.1", | |||
"eslint": "^7.14.0", | |||
"eslint-config-prettier": "^6.15.0", | |||
"eslint-plugin-prettier": "^3.1.4", | |||
"npm-run-all": "^4.1.5", | |||
"prettier": "^2.1.1", | |||
"rimraf": "^3.0.2", | |||
"stylelint": "^14.3.0", | |||
"stylelint-config-prettier": "^9.0.3", | |||
"stylelint-config-recommended": "^6.0.0", | |||
"stylelint-config-standard": "~24.0.0", | |||
"stylelint-prettier": "^2.0.0", | |||
"typescript": "~4.1.3" | |||
}, | |||
"sideEffects": [ | |||
"style/*.css", | |||
"style/index.js" | |||
], | |||
"styleModule": "style/index.js", | |||
"publishConfig": { | |||
"access": "public" | |||
}, | |||
"jupyterlab": { | |||
"extension": true, | |||
"outputDir": "jupyterlab_active_log/labextension", | |||
"_build": { | |||
"load": "static/remoteEntry.eb3177c3791d7658cc12.js", | |||
"extension": "./extension", | |||
"style": "./style" | |||
} | |||
}, | |||
"jupyter-releaser": { | |||
"hooks": { | |||
"before-build-npm": [ | |||
"python -m pip install jupyterlab~=3.1", | |||
"jlpm" | |||
], | |||
"before-build-python": [ | |||
"jlpm clean:all" | |||
] | |||
} | |||
} | |||
} |
@@ -0,0 +1 @@ | |||
"use strict";(self.webpackChunkjupyterlab_active_log=self.webpackChunkjupyterlab_active_log||[]).push([[568],{568:(t,e,a)=>{a.r(e),a.d(e,{default:()=>i});const i={id:"jupyterlab_active_log:plugin",autoStart:!0,activate:t=>{console.log("JupyterLab extension jupyterlab_active_log is activated!"),window.consts=Object.assign(Object.assign({},window.consts),{recordUrl:"https://modelscope.cn/api/v1/notebooks/activelog",timerDuration:1e4,timerParams:function(){const t=location.pathname.split("/");let e;return t.length>=2&&(e=t[1]),{site:"dsw",id:e,ext:{pathname:location.pathname}}}});const e=document.body,a=e.insertBefore(document.createElement("script"),e.firstChild);a.setAttribute("id","timer-sdk"),a.setAttribute("src","https://g.alicdn.com/alifanyi/translate-js-sdk/timer.js ")}}}}]); |
@@ -0,0 +1 @@ | |||
"use strict";(self.webpackChunkjupyterlab_active_log=self.webpackChunkjupyterlab_active_log||[]).push([[747],{150:(e,n,t)=>{t.d(n,{Z:()=>a});var r=t(645),o=t.n(r)()((function(e){return e[1]}));o.push([e.id,"/*\n See the JupyterLab Developer Guide for useful CSS Patterns:\n\n https://jupyterlab.readthedocs.io/en/stable/developer/css.html\n*/\n",""]);const a=o},645:e=>{e.exports=function(e){var n=[];return n.toString=function(){return this.map((function(n){var t=e(n);return n[2]?"@media ".concat(n[2]," {").concat(t,"}"):t})).join("")},n.i=function(e,t,r){"string"==typeof e&&(e=[[null,e,""]]);var o={};if(r)for(var a=0;a<this.length;a++){var i=this[a][0];null!=i&&(o[i]=!0)}for(var c=0;c<e.length;c++){var s=[].concat(e[c]);r&&o[s[0]]||(t&&(s[2]?s[2]="".concat(t," and ").concat(s[2]):s[2]=t),n.push(s))}},n}},379:(e,n,t)=>{var r,o=function(){var e={};return function(n){if(void 0===e[n]){var t=document.querySelector(n);if(window.HTMLIFrameElement&&t instanceof window.HTMLIFrameElement)try{t=t.contentDocument.head}catch(e){t=null}e[n]=t}return e[n]}}(),a=[];function i(e){for(var n=-1,t=0;t<a.length;t++)if(a[t].identifier===e){n=t;break}return n}function c(e,n){for(var t={},r=[],o=0;o<e.length;o++){var c=e[o],s=n.base?c[0]+n.base:c[0],u=t[s]||0,l="".concat(s," ").concat(u);t[s]=u+1;var f=i(l),d={css:c[1],media:c[2],sourceMap:c[3]};-1!==f?(a[f].references++,a[f].updater(d)):a.push({identifier:l,updater:v(d,n),references:1}),r.push(l)}return r}function s(e){var n=document.createElement("style"),r=e.attributes||{};if(void 0===r.nonce){var a=t.nc;a&&(r.nonce=a)}if(Object.keys(r).forEach((function(e){n.setAttribute(e,r[e])})),"function"==typeof e.insert)e.insert(n);else{var i=o(e.insert||"head");if(!i)throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");i.appendChild(n)}return n}var u,l=(u=[],function(e,n){return u[e]=n,u.filter(Boolean).join("\n")});function f(e,n,t,r){var o=t?"":r.media?"@media ".concat(r.media," {").concat(r.css,"}"):r.css;if(e.styleSheet)e.styleSheet.cssText=l(n,o);else{var a=document.createTextNode(o),i=e.childNodes;i[n]&&e.removeChild(i[n]),i.length?e.insertBefore(a,i[n]):e.appendChild(a)}}function d(e,n,t){var r=t.css,o=t.media,a=t.sourceMap;if(o?e.setAttribute("media",o):e.removeAttribute("media"),a&&"undefined"!=typeof btoa&&(r+="\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(a))))," */")),e.styleSheet)e.styleSheet.cssText=r;else{for(;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(document.createTextNode(r))}}var p=null,h=0;function v(e,n){var t,r,o;if(n.singleton){var a=h++;t=p||(p=s(n)),r=f.bind(null,t,a,!1),o=f.bind(null,t,a,!0)}else t=s(n),r=d.bind(null,t,n),o=function(){!function(e){if(null===e.parentNode)return!1;e.parentNode.removeChild(e)}(t)};return r(e),function(n){if(n){if(n.css===e.css&&n.media===e.media&&n.sourceMap===e.sourceMap)return;r(e=n)}else o()}}e.exports=function(e,n){(n=n||{}).singleton||"boolean"==typeof n.singleton||(n.singleton=(void 0===r&&(r=Boolean(window&&document&&document.all&&!window.atob)),r));var t=c(e=e||[],n);return function(e){if(e=e||[],"[object Array]"===Object.prototype.toString.call(e)){for(var r=0;r<t.length;r++){var o=i(t[r]);a[o].references--}for(var s=c(e,n),u=0;u<t.length;u++){var l=i(t[u]);0===a[l].references&&(a[l].updater(),a.splice(l,1))}t=s}}}},747:(e,n,t)=>{t.r(n);var r=t(379),o=t.n(r),a=t(150);o()(a.Z,{insert:"head",singleton:!1}),a.Z.locals}}]); |
@@ -0,0 +1 @@ | |||
var _JUPYTERLAB;(()=>{"use strict";var e,r,t={293:(e,r,t)=>{var o={"./index":()=>t.e(568).then((()=>()=>t(568))),"./extension":()=>t.e(568).then((()=>()=>t(568))),"./style":()=>t.e(747).then((()=>()=>t(747)))},a=(e,r)=>(t.R=r,r=t.o(o,e)?o[e]():Promise.resolve().then((()=>{throw new Error('Module "'+e+'" does not exist in container.')})),t.R=void 0,r),n=(e,r)=>{if(t.S){var o="default",a=t.S[o];if(a&&a!==e)throw new Error("Container initialization failed as it has already been initialized with a different share scope");return t.S[o]=e,t.I(o,r)}};t.d(r,{get:()=>a,init:()=>n})}},o={};function a(e){var r=o[e];if(void 0!==r)return r.exports;var n=o[e]={id:e,exports:{}};return t[e](n,n.exports,a),n.exports}a.m=t,a.c=o,a.n=e=>{var r=e&&e.__esModule?()=>e.default:()=>e;return a.d(r,{a:r}),r},a.d=(e,r)=>{for(var t in r)a.o(r,t)&&!a.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:r[t]})},a.f={},a.e=e=>Promise.all(Object.keys(a.f).reduce(((r,t)=>(a.f[t](e,r),r)),[])),a.u=e=>e+"."+{568:"a92ae44b87625ab09aed",747:"63b4c3d22bfe458b352b"}[e]+".js?v="+{568:"a92ae44b87625ab09aed",747:"63b4c3d22bfe458b352b"}[e],a.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),a.o=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),e={},r="jupyterlab_active_log:",a.l=(t,o,n,i)=>{if(e[t])e[t].push(o);else{var l,u;if(void 0!==n)for(var c=document.getElementsByTagName("script"),d=0;d<c.length;d++){var s=c[d];if(s.getAttribute("src")==t||s.getAttribute("data-webpack")==r+n){l=s;break}}l||(u=!0,(l=document.createElement("script")).charset="utf-8",l.timeout=120,a.nc&&l.setAttribute("nonce",a.nc),l.setAttribute("data-webpack",r+n),l.src=t),e[t]=[o];var p=(r,o)=>{l.onerror=l.onload=null,clearTimeout(f);var a=e[t];if(delete e[t],l.parentNode&&l.parentNode.removeChild(l),a&&a.forEach((e=>e(o))),r)return r(o)},f=setTimeout(p.bind(null,void 0,{type:"timeout",target:l}),12e4);l.onerror=p.bind(null,l.onerror),l.onload=p.bind(null,l.onload),u&&document.head.appendChild(l)}},a.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},(()=>{a.S={};var e={},r={};a.I=(t,o)=>{o||(o=[]);var n=r[t];if(n||(n=r[t]={}),!(o.indexOf(n)>=0)){if(o.push(n),e[t])return e[t];a.o(a.S,t)||(a.S[t]={});var i=a.S[t],l="jupyterlab_active_log",u=[];return"default"===t&&((e,r,t,o)=>{var n=i[e]=i[e]||{},u=n[r];(!u||!u.loaded&&(1!=!u.eager?o:l>u.from))&&(n[r]={get:()=>a.e(568).then((()=>()=>a(568))),from:l,eager:!1})})("jupyterlab_active_log","0.1.0"),e[t]=u.length?Promise.all(u).then((()=>e[t]=1)):1}}})(),(()=>{var e;a.g.importScripts&&(e=a.g.location+"");var r=a.g.document;if(!e&&r&&(r.currentScript&&(e=r.currentScript.src),!e)){var t=r.getElementsByTagName("script");t.length&&(e=t[t.length-1].src)}if(!e)throw new Error("Automatic publicPath is not supported in this browser");e=e.replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),a.p=e})(),(()=>{var e={346:0};a.f.j=(r,t)=>{var o=a.o(e,r)?e[r]:void 0;if(0!==o)if(o)t.push(o[2]);else{var n=new Promise(((t,a)=>o=e[r]=[t,a]));t.push(o[2]=n);var i=a.p+a.u(r),l=new Error;a.l(i,(t=>{if(a.o(e,r)&&(0!==(o=e[r])&&(e[r]=void 0),o)){var n=t&&("load"===t.type?"missing":t.type),i=t&&t.target&&t.target.src;l.message="Loading chunk "+r+" failed.\n("+n+": "+i+")",l.name="ChunkLoadError",l.type=n,l.request=i,o[1](l)}}),"chunk-"+r,r)}};var r=(r,t)=>{var o,n,[i,l,u]=t,c=0;if(i.some((r=>0!==e[r]))){for(o in l)a.o(l,o)&&(a.m[o]=l[o]);u&&u(a)}for(r&&r(t);c<i.length;c++)n=i[c],a.o(e,n)&&e[n]&&e[n][0](),e[n]=0},t=self.webpackChunkjupyterlab_active_log=self.webpackChunkjupyterlab_active_log||[];t.forEach(r.bind(null,0)),t.push=r.bind(null,t.push.bind(t))})(),a.nc=void 0;var n=a(293);(_JUPYTERLAB=void 0===_JUPYTERLAB?{}:_JUPYTERLAB).jupyterlab_active_log=n})(); |
@@ -0,0 +1,4 @@ | |||
/* This is a generated file of CSS imports */ | |||
/* It was generated by @jupyterlab/builder in Build.ensureAssets() */ | |||
import 'jupyterlab_active_log/style/index.js'; |
@@ -0,0 +1,16 @@ | |||
{ | |||
"packages": [ | |||
{ | |||
"name": "css-loader", | |||
"versionInfo": "5.2.7", | |||
"licenseId": "MIT", | |||
"extractedText": "Copyright JS Foundation and other contributors\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n'Software'), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\nCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\nTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\nSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n" | |||
}, | |||
{ | |||
"name": "style-loader", | |||
"versionInfo": "2.0.0", | |||
"licenseId": "MIT", | |||
"extractedText": "Copyright JS Foundation and other contributors\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n'Software'), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\nCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\nTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\nSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n" | |||
} | |||
] | |||
} |