hana_ml.hana_scheduler
This module contains the usage of HANA Scheduler.
The following classes and functions are available:
- class hana_ml.hana_scheduler.HANAScheduler(connection_context)
Bases:
object
HANA Scheduler.
Examples
>>> #auto_c.disable_hana_execution() >>> auto_c.fit(df_fit, key='ID') >>> hana_schedule = HANAScheduler(connection_context) >>> hana_schedule.create_training_schedule(job_name='my_job', obj=auto_c, cron="* * * mon,tue,wed,thu,fri 1 23 45", output_table_names=['BEST_PIPELINE_1122', 'MODEL_1122', 'INFO_1122'], force=True) >>> hana_schedule.list_schedules() USER_NAME SCHEMA_NAME SCHEDULER_JOB_NAME PROCEDURE_SCHEMA_NAME PROCEDURE_NAME CRON START_TIME END_TIME IS_ENABLED IS_VALID COMMENTS CREATE_TIME 0 PAL_TEST PAL_TEST my_job PAL_TEST PROC_my_job * * * mon,tue,wed,thu,fri 1 23 45 None None TRUE TRUE None 2023-02-14 08:57:11.689 >>> hana_schedule.delete_schedule("my_job") >>> auto_c.predict(df_predict, key='ID') >>> hana_schedule.create_applying_schedule(job_name='my_job2', obj=auto_c, cron="* * * mon,tue,wed,thu,fri 1 23 45", output_table_names=['RESULT_1123', 'INFO_1123'], force=True)
- Attributes:
- connection_contextConnectionContext
The connection to the HANA system.
Methods
check_scheduler_job_exist
(job_name)Check if the job exists in HANA Scheduler.
Clean up all the schedule jobs.
create_applying_schedule
(job_name, obj[, ...])Creates the applying procedure and the scheduled job.
create_scoring_schedule
(job_name, obj[, ...])Creates the scoring procedure and the scheduled job.
create_training_schedule
(job_name, obj[, ...])Creates the training procedure and the scheduled job.
delete_schedule
(job_name)Delete the given schedule job.
delete_schedules
(job_names)Delete the given schedule jobs.
display_schedule_status
([sort_by, ascending])Display the status of all the schedule jobs.
Get all the job names of the current user.
List all the schedule jobs.
set_schedule
(job_name[, cron, ...])Create or alter the schedule job.
- check_scheduler_job_exist(job_name)
Check if the job exists in HANA Scheduler.
- Parameters:
- job_namestr
Specifies the name of the scheduled job.
- list_schedules()
List all the schedule jobs.
- get_job_names()
Get all the job names of the current user.
- display_schedule_status(sort_by='START_TIME', ascending=False)
Display the status of all the schedule jobs.
- Parameters:
- sort_bystr, optional
Specifies the column to sort by.
Defaults to "START_TIME".
- ascendingbool, optional
Specifies the sort order.
Defaults to False.
- set_schedule(job_name, cron=None, procedure_name=None, job_start_time=None, job_end_time=None, status='active', procedure_params=None, force=False, disable_timezone_check=True)
Create or alter the schedule job.
- Parameters:
- job_namestr
Specifies the name of the scheduled job.
- cronstr
Specifies the frequency of the job. <cron> ::= <year> <month> <date> <weekday> <hour> <minute> <seconds>
<year> A four-digit number.
<month> A number from 1 to 12.
<date> A number from 1 to 31.
<weekday> A three-character day of the week: mon,tue,wed,thu,fri,sat,sun.
<hour> A number from 0 to 23 (expressed in 24-hour format).
<minute> A number from 0 to 59.
<seconds> A number from 0 to 59.
Each cron field also supports wildcard characters as follows.
* - Any value.
*/n - Any n-th value. For example, */1 for the day of the month means run every day of the month, */3 means run every third day of the month.
a:b - Any value between a and b.
a:b/n - Any n-th value between a and b. For example, 1:10/3 for the day of the month means every 3rd day between 1 and 10 or the 3rd, 6th, and 9th day of the month.
n.a - (For <weekday> only) A day of the week where n is a number from -5 to 5 for the n-th occurrence of the day in week a. For example, for the year 2019, 2.3 means Tuesday, January 15th. -3.22 means Friday, May 31st.
- procedure_namestr, optional
Specifies the name of the procedure in the scheduled job. If not specified, it will use "PROC_<job_name>".
- job_start_timestr, optional when server_side_scheduler is True
Specifies the earliest time after which the scheduled job can start to run.
- job_end_timestr, optional when server_side_scheduler is True
Specifies the latest time before which the scheduled job can start to run.
- status{'active', 'inactive'}
Enable or disable the schedule job.
- procedure_paramsdict, optional
Specifies the parameter name and value in the scheduled procedure. E.g., procedure_params={"THREAD_RATIO": 1}
- forcebool, optional
If force is True, it will disable the existing job and delete it.
Defaults to False.
- disable_timezone_checkbool, optional
If disable_timezone_check is True, it will disable the timezone check.
Defaults to True.
- delete_schedule(job_name)
Delete the given schedule job.
- Parameters:
- job_namestr
Specifies the name of the scheduled job.
- delete_schedules(job_names)
Delete the given schedule jobs.
- Parameters:
- job_nameslist of str
Specifies the names of the scheduled jobs.
- clean_up_schedules()
Clean up all the schedule jobs.
- create_training_schedule(job_name, obj, cron=None, job_start_time=None, job_end_time=None, status='active', output_table_names=None, procedure_name=None, force=True)
Creates the training procedure and the scheduled job.
- Parameters:
- job_namestr
Specifies the name of the scheduled job.
- objhana-ml object
The hana-ml object that has generated the execution statement. If the execution statement contains temporary table, it will perform the materialization. The materialized table name is according to "in_<job_name><idx>". <idx> is the index of the input table of the schedule procedure.
- cronstr
Specifies the frequency of the job. <cron> ::= <year> <month> <date> <weekday> <hour> <minute> <seconds>
<year> A four-digit number.
<month> A number from 1 to 12.
<date> A number from 1 to 31.
<weekday> A three-character day of the week: mon,tue,wed,thu,fri,sat,sun.
<hour> A number from 0 to 23 (expressed in 24-hour format).
<minute> A number from 0 to 59.
<seconds> A number from 0 to 59.
Each cron field also supports wildcard characters as follows.
* - Any value.
*/n - Any n-th value. For example, */1 for the day of the month means run every day of the month, */3 means run every third day of the month.
a:b - Any value between a and b.
a:b/n - Any n-th value between a and b. For example, 1:10/3 for the day of the month means every 3rd day between 1 and 10 or the 3rd, 6th, and 9th day of the month.
n.a (For <weekday> only) A day of the week where n is a number from -5 to 5 for the n-th occurrence of the day in week a. For example, for the year 2019, 2.3 means Tuesday, January 15th. -3.22 means Friday, May 31st.
- job_start_timestr, optional when server_side_scheduler is True
Specifies the earliest time after which the scheduled job can start to run.
- job_end_timestr, optional when server_side_scheduler is True
Specifies the latest time before which the scheduled job can start to run.
- status{'active', 'inactive'}
Enable or disable the schedule job.
- output_table_nameslist of str, optional
Specifies the output table names for the training result. If not specified, it will generate according to "out_<job_name><idx>". <idx> counts from 0.
- procedure_namestr, optional
Specifies the name of the procedure in the scheduled job. If not specified, it will use "PROC_<job_name>".
- forcebool, optional
If force is True, it will disable the existing job and delete it.
Defaults to False.
- create_applying_schedule(job_name, obj, cron=None, job_start_time=None, job_end_time=None, status='active', model_table_names=None, output_table_names=None, procedure_name=None, force=True)
Creates the applying procedure and the scheduled job.
- Parameters:
- job_namestr
Specifies the name of the scheduled job.
- objhana-ml object
The hana-ml object that has generated the execution statement. If the execution statement contains temporary table, it will perform the materialization. The materialized table name is according to "in_<job_name><idx>". <idx> is the index of the input table of the schedule procedure.
- cronstr
Specifies the frequency of the job. <cron> ::= <year> <month> <date> <weekday> <hour> <minute> <seconds>
<year> A four-digit number.
<month> A number from 1 to 12.
<date> A number from 1 to 31.
<weekday> A three-character day of the week: mon,tue,wed,thu,fri,sat,sun.
<hour> A number from 0 to 23 (expressed in 24-hour format).
<minute> A number from 0 to 59.
<seconds> A number from 0 to 59.
Each cron field also supports wildcard characters as follows.
* - Any value.
*/n - Any n-th value. For example, */1 for the day of the month means run every day of the month, */3 means run every third day of the month.
a:b - Any value between a and b.
a:b/n - Any n-th value between a and b. For example, 1:10/3 for the day of the month means every 3rd day between 1 and 10 or the 3rd, 6th, and 9th day of the month.
n.a - (For <weekday> only) A day of the week where n is a number from -5 to 5 for the n-th occurrence of the day in week a. For example, for the year 2019, 2.3 means Tuesday, January 15th. -3.22 means Friday, May 31st.
- job_start_timestr, optional when server_side_scheduler is True
Specifies the earliest time after which the scheduled job can start to run.
- job_end_timestr, optional when server_side_scheduler is True
Specifies the latest time before which the scheduled job can start to run.
- status{'active', 'inactive'}
Enable or disable the schedule job.
- model_table_namesstr or list of str, optional
Specifies the model table names for the predict result. If not, it will use temporary table name for materialization.
- output_table_nameslist of str, optional
Specifies the output table names for the predict result. If not specified, it will generate according to "out_<job_name><idx>". <idx> counts from 0.
- procedure_namestr, optional
Specifies the name of the procedure in the scheduled job. If not specified, it will use "PROC_<job_name>".
- forcebool, optional
If force is True, it will disable the existing job and delete it.
Defaults to False.
- create_scoring_schedule(job_name, obj, cron=None, job_start_time=None, job_end_time=None, status='active', model_table_names=None, output_table_names=None, procedure_name=None, force=True)
Creates the scoring procedure and the scheduled job.
- Parameters:
- job_namestr
Specifies the name of the scheduled job.
- objhana-ml object
The hana-ml object that has generated the execution statement. If the execution statement contains temporary table, it will perform the materialization. The materialized table name is according to "in_<job_name><idx>". <idx> is the index of the input table of the schedule procedure.
- cronstr
Specifies the frequency of the job. <cron> ::= <year> <month> <date> <weekday> <hour> <minute> <seconds>
<year> A four-digit number.
<month> A number from 1 to 12.
<date> A number from 1 to 31.
<weekday> A three-character day of the week: mon,tue,wed,thu,fri,sat,sun.
<hour> A number from 0 to 23 (expressed in 24-hour format).
<minute> A number from 0 to 59.
<seconds> A number from 0 to 59.
Each cron field also supports wildcard characters as follows.
* - Any value.
*/n - Any n-th value. For example, */1 for the day of the month means run every day of the month, */3 means run every third day of the month.
a:b - Any value between a and b.
a:b/n - Any n-th value between a and b. For example, 1:10/3 for the day of the month means every 3rd day between 1 and 10 or the 3rd, 6th, and 9th day of the month.
n.a - (For <weekday> only) A day of the week where n is a number from -5 to 5 for the n-th occurrence of the day in week a. For example, for the year 2019, 2.3 means Tuesday, January 15th. -3.22 means Friday, May 31st.
- job_start_timestr, optional when server_side_scheduler is True
Specifies the earliest time after which the scheduled job can start to run.
- job_end_timestr, optional when server_side_scheduler is True
Specifies the latest time before which the scheduled job can start to run.
- status{'active', 'inactive'}
Enable or disable the schedule job.
- model_table_namesstr or list of str, optional
Specifies the model table names for the score result. If not, it will use temporary table name for materialization.
- output_table_nameslist of str, optional
Specifies the output table names for the score result. If not specified, it will generate according to "out_<job_name><idx>". <idx> counts from 0.
- procedure_namestr, optional
Specifies the name of the procedure in the scheduled job. If not specified, it will use "PROC_<job_name>".
- forcebool, optional
If force is True, it will disable the existing job and delete it.
Defaults to False.