Переглянути джерело

Merge branch 'yili' of http://gogsb.soaringnova.com/ylproj/jupyterlab into yili

kilnonedre 1 рік тому
батько
коміт
1bdb72f338

+ 202 - 0
Dockerfile

@@ -0,0 +1,202 @@
+FROM node:16.15.1-bullseye-slim AS builder-fe
+COPY requirements.txt .
+RUN sed -i "s@http://\(deb\|security\).debian.org@http://mirrors.aliyun.com@g" /etc/apt/sources.list
+RUN apt update
+RUN apt update && apt install -y libpython3-dev  python3 python3-pip python-is-python3 make \
+    && pip config set global.index-url https://mirror.baidu.com/pypi/simple \
+    && pip install -U pip setuptools && pip install -r requirements.txt -i https://mirror.baidu.com/pypi/simple
+    #  \
+    # && yarn config set registry https://registry.npm.taobao.org \
+    # && npm config set registry https://registry.npm.taobao.org \
+    # && npm config set disturl https://npm.taobao.org/dist
+#https://registry.npmmirror.com
+COPY . /src/
+ENV PYTHONPATH=/src
+RUN cd /src && chmod a+x  ./bdist_wheel.sh && ./bdist_wheel.sh
+
+
+FROM  gettyimages/spark:2.4.0-hadoop-3.0  as builder
+RUN sed -i "s@http://\(deb\|security\).debian.org@http://mirrors.163.com@g" /etc/apt/sources.list
+RUN apt update && apt install -y --no-install-recommends \
+    krb5-user zip unzip procps tar curl supervisor net-tools telnet vim iputils-ping netcat jq wget zsh
+# 目录准备
+ENV WORKSPACE /hadoop
+WORKDIR ${WORKSPACE}
+
+
+# 环境变量
+ENV HADOOP_HOME=/usr/hadoop-3.0.0/
+ENV HADOOP_CONF_DIR=${WORKSPACE}/conf
+# ENV HIVE_HOME=${WORKSPACE}/hive
+# ENV HIVE_CONF_DIR=${WORKSPACE}/conf
+ENV PATH=$PATH:$HADOOP_HOME/bin:$SPARK_HOME/bin
+ENV LD_LIBRARY_PATH=$HADOOP_HOME/lib/native
+
+ENV LANG=zh_CN.UTF-8 LANGUAGE=zh_CN:zh LC_ALL=zh_CN.UTF-8 DEBIAN_FRONTEND=noninteractive
+
+RUN rm -rf  /etc/apt/sources.list.d/  && apt update
+
+RUN apt-get update && apt-get install -y --no-install-recommends \
+    supervisor \
+    iputils-ping \
+    wget \
+    zsh \
+    build-essential \
+    cmake \
+    git \
+    curl \
+    vim \
+    ca-certificates \
+    libjpeg-dev \
+    zip \
+    unzip \
+    libpng-dev \
+    openssh-server \
+    autojump \
+    ttf-wqy-zenhei \
+    libgl1-mesa-glx  \
+    libglib2.0-0 \
+    locales \
+    krb5-user net-tools telnet && \
+    rm -rf /var/lib/apt/lists/*
+
+
+RUN locale-gen zh_CN.UTF-8
+RUN dpkg-reconfigure locales
+
+
+CMD ["supervisord", "-n"]
+
+
+FROM builder as builder1
+
+ENV PYTHON_VERSION 3
+RUN chsh -s `which zsh`
+RUN curl -o ~/miniconda.sh -O  https://repo.anaconda.com/miniconda/Miniconda3-py37_4.12.0-Linux-x86_64.sh  && \
+    chmod +x ~/miniconda.sh && \
+    ~/miniconda.sh -b -p /opt/conda && \
+    rm ~/miniconda.sh
+
+RUN ln /opt/conda/bin/conda /usr/local/bin/conda
+RUN conda init zsh
+RUN conda install mamba -n base -c conda-forge
+RUN ln /opt/conda/bin/mamba /usr/local/bin/mamba && mamba init zsh
+
+
+
+FROM builder1 as builder2
+WORKDIR /workspace
+RUN /opt/conda/bin/pip install jupyterlab jupyterlab-language-pack-zh-CN kazoo==2.9.0 -i https://pypi.douban.com/simple
+RUN mamba install nodejs  sparkmagic  pyhive pandas  nbconvert>=7 mistune>=2 -y
+# pyhive thrift sasl thrift_sasl scikit-learn
+# password 'sx'
+RUN /opt/conda/bin/jupyter lab --generate-config && \
+    echo "c.NotebookApp.password='argon2:\$argon2id\$v=19\$m=10240,t=10,p=8\$+zIUCF9Uk2FiCHlV8njX5A\$I5Mm/64DORArcXYTXWRVng'">>/root/.jupyter/jupyter_lab_config.py
+ENV PATH /opt/conda/bin/:$PATH
+RUN jupyter nbextension enable --py --sys-prefix widgetsnbextension
+
+
+FROM builder2 as builder3
+
+RUN cd /opt/conda/lib/python3.7/site-packages/ \
+    && jupyter-kernelspec install sparkmagic/kernels/sparkkernel \
+    && jupyter-kernelspec install sparkmagic/kernels/pysparkkernel \
+    && /opt/conda/bin/jupyter serverextension enable --py sparkmagic
+
+EXPOSE 8888
+
+# 电信云测试
+FROM builder3 as image-idctest
+COPY --from=builder-fe /src/dist  dist
+RUN /opt/conda/bin/pip install dist/*.whl  -i https://mirror.baidu.com/pypi/simple
+ADD confs/idctest/config.json .
+RUN mkdir -p $HOME/.sparkmagic && cp config.json $HOME/.sparkmagic
+COPY confs/idctest/ydtk /ydtk
+COPY confs/idctest/conf ${WORKSPACE}/conf
+RUN echo "\
+[program:jupyter]\n\
+directory=/workspace\n\
+command=/bin/bash -c '/opt/conda/bin/jupyter lab --ip 0.0.0.0 --port 8888 --allow-root --no-browser --NotebookApp.allow_origin=* --NotebookApp.allow_remote_access=1' \n\
+autorestart=true\n\
+startretries=0\n\
+redirect_stderr=true\n\
+stdout_logfile=/var/log/jupyter.log\n\
+stdout_logfile_maxbytes=50MB\n\
+environment=PYTHONPATH=/\n\
+" > /etc/supervisor/conf.d/jupyter.conf
+
+
+FROM builder2 as jupyter0-idctest
+COPY --from=builder-fe /src/dist  dist
+RUN /opt/conda/bin/pip install dist/*.whl  -i https://mirror.baidu.com/pypi/simple
+COPY confs/idctest/ydtk /ydtk
+COPY confs/idctest/conf ${WORKSPACE}/conf
+RUN echo "\
+[program:jupyter]\n\
+directory=/workspace\n\
+command=/bin/bash -c '/opt/conda/bin/jupyter lab --ip 0.0.0.0 --port 8888 --allow-root --no-browser --NotebookApp.allow_origin=* --NotebookApp.allow_remote_access=1' \n\
+autorestart=true\n\
+startretries=0\n\
+redirect_stderr=true\n\
+stdout_logfile=/var/log/jupyter.log\n\
+stdout_logfile_maxbytes=50MB\n\
+environment=PYTHONPATH=/\n\
+" > /etc/supervisor/conf.d/jupyter.conf
+
+
+
+# 电信云生产
+FROM builder3 as image-idcprod
+COPY --from=builder-fe /src/dist  dist
+RUN /opt/conda/bin/pip install dist/*.whl  -i https://mirror.baidu.com/pypi/simple
+ADD confs/idcprod/config.json .
+RUN mkdir -p $HOME/.sparkmagic && cp config.json $HOME/.sparkmagic
+COPY confs/idcprod/ydtk /ydtk
+COPY confs/idcprod/conf ${WORKSPACE}/conf
+RUN echo "\
+[program:jupyter]\n\
+directory=/workspace\n\
+command=/bin/bash -c '/opt/conda/bin/jupyter lab --ip 0.0.0.0 --port 8888 --allow-root --no-browser --NotebookApp.allow_origin=* --NotebookApp.allow_remote_access=1' \n\
+autorestart=true\n\
+startretries=0\n\
+redirect_stderr=true\n\
+stdout_logfile=/var/log/jupyter.log\n\
+stdout_logfile_maxbytes=50MB\n\
+environment=PYTHONPATH=/\n\
+" > /etc/supervisor/conf.d/jupyter.conf
+
+
+
+FROM builder2 as jupyter0-idcprod
+COPY --from=builder-fe /src/dist  dist
+RUN /opt/conda/bin/pip install dist/*.whl  -i https://mirror.baidu.com/pypi/simple
+COPY confs/idcprod/ydtk /ydtk
+COPY confs/idcprod/conf ${WORKSPACE}/conf
+RUN echo "\
+[program:jupyter]\n\
+directory=/workspace\n\
+command=/bin/bash -c '/opt/conda/bin/jupyter lab --ip 0.0.0.0 --port 8888 --allow-root --no-browser --NotebookApp.allow_origin=* --NotebookApp.allow_remote_access=1' \n\
+autorestart=true\n\
+startretries=0\n\
+redirect_stderr=true\n\
+stdout_logfile=/var/log/jupyter.log\n\
+stdout_logfile_maxbytes=50MB\n\
+environment=PYTHONPATH=/\n\
+" > /etc/supervisor/conf.d/jupyter.conf
+
+# 普通版
+
+FROM builder2 as jupyter0
+
+COPY --from=builder-fe /src/dist  dist
+RUN /opt/conda/bin/pip install dist/*.whl  -i https://mirror.baidu.com/pypi/simple
+RUN echo "\
+[program:jupyter]\n\
+directory=/workspace\n\
+command=/bin/bash -c '/opt/conda/bin/jupyter lab --ip 0.0.0.0 --port 8888 --allow-root --no-browser --NotebookApp.allow_origin=* --NotebookApp.allow_remote_access=1' \n\
+autorestart=true\n\
+startretries=0\n\
+redirect_stderr=true\n\
+stdout_logfile=/var/log/jupyter.log\n\
+stdout_logfile_maxbytes=50MB\n\
+" > /etc/supervisor/conf.d/jupyter.conf

+ 28 - 5
Dockerfile.tx

@@ -10,14 +10,17 @@ RUN apt update && apt install -y libpython3-dev  python3 python3-pip python-is-p
     # && npm config set registry https://registry.npm.taobao.org \
     # && npm config set disturl https://npm.taobao.org/dist
 #https://registry.npmmirror.com
+
 COPY . /src/
 ENV PYTHONPATH=/src
 RUN cd /src && chmod a+x  ./bdist_wheel.sh && ./bdist_wheel.sh
 
-FROM ubuntu:18.04 AS builder
+# FROM ubuntu:18.04 AS builder
+FROM openjdk:8-jre-slim as builder
 
-RUN sed -i 's#archive.ubuntu.com#mirrors.aliyun.com#g' /etc/apt/sources.list  \
-    && sed -i 's#security.ubuntu.com#mirrors.aliyun.com#g' /etc/apt/sources.list
+RUN sed -i "s@http://\(deb\|security\).debian.org@https://mirrors.aliyun.com@g" /etc/apt/sources.list
+#RUN sed -i 's#archive.ubuntu.com#mirrors.aliyun.com#g' /etc/apt/sources.list  \
+#    && sed -i 's#security.ubuntu.com#mirrors.aliyun.com#g' /etc/apt/sources.list
 
 ENV LANG=zh_CN.UTF-8 LANGUAGE=zh_CN:zh LC_ALL=zh_CN.UTF-8 DEBIAN_FRONTEND=noninteractive
 
@@ -40,7 +43,6 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
     libpng-dev \
     openssh-server \
     autojump \
-    language-pack-zh-hans \
     ttf-wqy-zenhei \
     libgl1-mesa-glx  \
     libglib2.0-0 \
@@ -48,6 +50,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
     krb5-user net-tools telnet && \
     rm -rf /var/lib/apt/lists/*
 
+#language-pack-zh-hans \
 
 RUN locale-gen zh_CN.UTF-8
 RUN dpkg-reconfigure locales
@@ -55,8 +58,24 @@ RUN dpkg-reconfigure locales
 
 CMD ["supervisord", "-n"]
 
+FROM builder as builder_hadoop
+
+# 目录准备
+RUN mkdir -p /opt/cluster
+WORKDIR /opt/cluster
+RUN mkdir -p hadoop
+
+# hadoop
+COPY hadoop-3.2.3.tar.gz hadoop/hadoop.tgz
+RUN cd hadoop && tar zxfv hadoop.tgz && mv hadoop*/* . && rm -rf hadoop.tgz
+
+# 环境变量
+ENV HADOOP_HOME=/opt/cluster/hadoop
+ENV HADOOP_CONF_DIR=/opt/cluster/conf
+ENV PATH=${HADOOP_HOME}/bin:$PATH
+
 
