Accessing job arguments from a Glue script

0

I've defined a Glue job that accepts parameters but couldn't find an example of how to access these parameters?

질문됨 7년 전5365회 조회
1개 답변
0
수락된 답변

You can use read parameters like regular Python sys.argv arguments.

import sys
print "This is the name of the script: ", sys.argv[0]
print "Number of arguments: ", len(sys.argv)
print "The arguments are: " , str(sys.argv)

Alternatively, you can use Glue's getResolvedOptions to read the arguments by name. In this case, you will need to prepend the argument name with '--' e.g. --Arg1 Value1

from awsglue.utils import getResolvedOptions
args = getResolvedOptions(sys.argv, ['TempDir','JOB_NAME', 'Arg1'])
print "The args are: " , str(args)
print "The value is: " , args['Arg1']
AWS
답변함 7년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