// Copyright (c) Microsoft Corporation. // Licensed under the MIT license. 'use strict'; import { ExperimentProfile, TrialJobStatistics } from './manager'; import { TrialJobDetail, TrialJobStatus } from './trainingService'; type TrialJobEvent = TrialJobStatus | 'USER_TO_CANCEL' | 'ADD_CUSTOMIZED' | 'ADD_HYPERPARAMETER' | 'IMPORT_DATA'; type MetricType = 'PERIODICAL' | 'FINAL' | 'CUSTOM' | 'REQUEST_PARAMETER'; interface ExperimentProfileRecord { readonly timestamp: number; readonly experimentId: number; readonly revision: number; readonly data: ExperimentProfile; } interface TrialJobEventRecord { readonly timestamp: number; readonly trialJobId: string; readonly event: TrialJobEvent; readonly data?: string; readonly logPath?: string; readonly sequenceId?: number; } interface MetricData { readonly parameter_id: string; readonly trial_job_id: string; readonly type: MetricType; readonly sequence: number; readonly value: any; } interface MetricDataRecord { readonly timestamp: number; readonly trialJobId: string; readonly parameterId: string; readonly type: MetricType; readonly sequence: number; readonly data: any; } interface TrialJobInfo { id: string; sequenceId?: number; status: TrialJobStatus; startTime?: number; endTime?: number; hyperParameters?: string[]; logPath?: string; finalMetricData?: MetricDataRecord[]; stderrPath?: string; } interface HyperParameterFormat { parameter_source: string; parameters: Object; parameter_id: number; } interface ExportedDataFormat { parameter: Object; value: Object; id: string; } abstract class DataStore { public abstract init(): Promise; public abstract close(): Promise; public abstract storeExperimentProfile(experimentProfile: ExperimentProfile): Promise; public abstract getExperimentProfile(experimentId: string): Promise; public abstract storeTrialJobEvent( event: TrialJobEvent, trialJobId: string, hyperParameter?: string, jobDetail?: TrialJobDetail): Promise; public abstract getTrialJobStatistics(): Promise; public abstract listTrialJobs(status?: TrialJobStatus): Promise; public abstract getTrialJob(trialJobId: string): Promise; public abstract storeMetricData(trialJobId: string, data: string): Promise; public abstract getMetricData(trialJobId?: string, metricType?: MetricType): Promise; public abstract exportTrialHpConfigs(): Promise; public abstract getImportedData(): Promise; } abstract class Database { public abstract init(createNew: boolean, dbDir: string): Promise; public abstract close(): Promise; public abstract storeExperimentProfile(experimentProfile: ExperimentProfile): Promise; public abstract queryExperimentProfile(experimentId: string, revision?: number): Promise; public abstract queryLatestExperimentProfile(experimentId: string): Promise; public abstract storeTrialJobEvent( event: TrialJobEvent, trialJobId: string, timestamp: number, hyperParameter?: string, jobDetail?: TrialJobDetail): Promise; public abstract queryTrialJobEvent(trialJobId?: string, event?: TrialJobEvent): Promise; public abstract storeMetricData(trialJobId: string, data: string): Promise; public abstract queryMetricData(trialJobId?: string, type?: MetricType): Promise; } export { DataStore, Database, TrialJobEvent, MetricType, MetricData, TrialJobInfo, ExperimentProfileRecord, TrialJobEventRecord, MetricDataRecord, HyperParameterFormat, ExportedDataFormat };