コード例 #1
0
def job(
    name,
    cmd,
    schedule_interval,
    start_date,
    end_date,
    catchup,
    depends_on_past,
    update,
    retries,
):
    """Manage scheduled jobs"""
    from dbnd._core.utils.timezone import make_aware, is_localized

    if start_date and not is_localized(start_date):
        start_date = make_aware(start_date)
    if end_date and not is_localized(end_date):
        end_date = make_aware(end_date)
    scheduled_job = {
        "name": name,
        "cmd": cmd,
        "start_date": start_date,
        "end_date": end_date,
        "schedule_interval": schedule_interval,
        "catchup": catchup,
        "depends_on_past": depends_on_past,
        "retries": retries,
    }

    if update:
        res = patch_scheduled_job(scheduled_job)
    else:
        res = post_scheduled_job(scheduled_job)

    _click_echo_jobs([res])
コード例 #2
0
    def build_delta(self):
        from_file = self.read_config(self.config_file)

        file_modified_time = make_aware(
            datetime.utcfromtimestamp(os.path.getmtime(self.config_file)))
        if not from_file:
            from_file = []

        from_file = self.load_and_validate(from_file)

        from_db = [
            s["DbndScheduledJob"]
            for s in get_scheduled_jobs(from_file_only=True,
                                        include_deleted=None)
        ]
        return self.delta(from_db, from_file, file_modified_time)
コード例 #3
0
ファイル: constants.py プロジェクト: turbaszek/dbnd
class SystemTaskName(object):
    driver_submit = "dbnd_driver_submit"
    driver = "dbnd_driver"
    task_submit = "dbnd_task_submit"

    driver_and_submitter = {driver_submit, driver}


@attr.s
class _DbndDataClass(object):
    def asdict(self, filter=None):
        return attr.asdict(self, recurse=False, filter=filter)


HEARTBEAT_DISABLED = make_aware(datetime.datetime.fromtimestamp(0))


class ParamValidation(enum.Enum):
    warn = "warn"
    error = "error"
    disabled = "disabled"


class DbndTargetOperationType(enum.Enum):
    init = "init"
    read = "read"
    write = "write"
    reuse = "reuse"
    log = "log"
コード例 #4
0
ファイル: click_tzdatetime.py プロジェクト: turbaszek/dbnd
 def _try_to_convert_date(self, value, format):
     dt = super(TZAwareDateTime, self)._try_to_convert_date(value, format)
     if dt:
         return make_aware(dt, get_localzone())