Skip to content

Commit d6a36c0

Browse files
Merge branch 'release/v0.4.4'
2 parents 900eefd + e7227d5 commit d6a36c0

File tree

11 files changed

+68
-21
lines changed

11 files changed

+68
-21
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Marcelle changelog
22

3+
## 0.4.4
4+
5+
- Various minor bugfixes
6+
37
## 0.4.3
48

59
- Fixed svelte component compilation (reverted to svelte v3.39)

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@marcellejs/core",
33
"description": "Marcelle Core API",
4-
"version": "0.4.3",
4+
"version": "0.4.4",
55
"repository": {
66
"type": "git",
77
"url": "https://github.com/marcellejs/marcelle"

src/components/dataset-browser/dataset-browser.view.svelte

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,6 @@
171171
}
172172
});
173173
});
174-
175174
</script>
176175

177176
<svelte:window on:keydown={handleKeydown} on:keyup={handleKeyup} />
@@ -250,11 +249,10 @@
250249
.browser-class-body img {
251250
width: 60px;
252251
box-sizing: content-box;
253-
@apply border-2 border-transparent rounded-md;
252+
@apply border-solid border-2 border-transparent rounded-md;
254253
}
255254
256255
.browser-class-body img.selected {
257-
@apply border-teal-700;
256+
@apply border-gray-600;
258257
}
259-
260258
</style>

