Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[UI] Scheduled workflow catchup=false option #3131

Merged
merged 7 commits into from
Feb 21, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
[UI] scheduled workflow catchup option
  • Loading branch information
Bobgy committed Feb 20, 2020
commit ee75822c7747b3896bc1a3d34a217390b2bbca92
44 changes: 33 additions & 11 deletions frontend/src/components/Trigger.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,11 @@ import { ApiTrigger } from '../apis/job';
import { stylesheet } from 'typestyle';

interface TriggerProps {
onChange?: (trigger?: ApiTrigger, maxConcurrentRuns?: string) => void;
onChange?: (config: {
trigger?: ApiTrigger;
maxConcurrentRuns?: string;
catchup: boolean;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that in BE, we use nocatchup and in FE we use catchup. They are having opposite values. Should we just use the same in BE and FE to avoid accidental mistake, e.g., like forgetting to take negation when transferring value...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A nit comment above. Otherwise /lgtm

Copy link
Contributor Author

@Bobgy Bobgy Feb 21, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a good point.
The only reason backend uses no catchup is to be backward compatible, because we need false as the default value.

But for UI, I think it's better we use catchup to avoid unnecessary concept coersion, what do you think?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds reasonable.

}) => void;
}

interface TriggerState {
Expand All @@ -52,6 +56,7 @@ interface TriggerState {
startDate: string;
startTime: string;
type: TriggerType;
catchup: boolean;
}

const css = stylesheet({
Expand All @@ -61,9 +66,7 @@ const css = stylesheet({
});

export default class Trigger extends React.Component<TriggerProps, TriggerState> {
constructor(props: any) {
super(props);

public state = (() => {
const now = new Date();
const inAWeek = new Date(
now.getFullYear(),
Expand All @@ -75,7 +78,7 @@ export default class Trigger extends React.Component<TriggerProps, TriggerState>
const [startDate, startTime] = dateToPickerFormat(now);
const [endDate, endTime] = dateToPickerFormat(inAWeek);

this.state = {
return {
cron: '',
editCron: false,
endDate,
Expand All @@ -89,8 +92,9 @@ export default class Trigger extends React.Component<TriggerProps, TriggerState>
startDate,
startTime,
type: TriggerType.INTERVALED,
catchup: true,
};
}
})();

public componentDidMount(): void {
// TODO: This is called here because NewRun only updates its Trigger in state when onChange is
Expand All @@ -114,6 +118,7 @@ export default class Trigger extends React.Component<TriggerProps, TriggerState>
startDate,
startTime,
type,
catchup,
} = this.state;

return (
Expand Down Expand Up @@ -209,6 +214,18 @@ export default class Trigger extends React.Component<TriggerProps, TriggerState>
variant='outlined'
/>
</div>
<span className={commonCss.flex}>
<FormControlLabel
control={
<Checkbox
checked={catchup}
color='primary'
onClick={this.handleChange('catchup')}
/>
}
label='Catchup'
/>
</span>

<span className={commonCss.flex}>
Run every
Expand Down Expand Up @@ -322,11 +339,11 @@ export default class Trigger extends React.Component<TriggerProps, TriggerState>
{
[name]: value,
} as any,
this._updateTrigger.bind(this),
this._updateTrigger,
);
};

private _updateTrigger(): void {
private _updateTrigger = () => {
const {
hasStartDate,
hasEndDate,
Expand All @@ -340,6 +357,7 @@ export default class Trigger extends React.Component<TriggerProps, TriggerState>
type,
cron,
selectedDays,
catchup,
} = this.state;

const startDateTime = pickersToDate(hasStartDate, startDate, startTime);
Expand All @@ -363,11 +381,15 @@ export default class Trigger extends React.Component<TriggerProps, TriggerState>
);

if (this.props.onChange) {
this.props.onChange(trigger, trigger ? this.state.maxConcurrentRuns : undefined);
this.props.onChange({
trigger,
maxConcurrentRuns: trigger ? this.state.maxConcurrentRuns : undefined,
catchup,
});
}
},
);
}
};

private _isAllDaysChecked(): boolean {
return this.state.selectedDays.every(d => !!d);
Expand Down Expand Up @@ -397,7 +419,7 @@ export default class Trigger extends React.Component<TriggerProps, TriggerState>
cron,
selectedDays: newDays,
},
this._updateTrigger.bind(this),
this._updateTrigger,
);
}
}
48 changes: 24 additions & 24 deletions frontend/src/pages/NewRun.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ interface NewRunState {
isFirstRunInExperiment: boolean;
isRecurringRun: boolean;
maxConcurrentRuns?: string;
catchup: boolean;
parameters: ApiParameter[];
pipeline?: ApiPipeline;
pipelineVersion?: ApiPipelineVersion;
Expand Down Expand Up @@ -142,29 +143,26 @@ class NewRun extends Page<{}, NewRunState> {
{ label: 'Created at', flex: 1, sortKey: ExperimentSortKeys.CREATED_AT },
];

constructor(props: any) {
super(props);

this.state = {
description: '',
errorMessage: '',
experimentName: '',
experimentSelectorOpen: false,
isBeingStarted: false,
isClone: false,
isFirstRunInExperiment: false,
isRecurringRun: false,
parameters: [],
pipelineName: '',
pipelineSelectorOpen: false,
pipelineVersionName: '',
pipelineVersionSelectorOpen: false,
runName: '',
uploadDialogOpen: false,
usePipelineFromRunLabel: 'Using pipeline from cloned run',
useWorkflowFromRun: false,
};
}
public state: NewRunState = {
description: '',
errorMessage: '',
experimentName: '',
experimentSelectorOpen: false,
isBeingStarted: false,
isClone: false,
isFirstRunInExperiment: false,
isRecurringRun: false,
parameters: [],
pipelineName: '',
pipelineSelectorOpen: false,
pipelineVersionName: '',
pipelineVersionSelectorOpen: false,
runName: '',
uploadDialogOpen: false,
usePipelineFromRunLabel: 'Using pipeline from cloned run',
useWorkflowFromRun: false,
catchup: true, // defaults to true
};

public getInitialToolbarState(): ToolbarProps {
return {
Expand Down Expand Up @@ -507,11 +505,12 @@ class NewRun extends Page<{}, NewRunState> {
<div>Choose a method by which new runs will be triggered</div>

<Trigger
onChange={(trigger, maxConcurrentRuns) =>
onChange={({ trigger, maxConcurrentRuns, catchup }) =>
this.setStateSafe(
{
maxConcurrentRuns,
trigger,
catchup,
},
this._validate.bind(this),
)
Expand Down Expand Up @@ -1037,6 +1036,7 @@ class NewRun extends Page<{}, NewRunState> {
enabled: true,
max_concurrency: this.state.maxConcurrentRuns || '1',
trigger: this.state.trigger,
no_catchup: !this.state.catchup,
});
}

Expand Down
3 changes: 3 additions & 0 deletions frontend/src/pages/RecurringRunDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ class RecurringRunDetails extends Page<{}, RecurringRunConfigState> {
formatDateString(run.trigger.periodic_schedule.end_time),
]);
}
if (run.no_catchup != null) {
triggerDetails.push(['Catchup', `${run.no_catchup}`]);
}
}
}

Expand Down