-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: create new environment using a remote mamba solver
The code completion in the environment editor can be activated with CTRL-space.
- Loading branch information
1 parent
b7d87e1
commit 2da6178
Showing
16 changed files
with
666 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import * as React from 'react'; | ||
import CodeMirror from 'codemirror'; | ||
import 'codemirror/lib/codemirror.css'; | ||
import './yaml'; | ||
import * as condaHint from './CondaHint'; | ||
|
||
/** | ||
* Conda solve properties | ||
*/ | ||
export interface ICondaEnvSolveProps { | ||
subdir: string; | ||
create(name: string, explicitList: string): void; | ||
} | ||
|
||
export const CondaEnvSolve = (props: ICondaEnvSolveProps): JSX.Element => { | ||
const codemirrorElem = React.useRef(); | ||
|
||
const [editor, setEditor] = React.useState(null); | ||
const [solveState, setSolveState] = React.useState(null); | ||
|
||
async function solve() { | ||
const environment_yml = editor.getValue(); | ||
setSolveState('Solving...'); | ||
const name = condaHint.getName(environment_yml); | ||
try { | ||
const solveResult = await condaHint.fetchSolve( | ||
props.subdir, | ||
environment_yml | ||
); | ||
setSolveState(`Creating environment ${name}...`); | ||
await props.create(name, solveResult); | ||
setSolveState('Ok'); | ||
} catch (e) { | ||
setSolveState(`Error: ${e}`); | ||
} | ||
} | ||
|
||
React.useEffect(() => { | ||
if (editor) { | ||
return; | ||
} | ||
setEditor( | ||
CodeMirror(codemirrorElem.current, { | ||
lineNumbers: true, | ||
extraKeys: { | ||
'Ctrl-Space': 'autocomplete', | ||
'Ctrl-Tab': 'autocomplete' | ||
}, | ||
tabSize: 2, | ||
mode: 'yaml', | ||
autofocus: true | ||
}) | ||
); | ||
}); | ||
return ( | ||
<div style={{ width: '80vw', maxWidth: '900px' }}> | ||
<div ref={codemirrorElem}></div> | ||
<div style={{ paddingTop: '8px' }}> | ||
<button onClick={solve}>Create</button> | ||
<span style={{ marginLeft: '16px' }}>{solveState}</span> | ||
</div> | ||
</div> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.