Skip to content

Commit

Permalink
Merge branch 'release/v0.4.4'
Browse files Browse the repository at this point in the history
  • Loading branch information
JulesFrancoise committed Oct 12, 2021
2 parents 900eefd + e7227d5 commit d6a36c0
Show file tree
Hide file tree
Showing 11 changed files with 68 additions and 21 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Marcelle changelog

## 0.4.4

- Various minor bugfixes

## 0.4.3

- Fixed svelte component compilation (reverted to svelte v3.39)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@marcellejs/core",
"description": "Marcelle Core API",
"version": "0.4.3",
"version": "0.4.4",
"repository": {
"type": "git",
"url": "https://github.com/marcellejs/marcelle"
Expand Down
6 changes: 2 additions & 4 deletions src/components/dataset-browser/dataset-browser.view.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,6 @@
}
});
});
</script>

<svelte:window on:keydown={handleKeydown} on:keyup={handleKeyup} />
Expand Down Expand Up @@ -250,11 +249,10 @@
.browser-class-body img {
width: 60px;
box-sizing: content-box;
@apply border-2 border-transparent rounded-md;
@apply border-solid border-2 border-transparent rounded-md;
}
.browser-class-body img.selected {
@apply border-teal-700;
@apply border-gray-600;
}
</style>
8 changes: 8 additions & 0 deletions src/components/mlp-classifier/mlp-classifier.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
import type { ServiceIterable } from '../../core/data-store/service-iterable';
import { Dataset, isDataset } from '../../core/dataset';
import { Catch, TrainingError } from '../../utils/error-handling';
import { throwError } from '../../utils/error-handling';

interface TrainingData {
training_x: Tensor2D;
Expand Down Expand Up @@ -130,6 +131,13 @@ export class MLPClassifier extends TFJSBaseModel<TensorLike, ClassifierResults>
: (this.labels = Array.from(new Set(await dataset.map(({ y }) => y).toArray())));
const ds = isDataset(dataset) ? dataset.items() : dataset;
this.$training.set({ status: 'start', epochs: this.parameters.epochs.value });
if (this.labels.length === 0) {
throwError(new TrainingError('This dataset is empty or is missing labels'));
this.$training.set({
status: 'error',
});
return;
}
setTimeout(async () => {
const data = await dataSplit(ds, 0.75, this.labels);
this.buildModel(data.training_x.shape[1], data.training_y.shape[1]);
Expand Down
11 changes: 10 additions & 1 deletion src/components/training-history/training-history.component.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Paginated, Service } from '@feathersjs/feathers';
import { logger, Model, Component, Stream, TrainingRun, TrainingStatus } from '../../core';
import { DataStore } from '../../core/data-store';
import { preventConcurrentCalls } from '../../utils/asynchronicity';
import { noop } from '../../utils/misc';
import View from './training-history.view.svelte';

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

private lock = Promise.resolve();

constructor(public dataStore: DataStore, options: TrainingHistoryOptions = {}) {
super();
this.options = { ...defaultOptions, ...options };
this.lock = this.lock.then(noop);
this.start();
this.ready = this.ready
.then(() => this.dataStore.connect())
Expand Down Expand Up @@ -71,7 +75,7 @@ export class TrainingHistory<InputType, OutputType> extends Component {
})
.then(({ data: foundRuns }) => {
if (foundRuns.length > 0) {
return parseInt(foundRuns[0].name.split(`${name}-`)[1]) + 1;
return parseInt(foundRuns[0].name.split(`${basename}-`)[1]) + 1;
}
return 1;
})
Expand All @@ -85,6 +89,7 @@ export class TrainingHistory<InputType, OutputType> extends Component {
return this;
}

@preventConcurrentCalls('lock')
protected async trackTrainingStream(x: TrainingStatus): Promise<void> {
if (x.status === 'start') {
this.crtRun = await this.runService.create({
Expand Down Expand Up @@ -119,6 +124,10 @@ export class TrainingHistory<InputType, OutputType> extends Component {
},
]),
});
} else if (x.status === 'error') {
this.runService.patch(this.crtRun.id, {
status: x.status,
});
}
}

