I need to do some setup in my Glue-ETL Job when the script is running inside of a Glue Job as opposed to my Jupyter Notebook.
Let's pretend my setup looks like this:
from awsglue.utils import getResolvedOptions
from pyspark.context import SparkContext
from awsglue.context import GlueContext
SC = SparkContext.getOrCreate()
GC = GlueContext(SC)
# I only want to run this when inside a Glue Job
args = getResolvedOptions(sys.argv, ['JOB_NAME'])
job = Job(GC)
job.init(args['JOB_NAME'], args)
I'm using a Glue (Jupyter) Notebook to develop my ETL script and export that to a Python script whenever I want to deploy it. So far I commented out the lines above for development and commented them back in for the deployment.
That's error-prone and not elegant.
Is there an easy way to discover whether I'm running inside of a Glue Job?