Skip to content

Commit

Permalink
add arrays to exp show data type
Browse files Browse the repository at this point in the history
  • Loading branch information
mattseddon committed Jun 2, 2022
1 parent 1a2d5c2 commit 12d7d52
Show file tree
Hide file tree
Showing 11 changed files with 58 additions and 5 deletions.
2 changes: 1 addition & 1 deletion extension/src/cli/reader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export type StatusesOrAlwaysChanged = StageOrFileStatuses | 'always changed'

export type StatusOutput = Record<string, StatusesOrAlwaysChanged[]>

export type Value = string | number | boolean | null
export type Value = string | number | boolean | null | number[]

export interface ValueTreeOrError {
data?: ValueTree
Expand Down
1 change: 1 addition & 0 deletions extension/src/experiments/columns/collect.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,7 @@ describe('collectColumns', () => {
joinColumnPath(ColumnType.METRICS, 'summary.json', 'val_loss'),
joinColumnPath(ColumnType.METRICS, 'summary.json', 'val_accuracy'),
joinColumnPath(ColumnType.PARAMS, 'params.yaml'),
joinColumnPath(ColumnType.PARAMS, 'params.yaml', 'code_names'),
joinColumnPath(ColumnType.PARAMS, 'params.yaml', 'epochs'),
joinColumnPath(ColumnType.PARAMS, 'params.yaml', 'learning_rate'),
joinColumnPath(ColumnType.PARAMS, 'params.yaml', 'dvc_logs_dir'),
Expand Down
3 changes: 3 additions & 0 deletions extension/src/experiments/columns/collect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ const getValueType = (value: Value) => {
if (value === null) {
return 'null'
}
if (Array.isArray(value)) {
return 'array'
}
return typeof value
}

Expand Down
8 changes: 8 additions & 0 deletions extension/src/experiments/columns/tree.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,14 @@ describe('ExperimentsColumnsTree', () => {
path: paramsPath
})
expect(grandChildren).toStrictEqual([
{
collapsibleState: 0,
description: undefined,
dvcRoot: mockedDvcRoot,
iconPath: mockedSelectedCheckbox,
label: 'code_names',
path: appendColumnToPath(paramsPath, 'code_names')
},
{
collapsibleState: 0,
description: undefined,
Expand Down
2 changes: 1 addition & 1 deletion extension/src/experiments/columns/walk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const walkValueTree = (
ancestors: string[] = []
) => {
for (const [key, value] of Object.entries(tree)) {
if (value && typeof value === 'object') {
if (value && !Array.isArray(value) && typeof value === 'object') {
walkValueTree(value, meta, onValue, [...ancestors, key])
} else {
onValue(key, value, meta, ancestors)
Expand Down
1 change: 1 addition & 0 deletions extension/src/experiments/model/queue/collect.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ describe('collectFlatExperimentParams', () => {
it('should flatten the params into an array', () => {
const params = collectFlatExperimentParams(rowsFixture[0].params)
expect(params).toStrictEqual([
{ path: appendColumnToPath('params.yaml', 'code_names'), value: [0, 1] },
{ path: appendColumnToPath('params.yaml', 'epochs'), value: 2 },
{
path: appendColumnToPath('params.yaml', 'learning_rate'),
Expand Down
4 changes: 2 additions & 2 deletions extension/src/experiments/model/queue/collect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ export type Param = {
}

const collectFromParamsFile = (
acc: { path: string; value: string | number | boolean }[],
acc: { path: string; value: Value }[],
key: string | undefined,
value: Value | ValueTree,
ancestors: string[] = []
) => {
const pathArray = [...ancestors, key].filter(Boolean) as string[]

if (typeof value === 'object') {
if (!Array.isArray(value) && typeof value === 'object') {
for (const [childKey, childValue] of Object.entries(value as ValueTree)) {
collectFromParamsFile(acc, childKey, childValue, pathArray)
}
Expand Down
10 changes: 10 additions & 0 deletions extension/src/test/fixtures/expShow/columns.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,16 @@ const data: Column[] = [
parentPath: ColumnType.PARAMS,
path: joinColumnPath(ColumnType.PARAMS, 'params.yaml')
},
{
type: ColumnType.PARAMS,
hasChildren: false,
maxStringLength: 3,
name: 'code_names',
parentPath: joinColumnPath(ColumnType.PARAMS, 'params.yaml'),
path: joinColumnPath(ColumnType.PARAMS, 'params.yaml', 'code_names'),
pathArray: [ColumnType.PARAMS, 'params.yaml', 'code_names'],
types: ['array']
},
{
type: ColumnType.PARAMS,
hasChildren: false,
Expand Down
15 changes: 15 additions & 0 deletions extension/src/test/fixtures/expShow/output.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ const data: ExperimentsOutput = {
params: {
'params.yaml': {
data: {
code_names: [0, 1],
epochs: 2,
learning_rate: 2.2e-7,
dvc_logs_dir: 'dvc_logs',
Expand Down Expand Up @@ -201,6 +202,7 @@ const data: ExperimentsOutput = {
params: {
'params.yaml': {
data: {
code_names: [0, 1],
epochs: 5,
learning_rate: 2.1e-7,
dvc_logs_dir: 'dvc_logs',
Expand Down Expand Up @@ -311,6 +313,7 @@ const data: ExperimentsOutput = {
params: {
'params.yaml': {
data: {
code_names: [0, 1],
epochs: 2,
learning_rate: 2e-12,
dvc_logs_dir: 'dvc_logs',
Expand Down Expand Up @@ -420,6 +423,7 @@ const data: ExperimentsOutput = {
params: {
'params.yaml': {
data: {
code_names: [0, 1],
epochs: 2,
learning_rate: 2e-12,
dvc_logs_dir: 'dvc_logs',
Expand Down Expand Up @@ -529,6 +533,7 @@ const data: ExperimentsOutput = {
params: {
'params.yaml': {
data: {
code_names: [0, 1],
epochs: 2,
learning_rate: 2e-12,
dvc_logs_dir: 'dvc_logs',
Expand Down Expand Up @@ -608,6 +613,7 @@ const data: ExperimentsOutput = {
params: {
'params.yaml': {
data: {
code_names: [0, 1],
epochs: 2,
learning_rate: 2.2e-7,
dvc_logs_dir: 'dvc_logs',
Expand Down Expand Up @@ -748,6 +754,7 @@ const data: ExperimentsOutput = {
params: {
'params.yaml': {
data: {
code_names: [0, 1],
epochs: 2,
learning_rate: 2.2e-7,
dvc_logs_dir: 'dvc_logs',
Expand Down Expand Up @@ -857,6 +864,7 @@ const data: ExperimentsOutput = {
params: {
'params.yaml': {
data: {
code_names: [0, 1],
epochs: 2,
learning_rate: 2.2e-7,
dvc_logs_dir: 'dvc_logs',
Expand Down Expand Up @@ -967,6 +975,7 @@ const data: ExperimentsOutput = {
params: {
'params.yaml': {
data: {
code_names: [0, 1],
epochs: 5,
learning_rate: 2.1e-7,
dvc_logs_dir: 'dvc_logs',
Expand Down Expand Up @@ -1046,6 +1055,7 @@ const data: ExperimentsOutput = {
params: {
'params.yaml': {
data: {
code_names: [0, 1],
epochs: 5,
learning_rate: 2.1e-7,
dvc_logs_dir: 'dvc_logs',
Expand Down Expand Up @@ -1155,6 +1165,7 @@ const data: ExperimentsOutput = {
params: {
'params.yaml': {
data: {
code_names: [0, 1],
epochs: 5,
learning_rate: 2.1e-7,
dvc_logs_dir: 'dvc_logs',
Expand Down Expand Up @@ -1294,6 +1305,7 @@ const data: ExperimentsOutput = {
params: {
'params.yaml': {
data: {
code_names: [0, 1],
epochs: 5,
learning_rate: 2.1e-7,
dvc_logs_dir: 'dvc_logs',
Expand Down Expand Up @@ -1403,6 +1415,7 @@ const data: ExperimentsOutput = {
params: {
'params.yaml': {
data: {
code_names: [0, 1],
epochs: 5,
learning_rate: 2.1e-7,
dvc_logs_dir: 'dvc_logs',
Expand Down Expand Up @@ -1512,6 +1525,7 @@ const data: ExperimentsOutput = {
params: {
'params.yaml': {
data: {
code_names: [0, 1],
epochs: 5,
learning_rate: 2.1e-7,
dvc_logs_dir: 'dvc_logs',
Expand Down Expand Up @@ -1608,6 +1622,7 @@ const data: ExperimentsOutput = {
params: {
'params.yaml': {
data: {
code_names: [0, 1],
epochs: 5,
learning_rate: 2.1e-7,
dvc_logs_dir: 'dvc_logs',
Expand Down
15 changes: 15 additions & 0 deletions extension/src/test/fixtures/expShow/rows.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ const data: Row[] = [
},
params: {
'params.yaml': {
code_names: [0, 1],
epochs: 2,
learning_rate: 2.2e-7,
dvc_logs_dir: 'dvc_logs',
Expand Down Expand Up @@ -196,6 +197,7 @@ const data: Row[] = [
},
params: {
'params.yaml': {
code_names: [0, 1],
epochs: 5,
learning_rate: 2.1e-7,
dvc_logs_dir: 'dvc_logs',
Expand Down Expand Up @@ -304,6 +306,7 @@ const data: Row[] = [
},
params: {
'params.yaml': {
code_names: [0, 1],
epochs: 2,
learning_rate: 2e-12,
dvc_logs_dir: 'dvc_logs',
Expand Down Expand Up @@ -410,6 +413,7 @@ const data: Row[] = [
},
params: {
'params.yaml': {
code_names: [0, 1],
epochs: 2,
learning_rate: 2e-12,
dvc_logs_dir: 'dvc_logs',
Expand Down Expand Up @@ -517,6 +521,7 @@ const data: Row[] = [
},
params: {
'params.yaml': {
code_names: [0, 1],
epochs: 2,
learning_rate: 2e-12,
dvc_logs_dir: 'dvc_logs',
Expand Down Expand Up @@ -629,6 +634,7 @@ const data: Row[] = [
},
params: {
'params.yaml': {
code_names: [0, 1],
epochs: 2,
learning_rate: 2.2e-7,
dvc_logs_dir: 'dvc_logs',
Expand Down Expand Up @@ -735,6 +741,7 @@ const data: Row[] = [
},
params: {
'params.yaml': {
code_names: [0, 1],
epochs: 2,
learning_rate: 2.2e-7,
dvc_logs_dir: 'dvc_logs',
Expand Down Expand Up @@ -842,6 +849,7 @@ const data: Row[] = [
},
params: {
'params.yaml': {
code_names: [0, 1],
epochs: 2,
learning_rate: 2.2e-7,
dvc_logs_dir: 'dvc_logs',
Expand Down Expand Up @@ -954,6 +962,7 @@ const data: Row[] = [
},
params: {
'params.yaml': {
code_names: [0, 1],
epochs: 5,
learning_rate: 2.1e-7,
dvc_logs_dir: 'dvc_logs',
Expand Down Expand Up @@ -1060,6 +1069,7 @@ const data: Row[] = [
},
params: {
'params.yaml': {
code_names: [0, 1],
epochs: 5,
learning_rate: 2.1e-7,
dvc_logs_dir: 'dvc_logs',
Expand Down Expand Up @@ -1167,6 +1177,7 @@ const data: Row[] = [
},
params: {
'params.yaml': {
code_names: [0, 1],
epochs: 5,
learning_rate: 2.1e-7,
dvc_logs_dir: 'dvc_logs',
Expand Down Expand Up @@ -1274,6 +1285,7 @@ const data: Row[] = [
},
params: {
'params.yaml': {
code_names: [0, 1],
epochs: 5,
learning_rate: 2.1e-7,
dvc_logs_dir: 'dvc_logs',
Expand Down Expand Up @@ -1381,6 +1393,7 @@ const data: Row[] = [
},
params: {
'params.yaml': {
code_names: [0, 1],
epochs: 5,
learning_rate: 2.1e-7,
dvc_logs_dir: 'dvc_logs',
Expand Down Expand Up @@ -1488,6 +1501,7 @@ const data: Row[] = [
},
params: {
'params.yaml': {
code_names: [0, 1],
epochs: 5,
learning_rate: 2.1e-7,
dvc_logs_dir: 'dvc_logs',
Expand Down Expand Up @@ -1585,6 +1599,7 @@ const data: Row[] = [
},
params: {
'params.yaml': {
code_names: [0, 1],
epochs: 5,
learning_rate: 2.1e-7,
dvc_logs_dir: 'dvc_logs',
Expand Down
2 changes: 1 addition & 1 deletion extension/src/test/suite/extension.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ suite('Extension Test Suite', () => {
msPythonInstalled: true,
msPythonUsed: false,
noCheckpoints: 0,
params: 8,
params: 9,
pythonPathUsed: false,
templates: 3,
tracked: 15,
Expand Down

0 comments on commit 12d7d52

Please sign in to comment.