LoginSignup
0
0

More than 1 year has passed since last update.

GCP Dataflow Classic Templateで複数ファイルを取り扱う[備忘録]

Posted at

Apache BeamのワークフローをGCP Dataflow上で動かせるようになるにはTemplateの登録が必要です。TemplateにはFlex TemplateかClassic Templateが選べますが、今回はClassic Templateについて、特に複数ファイルを使ったテンプレートについての話です。

Dataflowのチュートリアルでは特に複数ファイルについての言及はなく、代わりにApache Beam側のドキュメントに説明があります。

ここで例示されたファイル構成は以下の感じです。

 ​root_dir/
  ​setup.py
  ​main.py
  ​other_files_dir/

setup.py内に設定を書いてパッケージ化が必要とのことで、main.pyif __name__ == '__main__'ではじまるメイン関数を書き、other_files_dir/にその他依存する複数ファイルを入れる感じのようです。つまり

 ​root_dir/
  ​setup.py
  ​main.py
  ​other_files_dir/
    __init__.py
    aaa.py
    bbb.py
    ...

という感じでファイルを置いていけばいいのかなと理解しました。しかしこれでテンプレートを作成して実行したところModuleNotFoundErrorother_files_dir以下で発生。
試行錯誤した結果、main.pyをother_files_dirに移すことでとりあえず上手くいきました。

 ​root_dir/
  ​setup.py
  ​other_files_dir/
    __init__.py
    main.py
    aaa.py
    bbb.py
    ...

自分が勘違いしてるだけで、元の構成でも行ける気がしますがとりあえず上手く行ったので備忘録。

0
0
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
0
0