src/components/mlp-classifier/mlp-classifier.component.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import {
2020
import type { ServiceIterable } from '../../core/data-store/service-iterable';
2121
import { Dataset, isDataset } from '../../core/dataset';
2222
import { Catch, TrainingError } from '../../utils/error-handling';
23+
import { throwError } from '../../utils/error-handling';
2324

2425
interface TrainingData {
2526
training_x: Tensor2D;
@@ -130,6 +131,13 @@ export class MLPClassifier extends TFJSBaseModel<TensorLike, ClassifierResults>
130131
: (this.labels = Array.from(new Set(await dataset.map(({ y }) => y).toArray())));
131132
const ds = isDataset(dataset) ? dataset.items() : dataset;
132133
this.$training.set({ status: 'start', epochs: this.parameters.epochs.value });
134+
if (this.labels.length === 0) {
135+
throwError(new TrainingError('This dataset is empty or is missing labels'));
136+
this.$training.set({
137+
status: 'error',
138+
});
139+
return;
140+
}
133141
setTimeout(async () => {
134142
const data = await dataSplit(ds, 0.75, this.labels);
135143
this.buildModel(data.training_x.shape[1], data.training_y.shape[1]);

src/components/training-history/training-history.component.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { Paginated, Service } from '@feathersjs/feathers';
22
import { logger, Model, Component, Stream, TrainingRun, TrainingStatus } from '../../core';
33
import { DataStore } from '../../core/data-store';
4+
import { preventConcurrentCalls } from '../../utils/asynchronicity';
45
import { noop } from '../../utils/misc';
56
import View from './training-history.view.svelte';
67

@@ -38,9 +39,12 @@ export class TrainingHistory<InputType, OutputType> extends Component {
3839
protected modelName: string;
3940
protected nextIndex: number;
4041

42+
private lock = Promise.resolve();
43+
4144
constructor(public dataStore: DataStore, options: TrainingHistoryOptions = {}) {
4245
super();
4346
this.options = { ...defaultOptions, ...options };
47+
this.lock = this.lock.then(noop);
4448
this.start();
4549
this.ready = this.ready
4650
.then(() => this.dataStore.connect())
@@ -71,7 +75,7 @@ export class TrainingHistory<InputType, OutputType> extends Component {
7175
})
7276
.then(({ data: foundRuns }) => {
7377
if (foundRuns.length > 0) {
74-
return parseInt(foundRuns[0].name.split(`${name}-`)[1]) + 1;
78+
return parseInt(foundRuns[0].name.split(`${basename}-`)[1]) + 1;
7579
}
7680
return 1;
7781
})
@@ -85,6 +89,7 @@ export class TrainingHistory<InputType, OutputType> extends Component {
8589
return this;
8690
}
8791

92+
@preventConcurrentCalls('lock')
8893
protected async trackTrainingStream(x: TrainingStatus): Promise<void> {
8994
if (x.status === 'start') {
9095
this.crtRun = await this.runService.create({
@@ -119,6 +124,10 @@ export class TrainingHistory<InputType, OutputType> extends Component {
119124
},
120125
]),
121126
});
127+
} else if (x.status === 'error') {
128+
this.runService.patch(this.crtRun.id, {
129+
status: x.status,
130+
});
122131
}
123132
}
124133

src/components/training-history/training-history.view.svelte

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@
4747
},
4848
});
4949
50+
provider.data.subscribe(() => {
51+
selection.set([]);
52+
});
53+
5054
const columns: Column[] = [
5155
{ name: 'name', sortable: true },
5256
{ name: 'start', sortable: true, type: 'date' },
@@ -82,7 +86,7 @@
8286
{provider}
8387
actions={[
8488
...actions.map((name) => (typeof name === 'string' ? { name } : name)),
85-
{ name: 'remove', confirm: true },
89+
{ name: 'delete', confirm: true },
8690
]}
8791
bind:selection={$selection}
8892
bind:this={mainTable}

src/ui/components/Select.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
on:change={(e) => dispatch('change', e.target.value)}
1818
>
1919
{#if placeholder}
20-
<option value="">{placeholder}</option>
20+
<option value="" disabled>{placeholder}</option>
2121
{/if}
2222
{#each options as option}
2323
<option value={option}>{option}</option>

src/ui/components/Table.svelte

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<script lang="ts">
2-
import { createEventDispatcher, onMount } from 'svelte';
2+
import { createEventDispatcher } from 'svelte';
33
import TableContentCell from './TableContentCell.svelte';
44
import TableHeaderCell from './TableHeaderCell.svelte';
55
import TableFooter from './TableFooter.svelte';
@@ -18,10 +18,7 @@
1818
1919
$: data = provider.data;
2020
$: error = provider.error;
21-
22-
onMount(() => {
23-
selected = selection.map((x) => get(data).indexOf(x));
24-
});
21+
$: selected = selection.map((x) => get(data).indexOf(x));
2522
2623
const dispatch = createEventDispatcher();
2724
@@ -93,7 +90,7 @@
9390
{#if !singleSelection}
9491
<input
9592
type="checkbox"
96-
checked={selected.length === $data.length}
93+
checked={selected.length > 0 && selected.length === $data.length}
9794
on:click={selectAll}
9895
/>
9996
{/if}

src/ui/components/TableFooter.svelte

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,48 @@
11
<script lang="ts">
22
import type { Action } from './table-types';
3-
import { get } from 'svelte/store';
43
import Button from './Button.svelte';
54
import Select from './Select.svelte';
65
import { TableDataProvider } from './table-abstract-provider';
76
import TableActions from './TableActions.svelte';
7+
import { noop } from '../../utils/misc';
88
99
export let provider: TableDataProvider;
1010
export let actions: Action[];
1111
export let selected: number[];
1212
13-
$: total = provider.total;
13+
// $: total = provider.total;
1414
$: itemsPerPage = provider.options.itemsPerPage;
1515
1616
let page = 1;
17+
let numPages = 1;
18+
let start = 0;
19+
let end = 0;
20+
let total = 0;
21+
let unsub = noop;
1722
18-
$: numPages = Math.ceil($total / itemsPerPage);
19-
$: start = (page - 1) * itemsPerPage + 1;
20-
$: end = Math.min($total, page * itemsPerPage);
23+
$: {
24+
unsub();
25+
unsub = provider.total.subscribe((t) => {
26+
if (t === undefined || t === 0) {
27+
numPages = 1;
28+
start = 0;
29+
end = 0;
30+
total = 0;
31+
} else {
32+
numPages = Math.ceil(total / itemsPerPage);
33+
start = (page - 1) * itemsPerPage + 1;
34+
end = Math.min(total || 0, page * itemsPerPage);
35+
total = t;
36+
}
37+
});
38+
}
39+
40+
// $: console.log('provider', provider);
41+
// $: console.log('total', total);
42+
// $: console.log('$total', $total);
43+
// $: numPages = $total ? Math.ceil($total / itemsPerPage) : 1;
44+
// $: start = $total ? (page - 1) * itemsPerPage + 1 : 0;
45+
// $: end = Math.min($total || 0, page * itemsPerPage);
2146
2247
function gotoPage(i: number): void {
2348
page = i;
@@ -41,15 +66,15 @@
4166
options={['10', '20', '50', 'all']}
4267
value={itemsPerPage.toString()}
4368
on:change={({ detail }) => {
44-
const n = detail === 'all' ? get(total) : parseInt(detail);
69+
const n = detail === 'all' ? total : parseInt(detail);
4570
provider.paginate(n);
4671
itemsPerPage = n;
4772
}}
4873
/>
4974
</div>
5075
</div>
5176
<div class="mx-3">
52-
{start}-{end} of {$total}
77+
{start}-{end} of {total}
5378
</div>
5479
<Button
5580
round

src/ui/components/table-array-provider.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export class TableArrayProvider<T extends Record<string, unknown>> extends Table
77
constructor({ data, ...options }: TableProviderOptions & { data: Array<T> }) {
88
super(options);
99
this.rawData = data;
10+
this.total.set(data.length);
1011
this.data.set(this.rawData.slice(0, this.options.itemsPerPage));
1112
}
1213

0 commit comments

Comments
 (0)