def test_create_job(adminapp, jt, kwargs, nocommit_cursor, user_id): jobs.create_job(jt, 'testcreatejob', user_id, 'cronstr', **kwargs) jlist = jobs.storage._call_procedure('list_jobs', with_current_user=False) assert len(jlist) == 2 job = [j for j in jlist if j['name'] == 'testcreatejob'][0] assert job['schedule'] == {'type': 'cron', 'cron_string': 'cronstr'} assert job['job_type'] == jt assert job['parameters'] == kwargs
def test_create_job_timeout(adminapp, nocommit_cursor, user_id): timeout = 100 jobs.create_job('periodic_report', 'testcreatejob', user_id, 'cronstr', timeout, report_id='reportid') jlist = jobs.storage._call_procedure('list_jobs', with_current_user=False) assert len(jlist) == 2 job = [j for j in jlist if j['name'] == 'testcreatejob'][0] assert job['schedule'] == { 'type': 'cron', 'cron_string': 'cronstr', 'timeout': timeout }
def reference_persistence_job(name, user_id, cron_string, base_url, timeout, **kwargs): """ Create a reference persistence job named NAME to be executed by USER_ID on a scheduled defined by CRON_STRING. Persistence forecasts are made based on new observation values. """ from sfa_api.jobs import create_job id_ = create_job('reference_persistence', name, user_id, cron_string, timeout, base_url=base_url) click.echo(f'Job created with id {id_}')
def periodic_report_job(name, user_id, cron_string, report_id, base_url, timeout, **kwargs): """ Create a job to periodically recreate a report given by REPORT_ID with job name NAME executed by user USER_ID on a schedule defined by CRON_STRING. """ from sfa_api.jobs import create_job id_ = create_job('periodic_report', name, user_id, cron_string, timeout, report_id=str(report_id), base_url=base_url) click.echo(f'Job created with id {id_}')
def reference_nwp_job(name, user_id, cron_string, issue_time_buffer, base_url, timeout, **kwargs): """ Create a reference nwp job named NAME to be executed by USER_ID on a scheduled defined by CRON_STRING. ISSUE_TIME_BUFFER is a timedelta added to the job run time to determine how far in advance a forecast can be made relative to the expected issue time the forecast. """ from sfa_api.jobs import create_job id_ = create_job('reference_nwp', name, user_id, cron_string, timeout, issue_time_buffer=issue_time_buffer, base_url=base_url) click.echo(f'Job created with id {id_}')
def daily_validation_job(name, user_id, cron_string, start_td, end_td, base_url, timeout, **kwargs): """ Create a daily observation validation job named NAME to be executed by the USER_ID user on a scheduled according to CRON_STRING. Validation is performed from job_time + START_TD to job_time + END_TD, so both are likely negative. """ from sfa_api.jobs import create_job id_ = create_job('daily_observation_validation', name, user_id, cron_string, timeout, start_td=start_td, end_td=end_td, base_url=base_url) click.echo(f'Job created with id {id_}')