How to get job name from job file in azkaban 3.0

We need the job name from Azkaban when trying to schedule a job. Is there a built-in property for this? We get the stream name from ${azkaban.job.flowid}

.

For example: My job file:

type=command
command=python xyz.py ${azkaban.job.attempt} ${azkaban.job.flowid}

      

+3


source to share


2 answers


Found the answer:

Azkaban works work with the following Environment Variables:

{ JOB_OUTPUT_PROP_FILE='xxx',
  JOB_PROP_FILE='xxx',
  JOB_NAME='xxx' }

      



The job title can be easily extracted from the following Python snippet:

import os

job_name = os.environ["JOB_NAME"]

      

0


source


The properties of the Azkaban runtime are stored in the file specified by the JOB_PROP_FILE env variable . Read this file in your python program and get the required properties.

import os
azkaban_job_prop_file = os.environ["JOB_PROP_FILE"]
with open(azkaban_job_prop_file,'r') as f:
        print f.readline()

      



we can infer the job names from these properties azkaban.flow.nested.path and azkaban.job.metadata.file

azkaban.flow.nested.path -> Use this if the job is part of an embedded DAG.

0


source







All Articles