Skip to content
This repository was archived by the owner on Mar 8, 2024. It is now read-only.

adds simple first views on model callbacks #51

Merged
merged 6 commits into from
Sep 13, 2022
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
15,453 changes: 15,405 additions & 48 deletions package-lock.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"d3v4": "^4.2.2",
"daisyui": "^1.14.2",
"graphql": "^15.0.0",
"i": "^0.3.7",
"monaco-editor": "^0.24.0",
"ng-intercom": "^8.0.2",
"ngx-filesize": "^2.0.16",
Expand Down
4 changes: 3 additions & 1 deletion src/app/app-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { ProjectAddComponent } from './projects/components/project-add/project-a
import { RecordIDEComponent } from './record-ide/components/record-ide.component';
import { ConfigComponent } from './config/components/config.component';
import { ModelDownloadComponent } from './model-download/pages/model-download/model-download.component';
import { ModelCallbackComponent } from './model-callbacks/components/model-callbacks.component';

const routes: Routes = [
{
Expand All @@ -28,7 +29,7 @@ const routes: Routes = [
{ path: 'notification-center', component: NotificationCenterComponent, data: { name: 'NotificationCenterComponent' } },
{ path: 'projects/new', component: ProjectNewComponent, data: { name: 'ProjectNewComponent' } },
{ path: 'config', component: ConfigComponent, data: { name: 'ConfigComponent' } },

{
path: 'projects/:projectId',
component: ProjectComponent,
Expand Down Expand Up @@ -56,6 +57,7 @@ const routes: Routes = [
path: 'knowledge-base/:knowledgeBaseId',
component: KnowledgeBaseDetailsComponent, data: { name: 'KnowledgeBaseDetailsComponent' }
},
{ path: 'model-callbacks', component: ModelCallbackComponent, data: { name: 'ModelCallbackComponent' } },
{ path: 'model-download', component: ModelDownloadComponent, data: { name: 'ModelDownloadComponent' } },
{ path: '**', component: ProjectOverviewComponent, data: { name: 'ProjectOverviewComponent' } },
//TODO: redirecting to projects overview page and errors
Expand Down
2 changes: 2 additions & 0 deletions src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { IntercomModule } from 'ng-intercom';
import { NotificationCenterModule } from './notification-center/notification-center.module';
import { RecordIDEModule } from './record-ide/record-ide.module';
import { ModelDownloadModule } from './model-download/model-download.module';
import { ModelCallbackModule } from './model-callbacks/model-callbacks.module';

@NgModule({
declarations: [AppComponent],
Expand All @@ -41,6 +42,7 @@ import { ModelDownloadModule } from './model-download/model-download.module';
ZeroShotModule,
LabelingModule,
RecordIDEModule,
ModelCallbackModule,
ModelDownloadModule,
NotificationCenterModule,
MonacoEditorModule.forRoot(),
Expand Down
34 changes: 17 additions & 17 deletions src/app/base/components/sidebar-pm/sidebar-pm.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,30 +101,30 @@ export class SidebarPmComponent implements OnInit {
})
)
.subscribe());
if(!SidebarPmComponent.initialConfigRequest) {

if (!SidebarPmComponent.initialConfigRequest) {
this.requestVersionOverview();
SidebarPmComponent.initialConfigRequest = true;
}
this.checkIfManagedVersion();
}

requestVersionOverview() {
this.versionOverview = null;
this.versionOverview = null;
this.configService
.getVersionOverview()
.pipe(first())
.subscribe((versionOverview) => {
this.versionOverview = versionOverview;
this.versionOverview.forEach((version)=> {
version.parseDate = this.parseUTC(version.lastChecked);
.getVersionOverview()
.pipe(first())
.subscribe((versionOverview) => {
this.versionOverview = versionOverview;
this.versionOverview.forEach((version) => {
version.parseDate = this.parseUTC(version.lastChecked);
});
this.versionOverview.sort((a, b) => a.service.localeCompare(b.service));
this.configService
.hasUpdates()
.pipe(first())
.subscribe((hasUpdates) => this.hasUpdates = hasUpdates);
});
this.versionOverview.sort((a, b) => a.service.localeCompare(b.service));
this.configService
.hasUpdates()
.pipe(first())
.subscribe((hasUpdates) => this.hasUpdates = hasUpdates);
});
}

onDestroy() {
Expand Down Expand Up @@ -187,11 +187,11 @@ export class SidebarPmComponent implements OnInit {
@HostListener('document:mozfullscreenchange', ['$event'])
@HostListener('document:MSFullscreenChange', ['$event'])
onEscapeClick() {
if(this.toggleClass == 'ft-minimize'){
if (this.toggleClass == 'ft-minimize') {
this.toggleClass = 'ft-maximize';
this.isFullscreen = false;
}
else{
else {
this.toggleClass = 'ft-minimize';
this.isFullscreen = true;

Expand Down
4 changes: 3 additions & 1 deletion src/app/base/enum/graphql-enums.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
export enum LabelSource {
MANUAL = "MANUAL",
WEAK_SUPERVISION = "WEAK_SUPERVISION",
INFORMATION_SOURCE = "INFORMATION_SOURCE"
INFORMATION_SOURCE = "INFORMATION_SOURCE",
MODEL_CALLBACK = "MODEL_CALLBACK",
}
export function labelSourceToString(source: LabelSource, forDisplay: boolean = true) {
if (forDisplay) {
switch (source) {
case LabelSource.MANUAL: return "Manual";
case LabelSource.WEAK_SUPERVISION: return "Weak Supervision";
case LabelSource.MODEL_CALLBACK: return "Model Callback";
case LabelSource.INFORMATION_SOURCE: return "Information Source";
default: return source;
}
Expand Down
34 changes: 34 additions & 0 deletions src/app/base/services/weak-source/weak-source-apollo.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,30 @@ export class WeakSourceApolloService {
return [query, vc];
}

getModelCallbacksOverviewData(projectId: string) {
const query = this.apollo
.watchQuery({
query: queries.GET_MODEL_CALLBACKS_OVERVIEW_DATA,
variables: {
projectId: projectId,
},
fetchPolicy: 'cache-and-network'
});
const vc = query.valueChanges.pipe(
map((result) => {
let tmp = result['data']['modelCallbacksOverviewData'];
if (!tmp) return [];
return JSON.parse(tmp).map((source) => {
source.labelSource = LabelSource.INFORMATION_SOURCE;
source.stats = this.mapInformationSourceStatsGlobal(source.stat_data);
return source;
});
})

);
return [query, vc];
}

private mapInformationSourceStatsGlobal(data) {
if (data?.length) {
return data.map((wrapper) => {
Expand Down Expand Up @@ -428,6 +452,16 @@ export class WeakSourceApolloService {
});
}

setAllModelCallbacks(projectId: string, value: boolean) {
return this.apollo.mutate({
mutation: mutations.SET_ALL_MODEL_CALLBACKS,
variables: {
projectId: projectId,
value: value
},
});
}

getModelProviderInfo() {
const query = this.apollo
.watchQuery({
Expand Down
9 changes: 9 additions & 0 deletions src/app/base/services/weak-source/weak-source-mutations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,15 @@ export const mutations = {

`,

SET_ALL_MODEL_CALLBACKS: gql`
mutation ($projectId: ID!, $value: Boolean!) {
setAllModelCallbacksSelected(projectId: $projectId, value: $value) {
ok
}
}

`,

MODEL_PROVIDER_DELETE_MODEL: gql`
mutation($modelName: String!) {
modelProviderDeleteModel(modelName: $modelName) {
Expand Down
6 changes: 6 additions & 0 deletions src/app/base/services/weak-source/weak-source-queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ export const queries = {
}
`,

GET_MODEL_CALLBACKS_OVERVIEW_DATA: gql`
query($projectId:ID!){
modelCallbacksOverviewData(projectId:$projectId)
}
`,

GET_INFORMATION_SOURCE_BY_SOURCE_ID: gql`
query ($projectId: ID!, $informationSourceId: ID!) {
informationSourceBySourceId(projectId: $projectId, informationSourceId: $informationSourceId) {
Expand Down
108 changes: 75 additions & 33 deletions src/app/data/components/data-browser/data-browser.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -347,44 +347,86 @@
</ng-template>
</div>
</div>
<div class="mt-2">Weakly supervised</div>
<div class="flex-grow min-w-0">
<div class="dropdown">
<ng-template
[ngIf]="groupItem.get('weakSupervisionLabels').controls.length == 0"
formArrayName="manualLabels"
[ngIfElse]="dropDownWS">
<ng-container
[ngTemplateOutlet]="buttonLabelsDisabled">
</ng-container>
</ng-template>
<ng-template #dropDownWS>
<kern-dropdown [dropdownOptions]="{
<div>
<div class="mt-2">Weakly supervised</div>
<div class="flex-grow min-w-0">
<div class="dropdown">
<ng-template
[ngIf]="groupItem.get('weakSupervisionLabels').controls.length == 0"
formArrayName="manualLabels"
[ngIfElse]="dropDownWS">
<ng-container
[ngTemplateOutlet]="buttonLabelsDisabled">
</ng-container>
</ng-template>
<ng-template #dropDownWS>
<kern-dropdown [dropdownOptions]="{
optionArray:groupItem.get('weakSupervisionLabels').controls,
hasCheckboxes:true,
keepDropdownOpen:true
}"
(optionClicked)="setActiveNegateGroup($event)">
</kern-dropdown>
</ng-template>
}" (optionClicked)="setActiveNegateGroup($event)">
</kern-dropdown>
</ng-template>
</div>
</div>
<div class="flex-grow min-w-0 mt-1">
<div class="flex flex-row items-center"
[formGroup]="groupItem.get('weakSupervisionConfidence')">
<span
class="label-text mr-1 font-dmMono">CONFIDENCE
BETWEEN</span><input
formControlName="lower" type="number"
class="w-12 px-2 input input-sm input-bordered"
(blur)="ensureValidConfidence(groupItem.get('weakSupervisionConfidence'))">
<span class="label-text mx-1 font-dmMono">%
AND</span>
<input formControlName="upper" type="number"
class="w-12 input input-sm input-bordered px-2"
(blur)="ensureValidConfidence(groupItem.get('weakSupervisionConfidence'))">
<span
class="label-text mx-1 font-dmMono">%</span>
</div>
</div>
</div>
<div class="flex-grow min-w-0 mt-1">
<div class="flex flex-row items-center"
[formGroup]="groupItem.get('confidence')">
<span
class="label-text mr-1 font-dmMono">CONFIDENCE
BETWEEN</span><input formControlName="lower"
type="number"
class="w-12 px-2 input input-sm input-bordered"
(blur)="ensureValidConfidence(groupItem.get('confidence'))">
<span class="label-text mx-1 font-dmMono">%
AND</span>
<input formControlName="upper" type="number"
class="w-12 input input-sm input-bordered px-2"
(blur)="ensureValidConfidence(groupItem.get('confidence'))">
<span
class="label-text mx-1 font-dmMono">%</span>
<div>
<div class="mt-2">Model callback</div>
<div class="flex-grow min-w-0">
<div class="dropdown">
<ng-template
[ngIf]="groupItem.get('modelCallbackLabels').controls.length == 0"
formArrayName="manualLabels"
[ngIfElse]="dropDownMC">
<ng-container
[ngTemplateOutlet]="buttonLabelsDisabled">
</ng-container>
</ng-template>
<ng-template #dropDownMC>
<kern-dropdown [dropdownOptions]="{
optionArray:groupItem.get('modelCallbackLabels').controls,
hasCheckboxes:true,
keepDropdownOpen:true
}" (optionClicked)="setActiveNegateGroup($event)">
</kern-dropdown>
</ng-template>
</div>
</div>
<div class="flex-grow min-w-0 mt-1">
<div class="flex flex-row items-center"
[formGroup]="groupItem.get('modelCallbackConfidence')">
<span
class="label-text mr-1 font-dmMono">CONFIDENCE
BETWEEN</span><input
formControlName="lower" type="number"
class="w-12 px-2 input input-sm input-bordered"
(blur)="ensureValidConfidence(groupItem.get('modelCallbackConfidence'))">
<span class="label-text mx-1 font-dmMono">%
AND</span>
<input formControlName="upper" type="number"
class="w-12 input input-sm input-bordered px-2"
(blur)="ensureValidConfidence(groupItem.get('modelCallbackConfidence'))">
<span
class="label-text mx-1 font-dmMono">%</span>
</div>
</div>
</div>
<div class="mt-2 font-bold">Heuristics
Expand Down
Loading