Closed dejaentenduu closed 4 years ago
I'm not sure I understand the question. Are you trying to get the job name via an API from inside the job? I think you can get your execution_id
, from there look up the particular Execution
and get a job_id
, and then use apscheduler
APIs to look up a particular Job
. The datastore extends apscheduler.jobstores.sqlalchemy.SQLAlchemyJobStore
.
Sorry, I should have given more detail and probably didn't ask that correctly. For context, I'm trying to set up an email notification system that alerts you when a job either fails or successfully completes. Right now, I can get the job_id
and execution_id
, and they would be helpful for an alert, but having the job name as it is written in the UI would great as well.
What you described sounds like what I need, I appreciate the response.
I was able to get the job name, thanks for the help. Probably relatively simple for most people, but below is how I did it for anyone else struggling like I was:
Code already present in JobBase class:
scheduler = scheduler_manager.ScheduleManager.get_instance()
datastore = scheduler.get_datastore()
Code needed to get the name:
execution = datastore.get_execution(execution_id) # returns a dict with a nested job dict
job_name = execution['job']['name']
I am still not clear on how to fetch the jobs name within the job. could you tell me which scripts-functions to import?
Is there an easy way to get the job name? I can't seem to figure out how. Any help would be great.