Repository: microsoft/nni
File: ts/webui/src/static/model/experiment.ts (TypeScript)

Code before:
            })
            .catch(error => {
                this.isexperimentError = true;
                this.experimentErrorMessage = `${error.message}`;
                updated = true;
            });

        await requestAxios(`${MANAGER_IP}/check-status`)
            .then(data => {
                updated = JSON.stringify(this.statusField) !== JSON.stringify(data);
                this.statusField = data;
            })
            .catch(error => {
                this.isStatusError = true;
                this.statusErrorMessage = `${error.message}`;
                updated = true;
            });

        return updated;
    }

    get profile(): ExperimentProfile {
        return this.profileField === undefined ? emptyProfile : this.profileField;
    }

    get metadata(): any {
        return this.metadataField === undefined ? emptyMetadata : this.metadataField;
    }

    get config(): ExperimentConfig {
        return this.profile.params;
    }

    get maxExperimentDurationSeconds(): number {
        const value = this.config.maxExperimentDuration || (this.config as any).maxExecDuration;
        return value === undefined ? Infinity : toSeconds(value);
    }

    get maxTrialNumber(): number {
        const value = this.config.maxTrialNumber || (this.config as any).maxTrialNum;
        return value === undefined ? Infinity : value;
    }

    get trialConcurrency(): number {
        return this.config.trialConcurrency;
    }

    get optimizeMode(): string {
        for (const algo of [this.config.tuner, this.config.advisor, this.config.assessor]) {
            if (algo && algo.classArgs && algo.classArgs['optimize_mode']) {
                return algo.classArgs['optimize_mode'];

Review comment (suggestion):
maybe `ExperimentMetadata | undefined` is better than `any`

Code after:
                }
            })
            .catch(error => {
                this.isexperimentError = true;
                this.experimentErrorMessage = `${error.message}`;
                updated = true;
            });

        await requestAxios(`${MANAGER_IP}/check-status`)
            .then(data => {
                updated = JSON.stringify(this.statusField) !== JSON.stringify(data);
                this.statusField = data;
            })
            .catch(error => {
                this.isStatusError = true;
                this.statusErrorMessage = `${error.message}`;
                updated = true;
            });

        return updated;
    }

    get profile(): ExperimentProfile {
        return this.profileField === undefined ? emptyProfile : this.profileField;
    }

    get metadata(): ExperimentMetadata {
        return this.metadataField === undefined ? emptyMetadata : this.metadataField;
    }

    get config(): ExperimentConfig {
        return this.profile.params;
    }

    get maxExperimentDurationSeconds(): number {
        const value = this.config.maxExperimentDuration || (this.config as any).maxExecDuration;
        return value === undefined ? Infinity : toSeconds(value);
    }

    get maxTrialNumber(): number {
        const value = this.config.maxTrialNumber || (this.config as any).maxTrialNum;
        return value === undefined ? Infinity : value;
    }

    get trialConcurrency(): number {
        return this.config.trialConcurrency;
    }

    get optimizeMode(): string {
        for (const algo of [this.config.tuner, this.config.advisor, this.config.assessor]) {
            if (algo && algo.classArgs && algo.classArgs['optimize_mode']) {