Skip to content

Fix command errors in Nebari server run for templates #317

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Sep 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions functions/nebari.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,19 @@ exports.handler = async function (event, _) {
.join(' ')

// get notebook cell structure
const nb = getNbCells(title, zipRes, argparser, template)
const nb = getNbCells(title, zipRes, argparser, template, (nebari = true))

// Updating UUID for nebari-test-fix
const nbUid_nebari = nbUid + '-nebari'

// Create the notebook on GitHub
await pushToGitHub(
Buffer.from(JSON.stringify(nb)).toString('base64'),
nbName,
nbUid
nbUid_nebari
)

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

return {
statusCode: 200,
Expand Down
17 changes: 14 additions & 3 deletions functions/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,10 @@ export function getRootUrlWithoutTrailingSlash(url) {
* @param {string} zipRes
* @param {string} argparser
* @param {string} template
* @param {boolean} nebari
* @returns {JSON} nb
*/
export function getNbCells(title, zipRes, argparser, template) {
export function getNbCells(title, zipRes, argparser, template, nebari = false) {
function create_nb_cell(source_array, cell_type) {
return {
cell_type: cell_type,
Expand All @@ -136,20 +137,30 @@ export function getNbCells(title, zipRes, argparser, template) {
'Please, run the cell below to execute your code.'
]

const common_nb_commands = [
let common_nb_commands = [
`!wget ${zipRes}\n`,
`!unzip ${template}.zip\n`,
'!pip install -r requirements.txt'
]

const execution_nb_commands = [
let execution_nb_commands = [
`!python main.py ${
argparser === 'hydra'
? '#--config-dir=/content/ --config-name=config.yaml'
: 'config.yaml'
}`
]

// To have seperate folder in Nebari server for downloading and executing files
if (nebari) {
common_nb_commands = [
'cur_dir = !mkdir pytorch-ignite-template-`date "+%Y%m%d-%H%M%S"` && cd $_ && echo $PWD\n',
`%cd {cur_dir[0]}\n`,
...common_nb_commands
]
execution_nb_commands = [`%cd {cur_dir[0]}\n`, ...execution_nb_commands]
}

let nb_cells = [
create_nb_cell(md_cell, 'markdown'),
create_nb_cell(common_nb_commands, 'code')
Expand Down