#NEWLINE# def __init__( self , id , frequency = 'one-time' , time_delta = None , load_hour = None , load_minutes = None , **kwargs ) : #NEWLINE# #INDENT# 'Constructor for the Schedule class\n\n        Args:\n            id(str): id of the Schedule object\n            frequency(enum): rate at which pipeline should be run                 can be daily, hourly and one-time\n            time_delta(timedelta): Additional offset provided to the schedule\n            load_hour(int): Hour at which the pipeline should start\n            load_minutes(int): Minutes at which the pipeline should be run\n            **kwargs(optional): Keyword arguments directly passed to base class\n        ' #NEWLINE# current_time = datetime . utcnow ( ) #NEWLINE# if ( load_minutes is None ) : #NEWLINE# #INDENT# load_minutes = 0 #NEWLINE# #UNINDENT# if ( load_hour is None ) : #NEWLINE# #INDENT# load_hour = DAILY_LOAD_TIME #NEWLINE# #UNINDENT# if ( time_delta is None ) : #NEWLINE# #INDENT# time_delta = timedelta ( seconds = 0 ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if isinstance ( time_delta , int ) : #NEWLINE# #INDENT# time_delta = timedelta ( days = time_delta ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( not isinstance ( time_delta , timedelta ) ) : #NEWLINE# #INDENT# raise ETLInputError ( 'Time_delta must be an instance of timedelta or int' ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# if ( frequency in FEQUENCY_PERIOD_CONVERTION ) : #NEWLINE# #INDENT# ( period , occurrences ) = FEQUENCY_PERIOD_CONVERTION [ frequency ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# raise ETLInputError ( ( 'Frequency %s not supported' % frequency ) ) #NEWLINE# #UNINDENT# start_time = current_time . replace ( minute = load_minutes ) #NEWLINE# start_time = start_time . replace ( hour = load_hour , second = 0 ) #NEWLINE# if ( current_time . hour < load_hour ) : #NEWLINE# #INDENT# if ( frequency == 'one-time' ) : #NEWLINE# #INDENT# time_delta -= timedelta ( days = 1 ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# time_delta -= timedelta ( seconds = parse ( period ) ) #NEWLINE# #UNINDENT# #UNINDENT# start_time += time_delta #NEWLINE# start_time_str = start_time . strftime ( '%Y-%m-%dT%H:%M:%S' ) #NEWLINE# logger . info ( ( 'Pipeline scheduled to start at %s' % start_time_str ) ) #NEWLINE# super ( Schedule , self ) . __init__ ( id = id , type = 'Schedule' , startDateTime = start_time_str , period = period , occurrences = occurrences )