Glueの使い方的な㊺(Python shellでPythonから他の.pyを読み込む)
概要
GlueのPython Shellのコードの中から、別のPythonコードを読み込み実行する
手順
Glueのジョブ作成
Glueの画面で"ジョブ"->[ジョブの追加]をクリックし、以下を入力します。
- 名前:se2_job28
- ロール:(適切な任意のもの)
- Type:Python shell
引き続き以下を入力します。以下の"参照されるファイルパス"に内部で読み込むファイル名をS3パスと合わせて記入します。
- 参照されるファイルパス:s3://test-glue00/se2/script/circle.py(任意のファイルパスとファイル名)
この画面で[次へ]をクリックし、次の画面で[ジョブを保存してスクリプトを編集する]をクリックします。
呼び出すコード
S3のs3://test-glue00/se2/script/に配置しておく。
circle.py
def calc_area(r):
return r ** 2 * 3.14
print('hello circle.py')
ジョブのコード
se2_job28
import circle
# 半径3の円の面積
circle = circle.calc_area(3)
print(circle)
print('hello se2_job28')
ジョブのコードを貼り付け、ジョブを実行します。
実行後のログ
呼び出すコードとGlueジョブコードのprintの出力結果が出ている
こちらも是非
Glueの使い方まとめ
https://qiita.com/pioho07/items/32f76a16cbf49f9f712f
Author And Source
この問題について(Glueの使い方的な㊺(Python shellでPythonから他の.pyを読み込む)), 我々は、より多くの情報をここで見つけました https://qiita.com/pioho07/items/91a5feb465ed2e2e200d著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .