Skip to content
This repository has been archived by the owner on Jun 6, 2024. It is now read-only.

Commit

Permalink
Merge branch 'pai-0.14.y' into qinsu/portal/pylon-address
Browse files Browse the repository at this point in the history
  • Loading branch information
sunqinzheng authored Jul 2, 2019
2 parents 0b20926 + f58834d commit e065926
Show file tree
Hide file tree
Showing 12 changed files with 38 additions and 48 deletions.
8 changes: 8 additions & 0 deletions src/webportal/src/app/components/monaco-hack.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,11 @@
}
}
}

:global {
.monaco-aria-container {
position: absolute;
left: -999em;
top: -999em;
}
}
3 changes: 2 additions & 1 deletion src/webportal/src/app/env.js.template
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ window.ENV = {
k8sDashboardUri: '${K8S_DASHBOARD_URI}',
exporterPort: '${EXPORTER_PORT}',
promScrapeTime: '${PROM_SCRAPE_TIME}',
authnMethod: '${AUTHN_METHOD}'
authnMethod: '${AUTHN_METHOD}',
pylonAddress: '${PYLON_ADDRESS}',
};

window.PAI_PLUGINS = [${WEBPORTAL_PLUGINS}][0] || [];
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export const CommandSection = (props) => {
monacoProps={{height: 200}}
value={value}
onChange={_onChange}
completionItems={[...PAI_ENV_VAR.map((x) => `$${x.key}`)]}
completionItems={[...PAI_ENV_VAR.map((x) => x.key)]}
/>
</FormShortSection>
</BasicSection>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export const ContainerSizeSection = (props) => {
};

return (
<BasicSection sectionLabel={'ContainerSize'}>
<BasicSection sectionLabel={'Container Size'}>
<Stack horizontal gap='l1'>
<FormShortSection gap='m'>
<CSpinButton
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@
*/

import {camelCase} from 'lodash';
import {TextField, IconButton, Stack, DetailsList, CheckboxVisibility, DetailsListLayoutMode, CommandBarButton, getTheme} from 'office-ui-fabric-react';
import {TextField, IconButton, Stack, DetailsList, CheckboxVisibility, DetailsListLayoutMode, CommandBarButton, getTheme, SelectionMode} from 'office-ui-fabric-react';
import PropTypes from 'prop-types';
import React, {useCallback, useLayoutEffect, useMemo, useState, useContext} from 'react';
import {dispatchResizeEvent} from '../../utils/utils';
import context from '../context';

export const KeyValueList = ({name, value, onChange, onDuplicate, columnWidth, keyName, keyField, valueName, valueField, secret}) => {
columnWidth = columnWidth || 200;
columnWidth = columnWidth || 180;
keyName = keyName || 'Key';
keyField = keyField || camelCase(keyName);
valueName = valueName || 'Value';
Expand Down Expand Up @@ -151,6 +151,7 @@ export const KeyValueList = ({name, value, onChange, onDuplicate, columnWidth, k
getKey={getKey}
checkboxVisibility={CheckboxVisibility.hidden}
layoutMode={DetailsListLayoutMode.fixedColumns}
selectionMode={SelectionMode.none}
compact
/>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ export const MountList = ({dataList, setDataList, setDataError}) => {
key: 'containerPath',
name: 'Container Path',
headerClassName: FontClassNames.medium,
minWidth: 200,
minWidth: 180,
onRender: (item, idx) => {
return (
<TextField
Expand All @@ -152,7 +152,7 @@ export const MountList = ({dataList, setDataList, setDataError}) => {
key: 'dataSource',
name: 'Data Source',
headerClassName: FontClassNames.medium,
minWidth: 230,
minWidth: 200,
onRender: (item, idx) => {
return (
<TextField
Expand All @@ -169,6 +169,7 @@ export const MountList = ({dataList, setDataList, setDataError}) => {
name: 'Remove',
minWidth: 50,
style: {padding: 0},
headerClassName: FontClassNames.medium,
onRender: (item, idx) => (
<div
style={{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ import config from '../../../config/webportal.config';
import {JobData} from '../../models/data/job-data';
import {Hint} from '../sidebar/hint';

const host = getHostNameFromUrl(config.restServerUri);

function reducer(state, action) {
let jobData;
switch (action.type) {
Expand Down Expand Up @@ -48,7 +46,10 @@ function reducer(state, action) {
}

export const DataComponent = React.memo((props) => {
const hdfsClient = new WebHDFSClient(host);
// add pylonAddress to .env for local debug
const hdfsHost = config.hasOwnProperty('pylonAddress') ? getHostNameFromUrl(config.pylonAddress) : window.location.hostname;
// TODO: add a judgement whether pylon is ready
const hdfsClient = new WebHDFSClient(hdfsHost);
const {onChange} = props;
const [teamConfigs, setTeamConfigs] = useState();
const [defaultTeamConfigs, setDefaultTeamConfigs] = useState();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ export const DockerSection = ({onValueChange, value}) => {
};

return (
<BasicSection sectionLabel={'Docker'}>
<BasicSection sectionLabel='Docker Image'>
<FormShortSection>
<Dropdown
placeholder='Select a docker image'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,16 @@ export const MonacoTextFiled = (props) => {
border: 'solid 1px',
borderColor: palette.neutralTertiary,
paddingTop: spacing.s1,
overflow: 'auto',
}}
completionItems={completionItems}
monacoRef={monacoRef}
monacoProps={{
theme: 'vs',
language: 'plaintext',
options: {
automaticLayout: true,
wordWrap: 'on',
readOnly: false,
theme: 'vs',
defaultEOL: 1,
minimap: {enabled: false},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
*/

import React from 'react';
import {DetailsList, CheckboxVisibility, Stack, DetailsListLayoutMode} from 'office-ui-fabric-react';
import {DetailsList, CheckboxVisibility, Stack, DetailsListLayoutMode, SelectionMode} from 'office-ui-fabric-react';
import PropTypes from 'prop-types';
import {Hint} from './hint';
import {SidebarCard} from './sidebar-card';
Expand Down Expand Up @@ -63,6 +63,7 @@ export const EnvVar = React.memo(({selected, onSelect}) => (
columns={columns}
checkboxVisibility={CheckboxVisibility.hidden}
layoutMode={DetailsListLayoutMode.fixedColumns}
selectionMode={SelectionMode.none}
compact
/>
</div>
Expand Down
15 changes: 9 additions & 6 deletions src/webportal/src/app/job-submission/job-submission.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -242,15 +242,18 @@ const JobSubmission = () => {
return (
<Context.Provider value={contextValue}>
<Fabric style={{height: '100%'}}>
<Stack styles={{root: {height: '100%', overflowY: 'auto'}}}>
<Stack
className={formLayout}
styles={{root: {height: '100%'}}}
gap='l1'
>
<Stack
className={formLayout}
styles={{root: {maxHeight: 930, height: '100%'}}}
styles={{root: {minHeight: 0}}}
horizontal
gap='l1'
>
{/* left column */}
<StackItem grow disableShrink styles={{root: {minWidth: 600}}}>
<StackItem grow styles={{root: {minWidth: 600, minHeight: 0, flexBasis: 0}}}>
<Stack
gap='l1'
styles={{root: {height: '100%', overflowY: 'auto'}}}
Expand All @@ -268,8 +271,8 @@ const JobSubmission = () => {
</Stack>
</StackItem>
{/* right column */}
<StackItem disableShrink styles={{root: {width: 600}}}>
<Stack gap='l1' styles={{root: {height: '100%'}}}>
<StackItem shrink styles={{root: {overflowX: 'auto'}}}>
<Stack gap='l1' styles={{root: {height: '100%', width: 550}}}>
<Parameters
parameters={parameters}
onChange={setParameters}
Expand Down
31 changes: 3 additions & 28 deletions src/webportal/src/app/job-submission/utils/webhdfs.js
Original file line number Diff line number Diff line change
@@ -1,36 +1,11 @@
import * as webhdfs from 'webhdfs';
import {promisify} from 'util';

// interface HDFSStatResult {
// pathSuffix: string
// permission: string
// accessTime: number
// modificationTime: number
// length: number
// type: 'DIRECTORY' | 'FILE'
// }

// interface HDFSClient {
// mkdir(path: string, mode?: string): Promise<void>
// readdir(path: string): Promise<HDFSStatResult[]>
// stat(path: string): Promise<HDFSStatResult>
// unlink(path: string, recursive: boolean): Promise<void>
// rename(from: string, to: string): Promise<void>
// createReadStream(path: string): fs.ReadStream
// createWriteStream(path: string): fs.WriteStream
// writeFile(path: string, data: string, callback: Function): fs.WriteStream
// _getOperationEndpoint(
// operation: string,
// path: string,
// options: object,
// ): string
// }

export class WebHDFSClient {
constructor(host, user, timeout, port = '50070', apiPath = `/webhdfs/v1`) {
constructor(host, user, timeout, port = '80', path = `/webhdfs/api/v1`) {
this.host = `http://${host}:${port}`;
this.endpoint = `http://${host}:${port}${apiPath}`;
this.client = webhdfs.createClient({host, port, user, apiPath}, {timeout});
this.endpoint = `http://${host}:${port}${path}`;
this.client = webhdfs.createClient({host, port, user, path}, {timeout});
this.client.readdir = promisify(this.client.readdir);
this.client.mkdir = promisify(this.client.mkdir);
}
Expand Down

0 comments on commit e065926

Please sign in to comment.