-FROM builder as builder1
+FROM builder_hadoop as builder1
 
 ENV PYTHON_VERSION 3
 RUN chsh -s `which zsh`
@@ -119,6 +138,7 @@ ADD confs/txtest/config.json .
 RUN mkdir -p $HOME/.sparkmagic && cp config.json $HOME/.sparkmagic
 ADD confs/txtest/user.keytab /
 COPY confs/txtest/ydtk /ydtk
+COPY confs/txtest /opt/cluster/conf
 RUN echo "\
 [program:jupyter]\n\
 directory=/workspace\n\
@@ -137,6 +157,7 @@ RUN /opt/conda/bin/pip install dist/*.whl  -i https://mirror.baidu.com/pypi/simp
 ADD confs/txtest/krb5.conf /etc/
 ADD confs/txtest/user.keytab /
 COPY confs/txtest/ydtk /ydtk
+COPY confs/txtest /opt/cluster/conf
 RUN echo "\
 [program:jupyter]\n\
 directory=/workspace\n\
@@ -159,6 +180,7 @@ ADD confs/txprod/config.json .
 RUN mkdir -p $HOME/.sparkmagic && cp config.json $HOME/.sparkmagic
 ADD confs/txprod/user.keytab /
 COPY confs/txprod/ydtk /ydtk
