class DagRunForm(DynamicForm): dag_id = StringField(lazy_gettext('Dag Id'), validators=[validators.DataRequired()], widget=BS3TextFieldWidget()) start_date = DateTimeField(lazy_gettext('Start Date'), widget=AirflowDateTimePickerWidget()) end_date = DateTimeField(lazy_gettext('End Date'), widget=AirflowDateTimePickerWidget()) run_id = StringField(lazy_gettext('Run Id'), validators=[validators.DataRequired()], widget=BS3TextFieldWidget()) state = SelectField(lazy_gettext('State'), choices=( ('success', 'success'), ('running', 'running'), ('failed', 'failed'), ), widget=Select2Widget()) execution_date = DateTimeField(lazy_gettext('Execution Date'), widget=AirflowDateTimePickerWidget()) external_trigger = BooleanField(lazy_gettext('External Trigger')) conf = TextAreaField(lazy_gettext('Conf'), validators=[ValidJson(), validators.Optional()], widget=BS3TextAreaFieldWidget()) def populate_obj(self, item): # TODO: This is probably better done as a custom field type so we can # set TZ at parse time super().populate_obj(item) item.execution_date = timezone.make_aware(item.execution_date) if item.conf: item.conf = json.loads(item.conf)
class DagRunForm(DynamicForm): dag_id = StringField(lazy_gettext('Dag Id'), validators=[validators.DataRequired()], widget=BS3TextFieldWidget()) start_date = DateTimeWithTimezoneField( lazy_gettext('Start Date'), widget=AirflowDateTimePickerWidget()) end_date = DateTimeWithTimezoneField(lazy_gettext('End Date'), widget=AirflowDateTimePickerWidget()) run_id = StringField(lazy_gettext('Run Id'), validators=[validators.DataRequired()], widget=BS3TextFieldWidget()) state = SelectField(lazy_gettext('State'), choices=( ('success', 'success'), ('running', 'running'), ('failed', 'failed'), ), widget=Select2Widget()) execution_date = DateTimeWithTimezoneField( lazy_gettext('Execution Date'), widget=AirflowDateTimePickerWidget()) external_trigger = BooleanField(lazy_gettext('External Trigger')) conf = TextAreaField(lazy_gettext('Conf'), validators=[ValidJson(), validators.Optional()], widget=BS3TextAreaFieldWidget()) def populate_obj(self, item): super().populate_obj(item) item.run_type = DagRunType.from_run_id(item.run_id).value if item.conf: item.conf = json.loads(item.conf)
class DagRunForm(DynamicForm): """Form for editing and adding DAG Run""" dag_id = StringField(lazy_gettext('Dag Id'), validators=[DataRequired()], widget=BS3TextFieldWidget()) start_date = DateTimeWithTimezoneField( lazy_gettext('Start Date'), widget=AirflowDateTimePickerWidget()) end_date = DateTimeWithTimezoneField(lazy_gettext('End Date'), widget=AirflowDateTimePickerWidget()) run_id = StringField(lazy_gettext('Run Id'), validators=[DataRequired()], widget=BS3TextFieldWidget()) state = SelectField( lazy_gettext('State'), choices=( ('success', 'success'), ('running', 'running'), ('failed', 'failed'), ), widget=Select2Widget(), ) execution_date = DateTimeWithTimezoneField( lazy_gettext('Execution Date'), widget=AirflowDateTimePickerWidget()) external_trigger = BooleanField(lazy_gettext('External Trigger')) conf = TextAreaField(lazy_gettext('Conf'), validators=[ValidJson(), Optional()], widget=BS3TextAreaFieldWidget()) def populate_obj(self, item): """Populates the attributes of the passed obj with data from the form’s fields.""" super().populate_obj(item) # pylint: disable=no-member item.run_type = DagRunType.from_run_id(item.run_id) if item.conf: item.conf = json.loads(item.conf)
class DateTimeForm(FlaskForm): """ Date filter form needed for task views """ execution_date = DateTimeWithTimezoneField( "Execution date", widget=AirflowDateTimePickerWidget())
class DateTimeWithNumRunsForm(FlaskForm): # Date time and number of runs form for tree view, task duration # and landing times base_date = DateTimeField( "Anchor date", widget=AirflowDateTimePickerWidget(), default=timezone.utcnow()) num_runs = SelectField("Number of runs", default=25, choices=( (5, "5"), (25, "25"), (50, "50"), (100, "100"), (365, "365"), ))