LoginSignup
19
7

More than 5 years have passed since last update.

Google Cloud DataflowにプリインストールされているPythonパッケージを調べてみた

Last updated at Posted at 2017-03-04

あまり注目を集めないGoogle Cloud Dataflowですが、簡単に実行環境をローカル/リモート切り替えできるのでかなり便利です。しかもスタンダードライブラリしか使えないと思っていたらpipのリストからインストールしたり、独自インストールもできるとのこと。
じゃあどのライブラリがプリインストールされているのか、Documentをざっと検索しても出てこないので調べてみました。

準備

まずはオプションの設定、この辺は@orfeonさんの丸パクリです・・

Optionの設定
import apache_beam as beam
import apache_beam.transforms.window as window

options = beam.utils.pipeline_options.PipelineOptions()

google_cloud_options = options.view_as(beam.utils.pipeline_options.GoogleCloudOptions)
google_cloud_options.project = '{PROJECTID}'
google_cloud_options.job_name = 'test'
google_cloud_options.staging_location = 'gs://{BUCKET_NAME}/binaries'
google_cloud_options.temp_location = 'gs://{BUCKET_NAME}/temp'

worker_options = options.view_as(beam.utils.pipeline_options.WorkerOptions)
worker_options.max_num_workers = 1

# options.view_as(beam.utils.pipeline_options.StandardOptions).runner = 'DirectRunner'
options.view_as(beam.utils.pipeline_options.StandardOptions).runner = 'DataflowRunner'

p = beam.Pipeline(options=options)

pip freezeを実行してPythonパッケージリストをログ出力します。

パッケージリスト出力部分
def inspect_df(dat):
    import subprocess
    import logging
    process = subprocess.Popen('pip freeze', shell=True,
                               stdout=subprocess.PIPE, 
                               stderr=subprocess.PIPE)
    for line in process.stdout:
        logging.info(line)

Dataflow上で実行します。hello worldは要らないかも・・

パイプライン実行
(p | 'init' >> beam.Create(['hello', 'world'])
   | 'inspect' >> beam.Map(inspect_df))

p.run()

これでパイプラインの実行が完了すると、パッケージリストがログに出力されるので、Cloud Consoleで確認してみます。

ログ確認

DataflowのDocumentだと、DataflowのJob詳細画面からログを確認するとなっていますが、2017年3月4日現在だとStackdriver->Loggingの方に移っています。

Logs_Viewer_-_Test_fx_lab.png
こんな感じにログ出力されます。

パッケージ一覧

上記ログに吐かれたパッケージの一覧です。2017年3月4日現在

Package Version
avro 1.8.1
beautifulsoup4 4.5.1
bs4 0.0.1
crcmod 1.7
Cython 0.25.2
dataflow-worker 0.5.5
dill 0.2.5
enum34 1.1.6
funcsigs 1.0.2
futures 3.0.5
google-api-python-client 1.6.2
google-apitools 0.5.7
google-cloud-dataflow 0.5.5
google-python-cloud-debugger 1.9
googledatastore 6.4.1
grpcio 1.1.0
guppy 0.1.10
httplib2 0.9.2
mock 2.0.0
nltk 3.2.1
nose 1.3.7
numpy 1.12.0
oauth2client 2.2.0
pandas 0.18.1
pbr 1.10.0
Pillow 3.4.1
proto-google-datastore-v1 1.3.1
protobuf 3.0.0
protorpc 0.11.1
pyasn1 0.2.2
pyasn1-modules 0.0.8
python-dateutil 2.6.0
python-gflags 3.0.6
python-snappy 0.5
pytz 2016.10
PyYAML 3.11
requests 2.10.0
rsa 3.4.2
scikit-learn 0.17.1
scipy 0.17.1
six 1.10.0
tensorflow 1.0.0
tensorflow-transform 0.1.4
uritemplate 3.0.0

tf.transformが来たからでしょうか?Cloud MLではTensorFlow verは0.12ですが (EDIT: 最新のVerはこちらで確認できます) Dataflowでは1.0.0ですね。scikit-learnはちょっと古いようです。

ややstagingは遅いものの、Jupyter Notebook上から簡単にローカル/リモート切り替えて、勝手にインスタンスの立ち上げから立ち下げまでフルマネージドで行ってくれるDataflowはデータ解析や機械学習などの用途でも強力なツールとなりそうです。

19
7
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
19
7