Skip to content

Commit

Permalink
Allows durations >=24h and renames 'showLink' in RunList
Browse files Browse the repository at this point in the history
  • Loading branch information
rileyjbauer committed Aug 13, 2019
1 parent af1e0ee commit c4c5740
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
6 changes: 6 additions & 0 deletions frontend/mock-backend/fixed-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@ const runs: ApiRunDetail[] = [
run: {
created_at: new Date('2018-03-17T20:58:23.000Z'),
description: 'A recursive coinflip run',
finished_at: new Date('2018-03-18T21:01:23.000Z'),
id: '3308d0ec-f1b3-4488-a2d3-8ad0f91e88e7',
metrics: [
{
Expand Down Expand Up @@ -319,6 +320,7 @@ const runs: ApiRunDetail[] = [
run: {
created_at: new Date('2018-04-17T21:00:00.000Z'),
description: 'A coinflip run with an error. No metrics',
finished_at: new Date('2018-04-17T21:00:33.000Z'),
id: '47a3d09c-7db4-4788-ac55-3f8d908574aa',
metrics: [],
name: 'coinflip-error-nklng2',
Expand Down Expand Up @@ -380,6 +382,7 @@ const runs: ApiRunDetail[] = [
run: {
created_at: new Date('2018-06-17T22:58:23.000Z'),
description: 'A simple hello world run, but with steps. Not attached to any experiment',
finished_at: new Date('2018-06-18T21:00:33.000Z'),
id: '21afb688-7597-47e9-b6c3-35d3145fe5e1',
metrics: [{
format: RunMetricFormat.PERCENTAGE,
Expand Down Expand Up @@ -466,6 +469,7 @@ const runs: ApiRunDetail[] = [
+ ' Ut nec dapibus eros, vitae iaculis nunc. In aliquet accumsan rhoncus. Donec vitae'
+ ' ipsum a tellus fermentum pharetra in in neque. Pellentesque consequat felis non est'
+ ' vulputate pellentesque. Aliquam eget cursus enim.',
finished_at: new Date('2018-08-20T21:01:23.000Z'),
id: '7fc01714-4a13-4c05-8044-a8a72c14253b',
metrics: [
{
Expand Down Expand Up @@ -508,6 +512,7 @@ const runs: ApiRunDetail[] = [
run: {
created_at: new Date('2018-08-18T20:58:23.000Z'),
description: 'simple run with pipeline spec embedded in it.',
finished_at: new Date('2018-08-18T21:01:23.000Z'),
id: '7fc01715-4a93-4c00-8044-a8a72c14253b',
metrics: [
{
Expand Down Expand Up @@ -575,6 +580,7 @@ function generateNRuns(): ApiRunDetail[] {
run: {
created_at: new Date('2018-02-12T20:' + padStartTwoZeroes(i.toString()) + ':23.000Z'),
description: 'The description of a dummy run',
finished_at: new Date('2018-02-12T20:' + padStartTwoZeroes(((2 * i) % 60).toString()) + ':25.000Z'),
id: 'Some-run-id-' + i,
metrics: [
{
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/lib/Utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ function getDuration(start: Date, end: Date): string {
const seconds = ('0' + Math.floor((diff / SECOND) % 60).toString()).slice(-2);
const minutes = ('0' + Math.floor((diff / MINUTE) % 60).toString()).slice(-2);
// Hours are the largest denomination, so we don't pad them
const hours = Math.floor((diff / HOUR) % 24).toString();
const hours = Math.floor(diff / HOUR).toString();
return `${sign}${hours}:${minutes}:${seconds}`;
}

Expand Down
16 changes: 10 additions & 6 deletions frontend/src/pages/RunList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ interface PipelineInfo {
displayName?: string;
id?: string;
runId?: string;
showLink: boolean;
pipelineFromSpec: boolean;
}

interface RecurringRunInfo {
Expand Down Expand Up @@ -191,17 +191,17 @@ class RunList extends React.PureComponent<RunListProps, RunListState> {

public _pipelineCustomRenderer: React.FC<CustomRendererProps<PipelineInfo>> = (props: CustomRendererProps<PipelineInfo>) => {
// If the getPipeline call failed or a run has no pipeline, we display a placeholder.
if (!props.value || (!props.value.showLink && !props.value.id)) {
if (!props.value || (!props.value.pipelineFromSpec && !props.value.id)) {
return <div>-</div>;
}
const search = new URLParser(this.props).build({ [QUERY_PARAMS.fromRunId]: props.id });
const url = props.value.showLink ?
const url = props.value.pipelineFromSpec ?
RoutePage.PIPELINE_DETAILS.replace(':' + RouteParams.pipelineId + '?', '') + search :
RoutePage.PIPELINE_DETAILS.replace(':' + RouteParams.pipelineId, props.value.id || '');
return (
<Link className={commonCss.link} onClick={(e) => e.stopPropagation()}
to={url}>
{props.value.showLink ? '[View pipeline]' : props.value.displayName}
{props.value.pipelineFromSpec ? '[View pipeline]' : props.value.displayName}
</Link>
);
}
Expand Down Expand Up @@ -359,13 +359,17 @@ class RunList extends React.PureComponent<RunListProps, RunListState> {
if (pipelineId) {
try {
const pipeline = await Apis.pipelineServiceApi.getPipeline(pipelineId);
displayRun.pipeline = { displayName: pipeline.name || '', id: pipelineId, showLink: false };
displayRun.pipeline = {
displayName: pipeline.name || '',
id: pipelineId,
pipelineFromSpec: false
};
} catch (err) {
// This could be an API exception, or a JSON parse exception.
displayRun.error = 'Failed to get associated pipeline: ' + await errorToMessage(err);
}
} else if (!!RunUtils.getPipelineSpec(displayRun.run)) {
displayRun.pipeline = { showLink: true };
displayRun.pipeline = { pipelineFromSpec: true };
}
}

Expand Down

0 comments on commit c4c5740

Please sign in to comment.