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

fix: fix task openability check and a trial detail decoder mismatch [DET-3924 DET-3937] #1148

Merged
merged 7 commits into from
Aug 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
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
6 changes: 4 additions & 2 deletions webui/react/src/components/CheckpointModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,11 @@ const CheckpointModal: React.FC<Props> = ({ config, checkpoint, onHide, show, ti
}, [ checkpoint ]);

const resources = useMemo(() => {
if (checkpoint.resources === undefined) return [];
const checkpointResources = checkpoint.resources;
return Object.keys(checkpoint.resources)
.sort((a, b) => checkpoint.resources[a] - checkpoint.resources[b])
.map(key => ({ name: key, size: humanReadableBytes(checkpoint.resources[key]) }));
.sort((a, b) => checkpointResources[a] - checkpointResources[b])
.map(key => ({ name: key, size: humanReadableBytes(checkpointResources[key]) }));
}, [ checkpoint.resources ]);

return (
Expand Down
53 changes: 53 additions & 0 deletions webui/react/src/fixtures/trialdetails-2994.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{
"end_time": "2020-08-20T00:16:46.465441+00:00",
"experiment_id": 1,
"hparams": {
"metrics_base": 0.9,
"metrics_sigma": 0,
"global_batch_size": 32,
"metrics_progression": "decreasing"
},
"id": 1,
"seed": 511579848,
"start_time": "2020-08-20T00:09:44.800485+00:00",
"state": "ERROR",
"warm_start_checkpoint_id": null,
"total_batches_processed": 100,
"steps": [
{
"id": 1,
"state": "COMPLETED",
"end_time": "2020-08-20T00:16:45.663342+00:00",
"checkpoint": {
"id": 1504,
"uuid": null,
"state": "ACTIVE",
"step_id": 1,
"end_time": null,
"metadata": {},
"trial_id": 1,
"resources": null,
"start_time": "2020-08-20T00:16:45.682217+00:00",
"validation_metric": 0.9
},
"start_time": "2020-08-20T00:16:38.35693+00:00",
"validation": {
"id": 2370,
"state": "COMPLETED",
"metrics": {
"num_inputs": 1024,
"validation_metrics": {
"validation_error": 0.9
}
},
"end_time": "2020-08-20T00:16:45.676929+00:00",
"start_time": "2020-08-20T00:16:45.666277+00:00"
},
"avg_metrics": {
"loss": 0.9000000000000005
},
"num_batches": 100,
"prior_batches_processed": 0
}
]
}
3 changes: 2 additions & 1 deletion webui/react/src/ioTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export const decode = <T>(type: io.Mixed, data: any): T => {
};

const ioNullOrUndefined = io.union([ io.null, io.undefined ]);
const optional = (x: io.Mixed) => io.union([ x, ioNullOrUndefined ]);

/* User */

Expand Down Expand Up @@ -161,7 +162,7 @@ const startEndTimeDef = {
export const ioCheckpoint = io.type({
...startEndTimeDef,
id: io.number,
resources: io.record(io.string, io.number),
resources: optional(io.record(io.string, io.number)),
state: checkpointStatesIoType,
step_id: io.number,
trial_id: io.number,
Expand Down
2 changes: 1 addition & 1 deletion webui/react/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ export interface MetricName {
// Checkpoint sub step.
export interface Checkpoint extends StartEndTimes {
id: number;
resources: Record<string, number>;
resources?: Record<string, number>;
state: CheckpointState;
stepId: number;
trialId: number;
Expand Down
6 changes: 2 additions & 4 deletions webui/react/src/utils/task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import {
} from 'types';
import { terminalCommandStates } from 'utils/types';

import { isExperiment } from './types';

/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
export function getRandomElementOfEnum(e: any): any {
const keys = Object.keys(e);
Expand Down Expand Up @@ -116,8 +114,8 @@ export const isExperimentTask = (task: AnyTask): task is ExperimentTask => {
};

export const canBeOpened = (task: AnyTask): boolean => {
if (!isExperimentTask(task) && task.state in terminalCommandStates) return false;
if (isExperiment(task)) return true;
if (isExperimentTask(task)) return true;
if (terminalCommandStates.has(task.state)) return false;
Copy link
Contributor

Choose a reason for hiding this comment

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

ha nice!

return !!task.url;
};

Expand Down
3 changes: 2 additions & 1 deletion webui/react/src/utils/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ export function hasKey<O>(obj: O, key: keyof any): key is keyof O {

// differentiate Experiment from Task
export const isExperiment = (obj: AnyTask | Experiment): obj is Experiment => {
return 'config' in obj; // FIXME
return 'config' in obj && 'archived' in obj;
};

// used when properties are named differently between objects.
Expand All @@ -163,6 +163,7 @@ export const oneOfProperties = <T>(obj: any, props: string[]): T => {

// size in bytes
export const checkpointSize = (checkpoint: Checkpoint): number => {
if (!checkpoint.resources) return 0;
const total = Object.values(checkpoint.resources).reduce((acc, size) => acc + size, 0);
return total;
};
Expand Down