-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjobs_scheduler.py
40 lines (28 loc) · 1.03 KB
/
jobs_scheduler.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
%%writefile ./scheduler_jobs.py
import schedule
import time
import ads
from ads.jobs import Job, DataScienceJobRun
#####################
#################### Define Jobs OCIDS
####################
#*********************************************************#
## set Job OCIDS
JOB_OCIDS = ["ocid1.datasciencejob.oc1.eu-frankfurt-1.amaaaaaangencdya2vnth3iaslq34nastb4ez6wlo6y2vnpo65iigefbcftq", "ocid1.datasciencejob.oc1.eu-frankfurt-1.amaaaaaangencdya2vnth3iaslq34nastb4ez6wlo6y2vnpo65iigefbcftq"]
## Set the frequency in minutes
frequency = 5
#*********************************************************#
##################
################## Function
##################
def job_api(JOB_OCIDS):
for job_ocid in JOB_OCIDS:
print("Job OCID = " +str(job_ocid))
#load Job
job = Job.from_datascience_job(job_ocid)
#Run Job
job.run()
# run the function job() every XX minute
schedule.every(frequency).minutes.do(job_api, JOB_OCIDS)
while True:
schedule.run_pending()