Commit f8bd3ad1 authored by Jaden DIEFENBAUGH's avatar Jaden DIEFENBAUGH
Browse files

[environments] integrate with beat.core env support to provide actual local env info, #77

parent 00ccee1d
...@@ -45,6 +45,9 @@ logger = logging.getLogger(__name__) ...@@ -45,6 +45,9 @@ logger = logging.getLogger(__name__)
from . import utils from . import utils
from beat.core.dock import Host
from beat.core.environments import enumerate_packages
class Layout(Resource): class Layout(Resource):
"""Exposes toolchain layout functionality""" """Exposes toolchain layout functionality"""
...@@ -69,52 +72,17 @@ class Environments(Resource): ...@@ -69,52 +72,17 @@ class Environments(Resource):
"""Exposes local environment info""" """Exposes local environment info"""
def get(self): def get(self):
return [ """Uses beat.core to get the local environment (docker) information
{ and returns a list of environments"""
"name": "Scientific Python 2.7", host = Host()
"packages": { envs = host.processing_environments
"alabaster": "0.7.6", for env in envs.keys():
"babel": "1.3" envs[env]['queues'] = {}
}, try:
"queues": { envs[env]['packages'] = enumerate_packages(host, env)
"Default": { except:
"memory_limit": 5983, envs[env]['packages'] = []
"nb_slots": 2, return envs
"max_slots_per_user": 2,
"nb_cores_per_slot": 1,
"time_limit": 360
}
},
"accessibility": "public",
"languages": [
"python"
],
"version": "0.0.4",
"short_description": "Scientific Python 2.7"
},
{
"name": "Scientific Python 2.7",
"packages": {
"alabaster": "0.7.10",
"Babel": "2.4.0"
},
"queues": {
"Default": {
"memory_limit": 5983,
"nb_slots": 2,
"max_slots_per_user": 2,
"nb_cores_per_slot": 1,
"time_limit": 360
}
},
"accessibility": "public",
"languages": [
"python"
],
"version": "1.0.0",
"short_description": "Scientific Python 2.7"
}
]
class Templates(Resource): class Templates(Resource):
......
...@@ -288,30 +288,32 @@ const EnvironmentConfig = ({ envInfo, queue, availableEnvs, updateEnvInfo, updat ...@@ -288,30 +288,32 @@ const EnvironmentConfig = ({ envInfo, queue, availableEnvs, updateEnvInfo, updat
} }
</Input> </Input>
</Col> </Col>
<Col> { Array.isArray(queues) && queues.length > 0 &&
<Label> <Col>
<InfoTooltip <Label>
id='queueTooltip' <InfoTooltip
info={`The "queue" refers to the job queue to put the experiment in once a user decides to run it. This setting currently is only used on the BEAT web platform, and has no effect if ran through beat.cmdline.`} id='queueTooltip'
> info={`The "queue" refers to the job queue to put the experiment in once a user decides to run it. This setting currently is only used on the BEAT web platform, and has no effect if ran through beat.cmdline.`}
Queue >
</InfoTooltip> Queue
</Label> </InfoTooltip>
<Input </Label>
type='select' <Input
className='queue custom-select' type='select'
value={queue} className='queue custom-select'
onChange={e => updateQueue(e.target.value)} value={queue}
placeholder='Queue' onChange={e => updateQueue(e.target.value)}
disabled={disabled} placeholder='Queue'
> disabled={disabled}
{ >
(queues || []).map((queue, i) => {
<option key={i} value={queue}>{ queue }</option> (queues).map((queue, i) =>
) <option key={i} value={queue}>{ queue }</option>
} )
</Input> }
</Col> </Input>
</Col>
}
</FormGroup> </FormGroup>
); );
}; };
...@@ -1101,6 +1103,7 @@ export class ExperimentEditor extends React.Component<Props, State> { ...@@ -1101,6 +1103,7 @@ export class ExperimentEditor extends React.Component<Props, State> {
...this.state.cache.contents.globals.environment, ...this.state.cache.contents.globals.environment,
name, name,
version, version,
queue: '',
} }
} }
})} })}
......
...@@ -96,9 +96,7 @@ const environments = (state: BeatEnvironment[] = [], action: Action) => { ...@@ -96,9 +96,7 @@ const environments = (state: BeatEnvironment[] = [], action: Action) => {
const {type, payload} = action; const {type, payload} = action;
switch(type){ switch(type){
case 'SAVE_ENVIRONMENTS': case 'SAVE_ENVIRONMENTS':
return [ return payload;
...payload,
];
default: default:
throw new Error(`Invalid actionType "${ type }"`); throw new Error(`Invalid actionType "${ type }"`);
} }
......
Supports Markdown
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