def _load_schedules(self): utils.mkdir_p(self._artifacts_dir) for file in os.listdir(self._artifacts_dir): if not file.endswith('.json'): continue file_path = os.path.join(self._artifacts_dir, file) with open(file_path) as data: try: data = seven.json.load(data) schedule = RunningSchedule( data['schedule_id'], ScheduleDefinition( name=data['name'], cron_schedule=data['cron_schedule'], execution_params=data['execution_params'], ), python_path=data['python_path'], repository_path=data['repository_path'], ) self._schedules[ schedule.schedule_definition.name] = schedule except Exception as ex: # pylint: disable=broad-except six.raise_from( Exception( 'Could not parse dagit schedule from {file_name} in {dir_name}. {ex}: {msg}' .format( file_name=file, dir_name=self._artifacts_dir, ex=type(ex).__name__, msg=ex, )), ex, )
def start_schedule(self, schedule_definition, python_path, repository_path): if schedule_definition.name in self._schedules: raise DagsterInvariantViolationError( 'You have attempted to start schedule {name}, but it is already running.' .format(name=schedule_definition.name)) schedule_id = str(uuid.uuid4()) schedule = RunningSchedule(schedule_id, schedule_definition, python_path, repository_path) self._schedules[schedule_definition.name] = schedule return schedule
def start_schedule(self, schedule_definition, python_path, repository_path): if schedule_definition.name in self._schedules: raise DagsterInvariantViolationError(( 'You have attempted to start schedule {name}, but it is already running.' ).format(name=schedule_definition.name)) schedule_id = str(uuid.uuid4()) schedule = RunningSchedule(schedule_id, schedule_definition, python_path, repository_path) self._schedules[schedule_definition.name] = schedule self._write_schedule_to_file(schedule) script_file = self._write_bash_script_to_file(schedule) self._start_cron_job(script_file, schedule) return schedule