Skip to content

Commit

Permalink
feat: Add Namespace in NAS
Browse files Browse the repository at this point in the history
Signed-off-by: Ce Gao <gaoce@caicloud.io>
  • Loading branch information
gaocegege committed Sep 30, 2019
1 parent f8d05cf commit 8fd331c
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 31 deletions.
5 changes: 3 additions & 2 deletions pkg/ui/v1alpha3/frontend/src/actions/nasMonitorActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ export const FETCH_NAS_JOB_INFO_REQUEST = "FETCH_NAS_JOB_INFO_REQUEST";
export const FETCH_NAS_JOB_INFO_SUCCESS = "FETCH_NAS_JOB_INFO_SUCCESS";
export const FETCH_NAS_JOB_INFO_FAILURE = "FETCH_NAS_JOB_INFO_FAILURE";

export const fetchNASJobInfo = (experimentName) => ({
export const fetchNASJobInfo = (experimentName, namespace) => ({
type: FETCH_NAS_JOB_INFO_REQUEST,
experimentName
experimentName,
namespace
})
2 changes: 1 addition & 1 deletion pkg/ui/v1alpha3/frontend/src/components/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const App = (props) => {
<Route path="/katib/hp_monitor/:namespace/:name" component={HPJobInfo} />
<Route path="/katib/nas" component={NAS} />
<Route exact path="/katib/nas_monitor" component={NASJobMonitor} />
<Route path="/katib/nas_monitor/:name" component={NASJobInfo} />
<Route path="/katib/nas_monitor/:namespace/:name" component={NASJobInfo} />
<Route path="/katib/trial" component={Trial} />
<Snack />
</div>
Expand Down
52 changes: 28 additions & 24 deletions pkg/ui/v1alpha3/frontend/src/components/NAS/Monitor/NASJobInfo.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,11 @@ const styles = theme => ({
class NASJobInfo extends React.Component {

componentDidMount() {
this.props.fetchNASJobInfo(this.props.match.params.name);
this.props.fetchNASJobInfo(
this.props.match.params.name, this.props.match.params.namespace);
}

render () {
render() {
const { classes } = this.props;
return (
<div className={classes.root}>
Expand All @@ -51,29 +52,32 @@ class NASJobInfo extends React.Component {
Back
</Button>
</Link>
{this.props.loading ?
<LinearProgress color={"primary"} className={classes.loading} />
:
<div>
<Typography className = {classes.header} variant={"h5"}>
Experiment Name: {this.props.match.params.name}
</Typography>
<br />
{this.props.steps.map((step, i) => {
return (
<ExpansionPanel key={i} className={classes.panel}>
<ExpansionPanelSummary expandIcon={<ExpandMoreIcon />}>
<Typography className={classes.heading}>{step.name}</Typography>
</ExpansionPanelSummary>
<ExpansionPanelDetails>
<NASJobStepInfo step={step} id={i + 1}/>
</ExpansionPanelDetails>
</ExpansionPanel>
)
})}
</div>
{this.props.loading ?
<LinearProgress color={"primary"} className={classes.loading} />
:
<div>
<Typography className={classes.header} variant={"h5"}>
Experiment Name: {this.props.match.params.name}
</Typography>
<Typography className={classes.header} variant={"h5"}>
Experiment Namespace: {this.props.match.params.namespace}
</Typography>
<br />
{this.props.steps.map((step, i) => {
return (
<ExpansionPanel key={i} className={classes.panel}>
<ExpansionPanelSummary expandIcon={<ExpandMoreIcon />}>
<Typography className={classes.heading}>{step.name}</Typography>
</ExpansionPanelSummary>
<ExpansionPanelDetails>
<NASJobStepInfo step={step} id={i + 1} />
</ExpansionPanelDetails>
</ExpansionPanel>
)
})}
</div>
}

</div>
)
}
Expand Down
7 changes: 4 additions & 3 deletions pkg/ui/v1alpha3/frontend/src/sagas/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,8 @@ export const fetchNASJobInfo = function* () {
try {
const result = yield call(
goFetchNASJobInfo,
action.experimentName
action.experimentName,
action.namespace,
)
if (result.status === 200) {
let data = Object.assign(result.data, {})
Expand Down Expand Up @@ -395,11 +396,11 @@ export const fetchNASJobInfo = function* () {
}
}

const goFetchNASJobInfo = function* (experimentName) {
const goFetchNASJobInfo = function* (experimentName, namespace) {
try {
const result = yield call(
axios.get,
`/katib/fetch_nas_job_info/?experimentName=${experimentName}`,
`/katib/fetch_nas_job_info/?experimentName=${experimentName}&namespace=${namespace}`,
)
return result
} catch (err) {
Expand Down
3 changes: 2 additions & 1 deletion pkg/ui/v1alpha3/nas.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ func (k *KatibUIHandler) FetchAllNASJobs(w http.ResponseWriter, r *http.Request)
func (k *KatibUIHandler) FetchNASJobInfo(w http.ResponseWriter, r *http.Request) {
//enableCors(&w)
experimentName := r.URL.Query()["experimentName"][0]
namespace := r.URL.Query()["namespace"][0]

responseRaw := make([]NNView, 0)
var architecture string
Expand All @@ -41,7 +42,7 @@ func (k *KatibUIHandler) FetchNASJobInfo(w http.ResponseWriter, r *http.Request)

defer conn.Close()

trials, err := k.katibClient.GetTrialList(experimentName)
trials, err := k.katibClient.GetTrialList(experimentName, namespace)
if err != nil {
log.Printf("GetTrialList from NAS job failed: %v", err)
http.Error(w, err.Error(), http.StatusInternalServerError)
Expand Down

0 comments on commit 8fd331c

Please sign in to comment.