+COPY confs/txprod /opt/cluster/conf
 RUN echo "\
 [program:jupyter]\n\
 directory=/workspace\n\
@@ -177,6 +199,7 @@ RUN /opt/conda/bin/pip install dist/*.whl  -i https://mirror.baidu.com/pypi/simp
 ADD confs/txprod/krb5.conf /etc/
 ADD confs/txprod/user.keytab /
 COPY confs/txprod/ydtk /ydtk
+COPY confs/txprod /opt/cluster/conf
 RUN echo "\
 [program:jupyter]\n\
 directory=/workspace\n\

+ 1 - 1
confs/idcprod/config.json

@@ -52,7 +52,7 @@
     "ignore_ssl_errors": false,
     "session_configs": {
         "driverMemory": "1000M",
-        "executorCores": 2
+        "executorCores": 1
     },
     "use_auto_viz": true,
     "coerce_dataframe": true,

+ 1 - 1
confs/idctest/config.json

@@ -52,7 +52,7 @@
     "ignore_ssl_errors": false,
     "session_configs": {
         "driverMemory": "1000M",
-        "executorCores": 2
+        "executorCores": 1
     },
     "use_auto_viz": true,
     "coerce_dataframe": true,

+ 1 - 1
confs/txprod/config.json

@@ -52,7 +52,7 @@
   "ignore_ssl_errors": false,
   "session_configs": {
     "driverMemory": "1000M",
-    "executorCores": 2
+    "executorCores": 1
   },
   "use_auto_viz": true,
   "coerce_dataframe": true,

