Skip to content

Commit

Permalink
Switch ExperimentsParamsAndMetricsTree to string | ParamsAndMetrics…
Browse files Browse the repository at this point in the history
…Item tree type (#700)

* move params and metrics tree to mixed type

* remove get param or metric methods where possible

* rework tree data type

* improve test

* improve test variable names
  • Loading branch information
mattseddon authored Aug 3, 2021
1 parent bf1b90a commit 5ba2e56
Show file tree
Hide file tree
Showing 7 changed files with 360 additions and 313 deletions.
4 changes: 0 additions & 4 deletions extension/src/experiments/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,6 @@ export class Experiments {
return Object.keys(this.experiments)
}

public getParamOrMetric(dvcRoot: string, path: string) {
return this.getRepository(dvcRoot).getParamOrMetric(path)
}

public getChildParamsOrMetrics(dvcRoot: string, path: string) {
return this.getRepository(dvcRoot).getChildParamsOrMetrics(path)
}
Expand Down
35 changes: 17 additions & 18 deletions extension/src/experiments/paramsAndMetrics/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,25 +45,20 @@ export class ParamsAndMetricsModel {
return this.data.filter(paramOrMetric => !paramOrMetric.hasChildren)
}

public getParamOrMetric(path: string) {
const paramOrMetric = this.data?.find(
paramOrMetric => paramOrMetric.path === path
)
if (paramOrMetric) {
return {
...paramOrMetric,
descendantStatuses: this.getDescendantsStatuses(paramOrMetric.path),
status: this.status[paramOrMetric.path]
}
}
}

public getChildren(path: string) {
return this.data?.filter(paramOrMetric =>
path
? paramOrMetric.parentPath === path
: ['metrics', 'params'].includes(paramOrMetric.parentPath)
)
return this.data
?.filter(paramOrMetric =>
path
? paramOrMetric.parentPath === path
: ['metrics', 'params'].includes(paramOrMetric.parentPath)
)
.map(paramOrMetric => {
return {
...paramOrMetric,
descendantStatuses: this.getDescendantsStatuses(paramOrMetric.path),
status: this.status[paramOrMetric.path]
}
})
}

public toggleStatus(path: string) {
Expand All @@ -90,6 +85,10 @@ export class ParamsAndMetricsModel {
})
}

private getParamOrMetric(path: string) {
return this.data?.find(paramOrMetric => paramOrMetric.path === path)
}

private setAreParentsSelected(path: string) {
const changed = this.getParamOrMetric(path)
if (!changed) {
Expand Down
Loading

0 comments on commit 5ba2e56

Please sign in to comment.