3

We need the job name from Azkaban when trying to schedule a job. Is there any built-in property for that? We are getting the flow name from ${azkaban.job.flowid}.

Eg: My job file is:

type=command
command=python xyz.py ${azkaban.job.attempt} ${azkaban.job.flowid}
Nisse Engström
  • 4,738
  • 23
  • 27
  • 42
Ashish Mohan
  • 664
  • 6
  • 13

2 Answers2

0

Azkaban job runtime properties are stored in file referred by env variable JOB_PROP_FILE. Read this file in your python program and get 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 job names from these properties azkaban.flow.nested.path and azkaban.job.metadata.file

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

Ravi
  • 912
  • 6
  • 12
0

Found the answer:

Azkaban jobs run with following Environment variables:

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

The Job Name can be fetched easily by the following Python snippet:

import os

job_name = os.environ["JOB_NAME"]
Nisse Engström
  • 4,738
  • 23
  • 27
  • 42
Ashish Mohan
  • 664
  • 6
  • 13