Skip to content

Commit e273a27

Browse files
Fix command errors in Nebari server run for templates (#317)
* Fix command errors in Nebari server run for templates * fmt fix * Reformat the nebari part in getNbCells * fix error in the commands * Update functions/utils.js Co-authored-by: vfdev <[email protected]> * To fix last commit issues in Nebari * fix the commit hash fetch in nebari.js * Revert "To fix last commit issues in Nebari" This reverts commit 73339b8. --------- Co-authored-by: vfdev <[email protected]>
1 parent 25e58ac commit e273a27

File tree

2 files changed

+20
-6
lines changed

2 files changed

+20
-6
lines changed

functions/nebari.js

+6-3
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,19 @@ exports.handler = async function (event, _) {
2929
.join(' ')
3030

3131
// get notebook cell structure
32-
const nb = getNbCells(title, zipRes, argparser, template)
32+
const nb = getNbCells(title, zipRes, argparser, template, (nebari = true))
33+
34+
// Updating UUID for nebari-test-fix
35+
const nbUid_nebari = nbUid + '-nebari'
3336

3437
// Create the notebook on GitHub
3538
await pushToGitHub(
3639
Buffer.from(JSON.stringify(nb)).toString('base64'),
3740
nbName,
38-
nbUid
41+
nbUid_nebari
3942
)
4043

41-
const nebariLink = `${nebariInstanceLink}/user/${userName}/lab/tree/GitHub%3A${repoOwner}/${repo}/nbs/${nbUid}/${nbName}`
44+
const nebariLink = `${nebariInstanceLink}/user/${userName}/lab/tree/GitHub%3A${repoOwner}/${repo}/nbs/${nbUid_nebari}/${nbName}`
4245

4346
return {
4447
statusCode: 200,

functions/utils.js

+14-3
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,10 @@ export function getRootUrlWithoutTrailingSlash(url) {
110110
* @param {string} zipRes
111111
* @param {string} argparser
112112
* @param {string} template
113+
* @param {boolean} nebari
113114
* @returns {JSON} nb
114115
*/
115-
export function getNbCells(title, zipRes, argparser, template) {
116+
export function getNbCells(title, zipRes, argparser, template, nebari = false) {
116117
function create_nb_cell(source_array, cell_type) {
117118
return {
118119
cell_type: cell_type,
@@ -136,20 +137,30 @@ export function getNbCells(title, zipRes, argparser, template) {
136137
'Please, run the cell below to execute your code.'
137138
]
138139

139-
const common_nb_commands = [
140+
let common_nb_commands = [
140141
`!wget ${zipRes}\n`,
141142
`!unzip ${template}.zip\n`,
142143
'!pip install -r requirements.txt'
143144
]
144145

145-
const execution_nb_commands = [
146+
let execution_nb_commands = [
146147
`!python main.py ${
147148
argparser === 'hydra'
148149
? '#--config-dir=/content/ --config-name=config.yaml'
149150
: 'config.yaml'
150151
}`
151152
]
152153

154+
// To have seperate folder in Nebari server for downloading and executing files
155+
if (nebari) {
156+
common_nb_commands = [
157+
'cur_dir = !mkdir pytorch-ignite-template-`date "+%Y%m%d-%H%M%S"` && cd $_ && echo $PWD\n',
158+
`%cd {cur_dir[0]}\n`,
159+
...common_nb_commands
160+
]
161+
execution_nb_commands = [`%cd {cur_dir[0]}\n`, ...execution_nb_commands]
162+
}
163+
153164
let nb_cells = [
154165
create_nb_cell(md_cell, 'markdown'),
155166
create_nb_cell(common_nb_commands, 'code')

0 commit comments

Comments
 (0)