+ 13 - 15
confs/txtest/config.json

@@ -1,12 +1,11 @@
 {
-  "kernel_python_credentials" : {
+  "kernel_python_credentials": {
     "username": "",
     "password": "",
     "url": "http://10.254.7.8:30998",
     "auth": "None"
   },
-
-  "kernel_scala_credentials" : {
+  "kernel_scala_credentials": {
     "username": "",
     "password": "",
     "url": "http://10.254.7.8:30998",
@@ -17,7 +16,6 @@
     "password": "",
     "url": "http://10.254.7.8:30998"
   },
-
   "logging_config": {
     "version": 1,
     "formatters": {
@@ -35,7 +33,9 @@
     },
     "loggers": {
       "magicsLogger": {
-        "handlers": ["magicsHandler"],
+        "handlers": [
+          "magicsHandler"
+        ],
         "level": "DEBUG",
         "propagate": 0
       }
@@ -46,32 +46,30 @@
     "None": "sparkmagic.auth.customauth.Authenticator",
     "Basic_Access": "sparkmagic.auth.basic.Basic"
   },
-
   "wait_for_idle_timeout_seconds": 15,
   "livy_session_startup_timeout_seconds": 60,
-
   "fatal_error_suggestion": "The code failed because of a fatal error:\n\t{}.\n\nSome things to try:\na) Make sure Spark has enough available resources for Jupyter to create a Spark context.\nb) Contact your Jupyter administrator to make sure the Spark magics library is configured correctly.\nc) Restart the kernel.",
-
   "ignore_ssl_errors": false,
-
   "session_configs": {
     "driverMemory": "1000M",
-    "executorCores": 2
+    "executorCores": 1
   },
-
   "use_auto_viz": true,
   "coerce_dataframe": true,
   "max_results_sql": 2500,
   "pyspark_dataframe_encoding": "utf-8",
-
   "heartbeat_refresh_seconds": 30,
   "livy_server_heartbeat_timeout_seconds": 0,
   "heartbeat_retry_seconds": 10,
-
   "server_extension_default_kernel_name": "pysparkkernel",
   "custom_headers": {},
-
   "retry_policy": "configurable",
-  "retry_seconds_to_sleep_list": [0.2, 0.5, 1, 3, 5],
+  "retry_seconds_to_sleep_list": [
+    0.2,
+    0.5,
+    1,
+    3,
+    5
+  ],
   "configurable_retry_policy_max_retries": 8
 }

+ 60 - 0
deploy/Jenkinsfile

@@ -0,0 +1,60 @@
+pipeline {
+  agent {
+    kubernetes {
+      yamlFile 'deploy/KubernetesPod.yaml'
+      retries 2
+    }
+  }
+  environment {
+    IMAGE_REPO = "registry.cn-hangzhou.aliyuncs.com/sxtest"
+    url1 = "http://aihub-dag-idctest.digitalyili.com"
+    url2 = "http://aihub-dag-idc.digitalyili.com"
+    TAB = "\n   \n  "
+    BUILD_TASKS = "\n   \n  "
+
+  }
+  stages{
+    stage('构建镜像') {
+      steps {
+        container('docker') {
+          echo "构建 Docker 镜像阶段"
+          sh 'echo "nameserver 114.114.114.114" >> /etc/resolv.conf'
+          sh "sed '/^http/c'$url1'' -i  packages/yili-dag/src/request.ts"
+          sh "sed '/^http/c'$url1'' -i  packages/jldbq-extenison/src/api/config.ts"
+          sh "sed '/^http/c'$url1'' -i  packages/filebrowser/src/api/config.ts"
+          sh 'docker build -f ${DOCKERFILE} --target ${ENV_TARGET0} -t ${IMAGE_REPO}/jupyterlab0:${ENV_APP} --output type=docker .'
+          sh 'docker build -f ${DOCKERFILE} --target ${ENV_TARGET} -t ${IMAGE_REPO}/jupyterlab:${ENV_APP}  --output type=docker .'
+          echo "build success"
+        }
+        script {
+          env.BUILD_TASKS += env.STAGE_NAME + "✅" + env.TAB
+        }
+      }
+    }
+    stage('镜像推送') {
+      steps {
+        container('docker') {
+          echo "Push Docker 镜像阶段"
+          sh'docker images'
+          sh 'docker push ${IMAGE_REPO}/jupyterlab:${ENV_APP}'
+          sh 'docker push ${IMAGE_REPO}/jupyterlab0:${ENV_APP} '
+          echo "Push image success"
+        }
+        script {
+          env.BUILD_TASKS += env.STAGE_NAME + "✅" + env.TAB
+        }
+      }
+    }
+    stage('重启服务') {
+      steps {
+        container('kubectl') {
+          sh 'kubectl version'
+        }
+        script {
+          env.BUILD_TASKS += env.STAGE_NAME + "✅" + env.TAB
+        }
+        sh 'printenv'
+      }
+    }
+  }
+    }

+ 52 - 0
deploy/Jenkinsfile.bk

@@ -0,0 +1,52 @@
+pipeline {
+  agent {
+    kubernetes {
+      yamlFile 'deploy/KubernetesPod.yaml'
+      retries 2
+    }
+  }
+  environment {
+    IMAGE_REPO = "registry.cn-hangzhou.aliyuncs.com/sxtest"
+    TAB = "\n   \n  "
+    BUILD_TASKS = "\n   \n  "
+  }
+  stages{
+    stage('构建镜像') {
+      steps {
+        container('docker') {
+          echo "构建 Docker 镜像阶段"
+          sh 'docker build  -t ${IMAGE_REPO}/jupyter:latest .'
+          echo "build success"
+        }
+        script {
+          env.BUILD_TASKS += env.STAGE_NAME + "✅" + env.TAB
+        }
+      }
+    }
+    stage('镜像推送') {
+      steps {
+        container('docker') {
+          echo "nameserver 114.114.114.114 >> /etc/resolv.conf"
+          echo "nameserver 223.5.5.5 >> /etc/resolv.conf"
+          echo "Push Docker 镜像阶段"
+          sh 'docker push ${IMAGE_REPO}/jupyter:latest '
+          echo "Push image success"
+        }
+        script {
+          env.BUILD_TASKS += env.STAGE_NAME + "✅" + env.TAB
+        }
+      }
+    }
+    stage('重启服务') {
+      steps {
+        container('kubectl') {
+          sh 'kubectl version'
+        }
+        script {
+          env.BUILD_TASKS += env.STAGE_NAME + "✅" + env.TAB
+        }
+        sh 'printenv'
+      }
+    }
+  }
+    }

+ 43 - 0
deploy/KubernetesPod.yaml

@@ -0,0 +1,43 @@
+apiVersion: v1
+kind: Pod
+metadata:
+  labels:
+    jupyter: jupyter
+spec:
+  containers:
+  - name: docker
+    image: docker:latest
+    imagePullPolicy: IfNotPresent
+    command:
+    - cat
+    tty: true
+    volumeMounts:
+    - mountPath: "/etc/docker/daemon.json"
+      name: "volume-docker1"
+    - mountPath: "/root/.docker/config.json"
+      name: "docker-auth"
+    - mountPath: "/var/run/docker.sock"
+      name: "volume-docker0"
+  - name: kubectl
+    image: cnych/kubectl
+    imagePullPolicy: IfNotPresent
+    command:
+    - cat
+    tty: true
+  volumes:
+   - name: volume-docker0
+     hostPath:
+       path: "/var/run/docker.sock"
+   - name: docker-auth
+     hostPath:
+       path: "/root/.docker/config.json"
+   - name: volume-docker1
+     hostPath:
+       path: "/etc/docker/daemon.json"
+  nodeSelector:
+    kubernetes.io/hostname: 10.138.130.97
+  tolerations:
+    - key: "node-role.kubernetes.io/master"
+      operator: "Equal"
+      value: "true"
+      effect: "NoSchedule"

BIN
hadoop-3.2.3.tar.gz


+ 47 - 42
packages/filebrowser-extension/src/index.ts

@@ -46,7 +46,7 @@ import {
   closeIcon,
   copyIcon,
   cutIcon,
-  // downloadIcon,
+  downloadIcon,
   editIcon,
   fileIcon,
   folderIcon,
@@ -330,50 +330,50 @@ const factory: JupyterFrontEndPlugin<IFileBrowserFactory> = {
  * Users will still be able to retrieve files from the file download URLs the
  * server provides.
  */
-// const downloadPlugin: JupyterFrontEndPlugin<void> = {
-//   id: '@jupyterlab/filebrowser-extension:download',
-//   requires: [IFileBrowserFactory, ITranslator],
-//   autoStart: true,
-//   activate: (
-//     app: JupyterFrontEnd,
-//     factory: IFileBrowserFactory,
-//     translator: ITranslator
-//   ): void => {
-//     const trans = translator.load('jupyterlab');
-//     const { commands } = app;
-//     const { tracker } = factory;
+const downloadPlugin: JupyterFrontEndPlugin<void> = {
+  id: '@jupyterlab/filebrowser-extension:download',
+  requires: [IFileBrowserFactory, ITranslator],
+  autoStart: true,
+  activate: (
+    app: JupyterFrontEnd,
+    factory: IFileBrowserFactory,
+    translator: ITranslator
+  ): void => {
+    const trans = translator.load('jupyterlab');
+    const { commands } = app;
+    const { tracker } = factory;
 
-//     commands.addCommand(CommandIDs.download, {
-//       execute: () => {
-//         const widget = tracker.currentWidget;
+    commands.addCommand(CommandIDs.download, {
+      execute: () => {
+        const widget = tracker.currentWidget;
 
-//         if (widget) {
-//           return widget.download();
-//         }
-//       },
-//       icon: downloadIcon.bindprops({ stylesheet: 'menuItem' }),
-//       label: trans.__('Download')
-//     });
+        if (widget) {
+          return widget.download();
+        }
+      },
+      icon: downloadIcon.bindprops({ stylesheet: 'menuItem' }),
+      label: trans.__('Download')
+    });
 
-//     commands.addCommand(CommandIDs.copyDownloadLink, {
-//       execute: () => {
-//         const widget = tracker.currentWidget;
-//         if (!widget) {
-//           return;
-//         }
+    commands.addCommand(CommandIDs.copyDownloadLink, {
+      execute: () => {
+        const widget = tracker.currentWidget;
+        if (!widget) {
+          return;
+        }
 
-//         return widget.model.manager.services.contents
-//           .getDownloadUrl(widget.selectedItems().next()!.path)
-//           .then(url => {
-//             Clipboard.copyToSystem(url);
-//           });
-//       },
-//       icon: copyIcon.bindprops({ stylesheet: 'menuItem' }),
-//       label: trans.__('Copy Download Link'),
-//       mnemonic: 0
-//     });
-//   }
-// };
+        return widget.model.manager.services.contents
+          .getDownloadUrl(widget.selectedItems().next()!.path)
+          .then(url => {
+            Clipboard.copyToSystem(url);
+          });
+      },
+      icon: copyIcon.bindprops({ stylesheet: 'menuItem' }),
+      label: trans.__('Copy Download Link'),
+      mnemonic: 0
+    });
+  }
+};
 
 /**
  * A plugin to add the file browser widget to an ILabShell
@@ -1353,12 +1353,17 @@ const plugins: JupyterFrontEndPlugin<any>[] = [
   browser,
   // shareFile,
   fileUploadStatus,
-  // downloadPlugin,
+  //  downloadPlugin,
   browserWidget,
   openWithPlugin
   // openBrowserTabPlugin,
   // openUrlPlugin
 ];
+const flag = localStorage.getItem('AI.jupyter_download');
+
+if (flag == 'true') {
+  plugins.push(downloadPlugin);
+}
 export default plugins;
 
 namespace Private {