Expand Down
6 changes: 5 additions & 1 deletion src/components/training-history/training-history.view.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@
},
});
provider.data.subscribe(() => {
selection.set([]);
});
const columns: Column[] = [
{ name: 'name', sortable: true },
{ name: 'start', sortable: true, type: 'date' },
Expand Down Expand Up @@ -82,7 +86,7 @@
{provider}
actions={[
...actions.map((name) => (typeof name === 'string' ? { name } : name)),
{ name: 'remove', confirm: true },
{ name: 'delete', confirm: true },
]}
bind:selection={$selection}
bind:this={mainTable}
Expand Down
2 changes: 1 addition & 1 deletion src/ui/components/Select.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
on:change={(e) => dispatch('change', e.target.value)}
>
{#if placeholder}
<option value="">{placeholder}</option>
<option value="" disabled>{placeholder}</option>
{/if}
{#each options as option}
<option value={option}>{option}</option>
Expand Down
9 changes: 3 additions & 6 deletions src/ui/components/Table.svelte
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script lang="ts">
import { createEventDispatcher, onMount } from 'svelte';
import { createEventDispatcher } from 'svelte';
import TableContentCell from './TableContentCell.svelte';
import TableHeaderCell from './TableHeaderCell.svelte';
import TableFooter from './TableFooter.svelte';
Expand All @@ -18,10 +18,7 @@
$: data = provider.data;
$: error = provider.error;
onMount(() => {
selected = selection.map((x) => get(data).indexOf(x));
});
$: selected = selection.map((x) => get(data).indexOf(x));
const dispatch = createEventDispatcher();
Expand Down Expand Up @@ -93,7 +90,7 @@
{#if !singleSelection}
<input
type="checkbox"
checked={selected.length === $data.length}
checked={selected.length > 0 && selected.length === $data.length}
on:click={selectAll}
/>
{/if}
Expand Down
39 changes: 32 additions & 7 deletions src/ui/components/TableFooter.svelte
Original file line number Diff line number Diff line change
@@ -1,23 +1,48 @@
<script lang="ts">
import type { Action } from './table-types';
import { get } from 'svelte/store';
import Button from './Button.svelte';
import Select from './Select.svelte';
import { TableDataProvider } from './table-abstract-provider';
import TableActions from './TableActions.svelte';
import { noop } from '../../utils/misc';
export let provider: TableDataProvider;
export let actions: Action[];
export let selected: number[];
$: total = provider.total;
// $: total = provider.total;
$: itemsPerPage = provider.options.itemsPerPage;
let page = 1;
let numPages = 1;
let start = 0;
let end = 0;
let total = 0;
let unsub = noop;
$: numPages = Math.ceil($total / itemsPerPage);
$: start = (page - 1) * itemsPerPage + 1;
$: end = Math.min($total, page * itemsPerPage);
$: {
unsub();
unsub = provider.total.subscribe((t) => {
if (t === undefined || t === 0) {
numPages = 1;
start = 0;
end = 0;
total = 0;
} else {
numPages = Math.ceil(total / itemsPerPage);
start = (page - 1) * itemsPerPage + 1;
end = Math.min(total || 0, page * itemsPerPage);
total = t;
}
});
}
// $: console.log('provider', provider);
// $: console.log('total', total);
// $: console.log('$total', $total);
// $: numPages = $total ? Math.ceil($total / itemsPerPage) : 1;
// $: start = $total ? (page - 1) * itemsPerPage + 1 : 0;
// $: end = Math.min($total || 0, page * itemsPerPage);
function gotoPage(i: number): void {
page = i;
Expand All @@ -41,15 +66,15 @@
options={['10', '20', '50', 'all']}
value={itemsPerPage.toString()}
on:change={({ detail }) => {
const n = detail === 'all' ? get(total) : parseInt(detail);
const n = detail === 'all' ? total : parseInt(detail);
provider.paginate(n);
itemsPerPage = n;
}}
/>
</div>
</div>
<div class="mx-3">
{start}-{end} of {$total}
{start}-{end} of {total}
</div>
<Button
round
Expand Down
1 change: 1 addition & 0 deletions src/ui/components/table-array-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export class TableArrayProvider<T extends Record<string, unknown>> extends Table
constructor({ data, ...options }: TableProviderOptions & { data: Array<T> }) {
super(options);
this.rawData = data;
this.total.set(data.length);
this.data.set(this.rawData.slice(0, this.options.itemsPerPage));
}

Expand Down
1 change: 1 addition & 0 deletions src/ui/components/table-service-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export class TableServiceProvider<
});
this.data.set(data);
this.total.set(res.total);
console.log('res.total', res.total);
this.error.set(null);
} catch (error) {
this.data.set([]);
Expand Down

0 comments on commit d6a36c0

Please sign in to comment.