paiConfig.ts 2.24 KB
Newer Older
liuzhe-lz's avatar
liuzhe-lz committed
1
2
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
3
4
5

'use strict';

6
import { TrialJobApplicationForm, TrialJobDetail, TrialJobStatus } from '../../common/trainingService';
7
8
9

export class PAIClusterConfig {
    public readonly userName: string;
10
    public readonly passWord?: string;
SparkSnail's avatar
SparkSnail committed
11
    public host: string;
12
    public readonly token?: string;
13
    public readonly reuse?: boolean;
14

15
16
17
18
19
20
21
    public cpuNum?: number;
    public memoryMB?: number;
    public gpuNum?: number;

    public useActiveGpu?: boolean;
    public maxTrialNumPerGpu?: number;

22
23
24
25
26
    /**
     * Constructor
     * @param userName User name of PAI Cluster
     * @param passWord password of PAI Cluster
     * @param host Host IP of PAI Cluster
27
     * @param token PAI token of PAI Cluster
28
     * @param reuse If job is reusable for multiple trials
29
     */
30
31
    constructor(userName: string, host: string, passWord?: string, token?: string, reuse?: boolean,
        cpuNum?: number, memoryMB?: number, gpuNum?: number) {
32
33
34
        this.userName = userName;
        this.passWord = passWord;
        this.host = host;
35
        this.token = token;
36
        this.reuse = reuse;
37
38
39
        this.cpuNum = cpuNum;
        this.memoryMB = memoryMB;
        this.gpuNum = gpuNum;
40
41
42
    }
}

43
/**
44
 * PAI trial job detail
45
 */
46
47
48
49
50
51
52
53
54
55
56
57
58
export class PAITrialJobDetail implements TrialJobDetail {
    public id: string;
    public status: TrialJobStatus;
    public paiJobName: string;
    public submitTime: number;
    public startTime?: number;
    public endTime?: number;
    public tags?: string[];
    public url?: string;
    public workingDirectory: string;
    public form: TrialJobApplicationForm;
    public logPath: string;
    public isEarlyStopped?: boolean;
SparkSnail's avatar
SparkSnail committed
59
    public paiJobDetailUrl?: string;
60
61

    constructor(id: string, status: TrialJobStatus, paiJobName: string,
SparkSnail's avatar
SparkSnail committed
62
                submitTime: number, workingDirectory: string, form: TrialJobApplicationForm, logPath: string, paiJobDetailUrl?: string) {
63
64
65
66
67
68
69
70
        this.id = id;
        this.status = status;
        this.paiJobName = paiJobName;
        this.submitTime = submitTime;
        this.workingDirectory = workingDirectory;
        this.form = form;
        this.tags = [];
        this.logPath = logPath;
SparkSnail's avatar
SparkSnail committed
71
        this.paiJobDetailUrl = paiJobDetailUrl;
72
    }
73
}