Unverified Commit f0a2d396 authored by SparkSnail's avatar SparkSnail Committed by GitHub
Browse files

Merge pull request #150 from Microsoft/master

merge master
parents 080ae00d 0330333c
......@@ -8,8 +8,8 @@ const TabPane = Tabs.TabPane;
interface OpenRowProps {
trainingPlatform: string;
showLogModalOverview: Function;
record: TableObj;
logCollection: boolean;
}
class OpenRow extends React.Component<OpenRowProps, {}> {
......@@ -20,7 +20,7 @@ class OpenRow extends React.Component<OpenRowProps, {}> {
}
render() {
const { trainingPlatform, record, showLogModalOverview } = this.props;
const { trainingPlatform, record, logCollection } = this.props;
let isHasParameters = true;
if (record.description.parameters.error) {
......@@ -62,7 +62,7 @@ class OpenRow extends React.Component<OpenRowProps, {}> {
<PaiTrialLog
logStr={logPathRow}
id={record.id}
showLogModal={showLogModalOverview}
logCollection={logCollection}
/>
:
<TrialLog logStr={logPathRow} id={record.id} />
......
......@@ -5,8 +5,7 @@ import { DOWNLOAD_IP } from '../../static/const';
interface PaiTrialChildProps {
logString: string;
id: string;
showLogModal: Function;
isdisLogbtn?: boolean;
logCollect: boolean;
}
class PaiTrialChild extends React.Component<PaiTrialChildProps, {}> {
......@@ -17,7 +16,7 @@ class PaiTrialChild extends React.Component<PaiTrialChildProps, {}> {
}
render() {
const { logString, id } = this.props;
const { logString, id, logCollect } = this.props;
return (
<div>
{
......@@ -26,15 +25,19 @@ class PaiTrialChild extends React.Component<PaiTrialChildProps, {}> {
<div />
:
<Row>
<Row>
<a
target="_blank"
href={`${DOWNLOAD_IP}/trial_${id}.log`}
style={{ marginRight: 10 }}
>
trial stdout
</a>
</Row>
{
logCollect
?
<a
target="_blank"
href={`${DOWNLOAD_IP}/trial_${id}.log`}
style={{ marginRight: 10 }}
>
trial stdout
</a>
:
<span>trial stdout: {logString}</span>
}
</Row>
}
</div>
......
......@@ -2,13 +2,12 @@ import * as React from 'react';
import { Row } from 'antd';
import { DOWNLOAD_IP } from '../../static/const';
import PaiTrialChild from './PaiTrialChild';
import LogPathChild from './LogPathChild';
interface PaitrialLogProps {
logStr: string;
id: string;
showLogModal: Function;
trialStatus?: string;
isdisLogbutton?: boolean;
logCollection: boolean;
}
class PaitrialLog extends React.Component<PaitrialLogProps, {}> {
......@@ -19,9 +18,7 @@ class PaitrialLog extends React.Component<PaitrialLogProps, {}> {
}
render() {
const { logStr, id, showLogModal,
isdisLogbutton
} = this.props;
const { logStr, id, logCollection } = this.props;
const isTwopath = logStr.indexOf(',') !== -1
?
true
......@@ -34,23 +31,37 @@ class PaitrialLog extends React.Component<PaitrialLogProps, {}> {
isTwopath
?
<Row>
<Row>
<a
target="_blank"
href={`${DOWNLOAD_IP}/trial_${id}.log`}
style={{ marginRight: 10 }}
>
trial stdout
</a>
<a target="_blank" href={logStr.split(',')[1]}>hdfsLog</a>
</Row>
{
logCollection
?
<Row>
<a
target="_blank"
href={`${DOWNLOAD_IP}/trial_${id}.log`}
style={{ marginRight: 10 }}
>
trial stdout
</a>
<a target="_blank" href={logStr.split(',')[1]}>hdfsLog</a>
</Row>
:
<Row>
<LogPathChild
eachLogpath={logStr.split(',')[0]}
logName="trial stdout:"
/>
<LogPathChild
eachLogpath={logStr.split(',')[1]}
logName="hdfsLog:"
/>
</Row>
}
</Row>
:
<PaiTrialChild
logString={logStr}
id={id}
showLogModal={showLogModal}
isdisLogbtn={isdisLogbutton}
logCollect={logCollection}
/>
}
</div>
......
......@@ -5,11 +5,12 @@ import {
Row, Table, Button, Popconfirm, Modal, Checkbox
} from 'antd';
const CheckboxGroup = Checkbox.Group;
import { MANAGER_IP, DOWNLOAD_IP, trialJobStatus, COLUMN, COLUMN_INDEX } from '../../static/const';
import { MANAGER_IP, trialJobStatus, COLUMN, COLUMN_INDEX } from '../../static/const';
import { convertDuration, intermediateGraphOption, killJob } from '../../static/function';
import { TableObj, TrialJob } from '../../static/interface';
import OpenRow from '../public-child/OpenRow';
import DefaultMetric from '../public-child/DefaultMetrc';
// import DefaultMetric from '../public-child/DefaultMetrc';
import IntermediateVal from '../public-child/IntermediateVal';
import '../../static/style/search.scss';
require('../../static/style/tableStatus.css');
require('../../static/style/logPath.scss');
......@@ -30,6 +31,7 @@ interface TableListProps {
tableSource: Array<TableObj>;
updateList: Function;
platform: string;
logCollection: boolean;
}
interface TableListState {
......@@ -38,8 +40,6 @@ interface TableListState {
isObjFinal: boolean;
isShowColumn: boolean;
columnSelected: Array<string>; // user select columnKeys
logModal: boolean;
logMessage: string;
}
interface ColumnIndex {
......@@ -61,9 +61,7 @@ class TableList extends React.Component<TableListProps, TableListState> {
modalVisible: false,
isObjFinal: false,
isShowColumn: false,
logModal: false,
columnSelected: COLUMN,
logMessage: ''
columnSelected: COLUMN
};
}
......@@ -107,51 +105,6 @@ class TableList extends React.Component<TableListProps, TableListState> {
}
}
updateTrialLogMessage = (id: string) => {
this._trialId = id;
axios(`${DOWNLOAD_IP}/trial_${this._trialId}.log`, {
method: 'GET'
})
.then(res => {
if (res.status === 200) {
if (this._isMounted) {
this.setState(() => ({
logMessage: res.data
}));
}
}
})
.catch(error => {
if (error.response.status === 500) {
if (this._isMounted) {
this.setState(() => ({
logMessage: 'failed to get log message'
}));
}
}
});
}
showLogModal = (id: string) => {
this.updateTrialLogMessage(id);
this.intervalTrialLog = window.setInterval(this.updateTrialLogMessage.bind(this, this._trialId), 10000);
if (this._isMounted) {
this.setState({
logModal: true
});
}
}
hideLogModal = () => {
window.clearInterval(this.intervalTrialLog);
if (this._isMounted) {
this.setState({
logModal: false,
logMessage: ''
});
}
}
hideShowColumnModal = () => {
if (this._isMounted) {
this.setState({
......@@ -222,12 +175,12 @@ class TableList extends React.Component<TableListProps, TableListState> {
}
openRow = (record: TableObj) => {
const { platform } = this.props;
const { platform, logCollection } = this.props;
return (
<OpenRow
showLogModalOverview={this.showLogModal}
trainingPlatform={platform}
record={record}
logCollection={logCollection}
/>
);
}
......@@ -243,7 +196,7 @@ class TableList extends React.Component<TableListProps, TableListState> {
render() {
const { entries, tableSource, updateList } = this.props;
const { intermediateOption, modalVisible, isShowColumn, columnSelected} = this.state;
const { intermediateOption, modalVisible, isShowColumn, columnSelected } = this.state;
let showTitle = COLUMN;
let bgColor = '';
const trialJob: Array<TrialJob> = [];
......@@ -348,17 +301,19 @@ class TableList extends React.Component<TableListProps, TableListState> {
title: 'Default Metric',
dataIndex: 'acc',
key: 'acc',
width: 200,
width: 160,
sorter: (a: TableObj, b: TableObj) => {
if (a.acc !== undefined && b.acc !== undefined) {
return JSON.parse(a.acc.default) - JSON.parse(b.acc.default);
const aa = a.description.intermediate;
const bb = b.description.intermediate;
if (aa !== undefined && bb !== undefined) {
return aa[aa.length - 1] - bb[bb.length - 1];
} else {
return NaN;
}
},
render: (text: string, record: TableObj) => {
return (
<DefaultMetric record={record}/>
<IntermediateVal record={record} />
);
}
});
......
......@@ -46,6 +46,7 @@ interface Experiment {
assessor?: object;
advisor?: object;
clusterMetaData?: object;
logCollection?: string;
}
// trial accuracy
......
......@@ -98,8 +98,8 @@ def parse_args():
parser_trial_ls.add_argument('id', nargs='?', help='the id of experiment')
parser_trial_ls.set_defaults(func=trial_ls)
parser_trial_kill = parser_trial_subparsers.add_parser('kill', help='kill trial jobs')
parser_trial_kill.add_argument('id', nargs='?', help='the id of experiment')
parser_trial_kill.add_argument('--trialid', '-t', required=True, dest='trialid', help='the id of trial to be killed')
parser_trial_kill.add_argument('id', nargs='?', help='id of the trial to be killed')
parser_trial_kill.add_argument('--experiment', '-E', required=True, dest='experiment', help='experiment id of the trial')
parser_trial_kill.set_defaults(func=trial_kill)
#parse experiment command
......@@ -149,8 +149,8 @@ def parse_args():
parser_log_stderr.add_argument('--path', action='store_true', default=False, help='get the path of stderr file')
parser_log_stderr.set_defaults(func=log_stderr)
parser_log_trial = parser_log_subparsers.add_parser('trial', help='get trial log path')
parser_log_trial.add_argument('id', nargs='?', help='the id of experiment')
parser_log_trial.add_argument('--trialid', '-T', dest='trialid', help='find trial log path by id')
parser_log_trial.add_argument('id', nargs='?', help='id of the trial to be found the log path')
parser_log_trial.add_argument('--experiment', '-E', dest='experiment', help='experiment id of the trial, xperiment ID of the trial, required when id is not empty.')
parser_log_trial.set_defaults(func=log_trial)
#parse package command
......
......@@ -76,11 +76,14 @@ def check_experiment_id(args):
return None
else:
return running_experiment_list[0]
if experiment_dict.get(args.id):
return args.id
else:
print_error('Id not correct!')
return None
if hasattr(args, "experiment"):
if experiment_dict.get(args.experiment):
return args.experiment
elif hasattr(args, "id"):
if experiment_dict.get(args.id):
return args.id
print_error('Id not correct!')
return None
def parse_ids(args):
'''Parse the arguments for nnictl stop
......@@ -221,7 +224,7 @@ def trial_ls(args):
response = rest_get(trial_jobs_url(rest_port), 20)
if response and check_response(response):
content = json.loads(response.text)
for index, value in enumerate(content):
for index, value in enumerate(content):
content[index] = convert_time_stamp_to_date(value)
print(json.dumps(content, indent=4, sort_keys=True, separators=(',', ':')))
else:
......@@ -239,7 +242,7 @@ def trial_kill(args):
return
running, _ = check_rest_server_quick(rest_port)
if running:
response = rest_delete(trial_job_id_url(rest_port, args.trialid), 20)
response = rest_delete(trial_job_id_url(rest_port, args.id), 20)
if response and check_response(response):
print(response.text)
else:
......@@ -327,14 +330,19 @@ def log_trial(args):
else:
print_error('Restful server is not running...')
exit(1)
if args.id:
if trial_id_path_dict.get(args.id):
print('id:' + args.id + ' path:' + trial_id_path_dict[args.id])
if args.experiment:
if args.id:
if trial_id_path_dict.get(args.id):
print('id:' + args.id + ' path:' + trial_id_path_dict[args.id])
else:
print_error('trial id is not valid!')
exit(1)
else:
print_error('trial id is not valid!')
print_error('please specific the trial id!')
print_error("trial id list in this experiment: " + str(list(trial_id_path_dict.keys())))
exit(1)
else:
for key in trial_id_path_dict.keys():
for key in trial_id_path_dict:
print('id:' + key + ' path:' + trial_id_path_dict[key])
def get_config(args):
......@@ -412,7 +420,7 @@ def show_experiment_info():
response = rest_get(trial_jobs_url(experiment_dict[key]['port']), 20)
if response and check_response(response):
content = json.loads(response.text)
for index, value in enumerate(content):
for index, value in enumerate(content):
content[index] = convert_time_stamp_to_date(value)
print(TRIAL_MONITOR_CONTENT % (content[index].get('id'), content[index].get('startTime'), content[index].get('endTime'), content[index].get('status')))
print(TRIAL_MONITOR_TAIL)
......
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