Unverified Commit 521f1917 authored by liuzhe-lz's avatar liuzhe-lz Committed by GitHub
Browse files

Fix a logging related bug (#3705)

parent b7c91e73
...@@ -18,7 +18,7 @@ type SCHEDULE_POLICY_NAME = 'random' | 'round-robin'; ...@@ -18,7 +18,7 @@ type SCHEDULE_POLICY_NAME = 'random' | 'round-robin';
export class GPUScheduler { export class GPUScheduler {
private readonly machineExecutorMap: Map<RemoteMachineConfig, ExecutorManager>; private readonly machineExecutorMap: Map<RemoteMachineConfig, ExecutorManager>;
private readonly log: Logger = getLogger(); private readonly log: Logger = getLogger('GPUScheduler');
private readonly policyName: SCHEDULE_POLICY_NAME = 'round-robin'; private readonly policyName: SCHEDULE_POLICY_NAME = 'round-robin';
private roundRobinIndex: number = 0; private roundRobinIndex: number = 0;
private configuredRMs: RemoteMachineMeta[] = []; private configuredRMs: RemoteMachineMeta[] = [];
......
...@@ -67,7 +67,7 @@ class RemoteMachineTrainingService implements TrainingService { ...@@ -67,7 +67,7 @@ class RemoteMachineTrainingService implements TrainingService {
this.sshConnectionPromises = []; this.sshConnectionPromises = [];
this.expRootDir = getExperimentRootDir(); this.expRootDir = getExperimentRootDir();
this.timer = component.get(ObservableTimer); this.timer = component.get(ObservableTimer);
this.log = getLogger(); this.log = getLogger('RemoteMachineTrainingService');
this.log.info('Construct remote machine training service.'); this.log.info('Construct remote machine training service.');
this.config = flattenConfig(config, 'remote'); this.config = flattenConfig(config, 'remote');
......
...@@ -36,7 +36,7 @@ class ShellExecutor { ...@@ -36,7 +36,7 @@ class ShellExecutor {
public isWindows: boolean = false; public isWindows: boolean = false;
constructor() { constructor() {
this.log = getLogger(); this.log = getLogger('ShellExecutor');
this.sshClient = new Client(); this.sshClient = new Client();
} }
......
...@@ -61,7 +61,7 @@ export class WebCommandChannel extends CommandChannel { ...@@ -61,7 +61,7 @@ export class WebCommandChannel extends CommandChannel {
this.webSocketServer.on('connection', (client: WebSocket) => { this.webSocketServer.on('connection', (client: WebSocket) => {
this.log.debug(`WebCommandChannel: received connection`); this.log.debug(`WebCommandChannel: received connection`);
client.onerror = (event): void => { client.onerror = (event): void => {
this.log.error(`error on client ${JSON.stringify(event)}`); this.log.error('error on client', event);
} }
this.clients.set(client, undefined); this.clients.set(client, undefined);
...@@ -109,7 +109,7 @@ export class WebCommandChannel extends CommandChannel { ...@@ -109,7 +109,7 @@ export class WebCommandChannel extends CommandChannel {
// undefined means it's expecting initializing message. // undefined means it's expecting initializing message.
const commands = this.parseCommands(rawCommands); const commands = this.parseCommands(rawCommands);
let isValid = false; let isValid = false;
this.log.debug(`WebCommandChannel: received initialize message: ${JSON.stringify(rawCommands)}`); this.log.debug('WebCommandChannel: received initialize message:', rawCommands);
if (commands.length > 0) { if (commands.length > 0) {
const commandType = commands[0][0]; const commandType = commands[0][0];
......
...@@ -50,7 +50,7 @@ export abstract class CommandChannel { ...@@ -50,7 +50,7 @@ export abstract class CommandChannel {
private readonly commandPattern: RegExp = /(?<type>[\w]{2})(?<length>[\d]{14})(?<data>.*)\n?/gm; private readonly commandPattern: RegExp = /(?<type>[\w]{2})(?<length>[\d]{14})(?<data>.*)\n?/gm;
public constructor(commandEmitter: EventEmitter) { public constructor(commandEmitter: EventEmitter) {
this.log = getLogger(); this.log = getLogger('CommandChannel');
this.commandEmitter = commandEmitter; this.commandEmitter = commandEmitter;
} }
......
...@@ -82,7 +82,7 @@ export class EnvironmentInformation { ...@@ -82,7 +82,7 @@ export class EnvironmentInformation {
public useSharedStorage?: boolean; public useSharedStorage?: boolean;
constructor(id: string, name: string, envId?: string) { constructor(id: string, name: string, envId?: string) {
this.log = getLogger(); this.log = getLogger('EnvironmentInformation');
this.id = id; this.id = id;
this.name = name; this.name = name;
this.envId = envId ? envId : name; this.envId = envId ? envId : name;
...@@ -116,7 +116,7 @@ export class EnvironmentInformation { ...@@ -116,7 +116,7 @@ export class EnvironmentInformation {
const gpuSummary = this.gpuSummaries.get(this.defaultNodeId); const gpuSummary = this.gpuSummaries.get(this.defaultNodeId);
if (gpuSummary === undefined) { if (gpuSummary === undefined) {
if (false === this.isNoGpuWarned) { if (false === this.isNoGpuWarned) {
this.log.warning(`EnvironmentInformation: ${this.envId} no default gpu found. current gpu info ${JSON.stringify(this.gpuSummaries)}`); this.log.warning(`EnvironmentInformation: ${this.envId} no default gpu found. current gpu info`, this.gpuSummaries);
this.isNoGpuWarned = true; this.isNoGpuWarned = true;
} }
} else { } else {
......
...@@ -24,7 +24,7 @@ interface FlattenAmlConfig extends ExperimentConfig, AmlConfig { } ...@@ -24,7 +24,7 @@ interface FlattenAmlConfig extends ExperimentConfig, AmlConfig { }
@component.Singleton @component.Singleton
export class AMLEnvironmentService extends EnvironmentService { export class AMLEnvironmentService extends EnvironmentService {
private readonly log: Logger = getLogger(); private readonly log: Logger = getLogger('AMLEnvironmentService');
private experimentId: string; private experimentId: string;
private experimentRootDir: string; private experimentRootDir: string;
private config: FlattenAmlConfig; private config: FlattenAmlConfig;
......
...@@ -17,7 +17,7 @@ import { SharedStorageService } from '../sharedStorage' ...@@ -17,7 +17,7 @@ import { SharedStorageService } from '../sharedStorage'
@component.Singleton @component.Singleton
export class LocalEnvironmentService extends EnvironmentService { export class LocalEnvironmentService extends EnvironmentService {
private readonly log: Logger = getLogger(); private readonly log: Logger = getLogger('LocalEnvironmentService');
private experimentRootDir: string; private experimentRootDir: string;
private experimentId: string; private experimentId: string;
......
...@@ -23,7 +23,7 @@ interface FlattenOpenpaiConfig extends ExperimentConfig, OpenpaiConfig { } ...@@ -23,7 +23,7 @@ interface FlattenOpenpaiConfig extends ExperimentConfig, OpenpaiConfig { }
@component.Singleton @component.Singleton
export class OpenPaiEnvironmentService extends EnvironmentService { export class OpenPaiEnvironmentService extends EnvironmentService {
private readonly log: Logger = getLogger(); private readonly log: Logger = getLogger('OpenPaiEnvironmentService');
private paiClusterConfig: PAIClusterConfig | undefined; private paiClusterConfig: PAIClusterConfig | undefined;
private paiTrialConfig: NNIPAITrialConfig | undefined; private paiTrialConfig: NNIPAITrialConfig | undefined;
private paiToken: string; private paiToken: string;
...@@ -77,7 +77,7 @@ export class OpenPaiEnvironmentService extends EnvironmentService { ...@@ -77,7 +77,7 @@ export class OpenPaiEnvironmentService extends EnvironmentService {
// Status code 200 for success // Status code 200 for success
if ((error !== undefined && error !== null) || response.statusCode >= 400) { if ((error !== undefined && error !== null) || response.statusCode >= 400) {
const errorMessage: string = (error !== undefined && error !== null) ? error.message : const errorMessage: string = (error !== undefined && error !== null) ? error.message :
`OpenPAI: get environment list from PAI Cluster failed!, http code:${response.statusCode}, http body: ${JSON.stringify(body)}`; `OpenPAI: get environment list from PAI Cluster failed!, http code:${response.statusCode}, http body:' ${JSON.stringify(body)}`;
this.log.error(`${errorMessage}`); this.log.error(`${errorMessage}`);
deferred.reject(errorMessage); deferred.reject(errorMessage);
} else { } else {
...@@ -113,7 +113,7 @@ export class OpenPaiEnvironmentService extends EnvironmentService { ...@@ -113,7 +113,7 @@ export class OpenPaiEnvironmentService extends EnvironmentService {
this.log.debug(`OpenPAI: job ${environment.envId} change status ${oldEnvironmentStatus} to ${environment.status} due to job is ${jobResponse.state}.`) this.log.debug(`OpenPAI: job ${environment.envId} change status ${oldEnvironmentStatus} to ${environment.status} due to job is ${jobResponse.state}.`)
} }
} else { } else {
this.log.error(`OpenPAI: job ${environment.envId} has no state returned. body:${JSON.stringify(jobResponse)}`); this.log.error(`OpenPAI: job ${environment.envId} has no state returned. body:`, jobResponse);
// some error happens, and mark this environment // some error happens, and mark this environment
environment.status = 'FAILED'; environment.status = 'FAILED';
} }
......
...@@ -39,7 +39,7 @@ export class RemoteEnvironmentService extends EnvironmentService { ...@@ -39,7 +39,7 @@ export class RemoteEnvironmentService extends EnvironmentService {
this.machineExecutorManagerMap = new Map<RemoteMachineConfig, ExecutorManager>(); this.machineExecutorManagerMap = new Map<RemoteMachineConfig, ExecutorManager>();
this.remoteMachineMetaOccupiedMap = new Map<RemoteMachineConfig, boolean>(); this.remoteMachineMetaOccupiedMap = new Map<RemoteMachineConfig, boolean>();
this.experimentRootDir = experimentRootDir; this.experimentRootDir = experimentRootDir;
this.log = getLogger(); this.log = getLogger('RemoteEnvironmentService');
this.config = flattenConfig(config, 'remote'); this.config = flattenConfig(config, 'remote');
// codeDir is not a valid directory, throw Error // codeDir is not a valid directory, throw Error
......
...@@ -29,7 +29,7 @@ export type GpuScheduleResult = { ...@@ -29,7 +29,7 @@ export type GpuScheduleResult = {
export class GpuScheduler { export class GpuScheduler {
// private readonly machineExecutorMap: Set<TrialDetail>; // private readonly machineExecutorMap: Set<TrialDetail>;
private readonly log: Logger = getLogger(); private readonly log: Logger = getLogger('GpuScheduler');
private readonly policyName: SCHEDULE_POLICY_NAME = 'recently-idle'; private readonly policyName: SCHEDULE_POLICY_NAME = 'recently-idle';
private defaultSetting: GpuSchedulerSetting; private defaultSetting: GpuSchedulerSetting;
private roundRobinIndex: number = 0; private roundRobinIndex: number = 0;
......
...@@ -66,7 +66,7 @@ export class AzureBlobSharedStorageService extends SharedStorageService { ...@@ -66,7 +66,7 @@ export class AzureBlobSharedStorageService extends SharedStorageService {
constructor() { constructor() {
super(); super();
this.log = getLogger(); this.log = getLogger('AzureBlobSharedStorageService');
this.internalStorageService = new MountedStorageService(); this.internalStorageService = new MountedStorageService();
this.experimentId = getExperimentId(); this.experimentId = getExperimentId();
} }
......
...@@ -50,7 +50,7 @@ export class NFSSharedStorageService extends SharedStorageService { ...@@ -50,7 +50,7 @@ export class NFSSharedStorageService extends SharedStorageService {
constructor() { constructor() {
super(); super();
this.log = getLogger(); this.log = getLogger('NFSSharedStorageService');
this.internalStorageService = new MountedStorageService(); this.internalStorageService = new MountedStorageService();
this.experimentId = getExperimentId(); this.experimentId = getExperimentId();
} }
......
...@@ -30,7 +30,7 @@ export abstract class StorageService { ...@@ -30,7 +30,7 @@ export abstract class StorageService {
protected abstract internalBasename(...paths: string[]): string; protected abstract internalBasename(...paths: string[]): string;
constructor() { constructor() {
this.logger = getLogger(); this.logger = getLogger('StorageService');
} }
public initialize(localRoot: string, remoteRoot: string): void { public initialize(localRoot: string, remoteRoot: string): void {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment