Apache Zeppelin 노트북에서 사용자 정의되고 격리된 Python 환경 사용

Apache Zeppelin 노트북은 SQL, Scala, Python 등을 사용하여 데이터 중심의 대화형 데이터 분석 및 협업 문서를 지원하는 웹 기반 노트북입니다.

Python 개발자의 경우 사용자 지정되고 격리된 Python 런타임 환경을 사용하는 것이 필수 요구 사항입니다. 귀하와 귀하의 동료는 서로 다른 버전의 Python 및 Python 패키지를 사용하고 서로의 환경에 영향을 주고 싶지 않을 수 있습니다. 이 글에서는 Hadoop Yarn 클러스터에서 커스터마이즈되고 격리된 Python 환경을 사용하는 방법을 소개하고자 합니다. PySpark에서 이를 달성하는 방법에 대해서는 다른 기사에 남겨 두겠습니다. (이 기사의 모든 기능은 이 jira ZEPPELIN-5330에서 이루어집니다). 이 노트를 다운로드하여 여기에 있는 모든 단계를 재현할 수 있습니다.
  • Python Conda Env in Yarn Mode

  • 1단계. 맞춤형 conda 환경 생성



    먼저 다음을 포함하여 python conda env를 정의하는 yaml 파일을 생성해 보겠습니다.
  • 환경 이름
  • 패키지를 설치하는 데 사용되는 채널
  • 파이썬 버전
  • 기타 타사 Python 패키지

  • name: python_env
    channels:
      - conda-forge
      - defaults
    dependencies:
      - python=3.7 
      - pycodestyle
      - numpy
      - pandas
      - scipy
      - grpcio
      - protobuf
      - pandasql
      - ipython
      - ipykernel
      - jupyter_client
      - panel
      - pyyaml
      - seaborn
      - plotnine
      - hvplot
      - intake
      - intake-parquet
      - intake-xarray
      - altair
      - vega_datasets
      - pyarrow
    


    그런 다음 다음 명령을 사용하여 conda env tar를 생성하고 hdfs에 업로드합니다.

    conda pack -n python_env
    hadoop fs -put python_env.tar.gz /tmp
    # The python conda tar should be publicly accessible, so need to change permission here.
    hadoop fs -chmod 644 /tmp/pyspark_env.tar.gz
    


    2단계. Python 인터프리터 구성




    %python.conf
    # set zeppelin.interpreter.launcher to be yarn, so that python interpreter run in yarn container, 
    # otherwise python interpreter run as local process in the zeppelin server host.
    zeppelin.interpreter.launcher yarn
    # zeppelin.yarn.dist.archives can be either local file or hdfs file
    zeppelin.yarn.dist.archives hdfs:///tmp/python_env.tar.gz#environment
    # conda environment name, aka the folder name in the working directory of yarn container
    zeppelin.interpreter.conda.env.name environment
    


    3단계. 이 사용자 지정 conda 환경에서 Python Interpreter 실행




    %python
    
    %matplotlib inline
    
    import matplotlib.pyplot as plt
    plt.plot([1,2,3,4])
    plt.ylabel('some numbers')
    plt.show()
    




    요약



    이 기능은 이 기사가 게시될 때 아직 릴리스되지 않았으므로 직접 Zeppelin 마스터 브랜치를 빌드하고 여기에서 이 노트를 가져와서 이 기능을 사용해 볼 수 있습니다. 질문이 있는 경우 zeppelin 사용자 메일 목록 또는 slack 채널( http://zeppelin.apache.org/community.html )에서 질문할 수 있습니다.

    참조


  • Apache Zeppelin
  • Flink on Zeppelin docs
  • Zeppelin notebooks website
  • Zeppelin notebooks git repo
  • 좋은 웹페이지 즐겨찾기