This repository has been archived by the owner on Nov 16, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Hot fix for initializing blob data and using template in v1.4.0 (#165)
- Loading branch information
Showing
4 changed files
with
45 additions
and
37 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
54 changes: 28 additions & 26 deletions
54
webportal/src/app/market_detail/utils/generate_job_protocol.js
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 |
---|---|---|
@@ -1,30 +1,32 @@ | ||
import { getConnectionString } from 'App/utils/marketplace_api'; | ||
|
||
export async function generateJobProtocol(item, user) { | ||
const connectionString = await getConnectionString(); // can add user as key to get connection string | ||
const npmInstallToken = process.env.NPM_INSTALL_TOKEN; | ||
const protocolHeaderArray = [ | ||
'curl -sL https://deb.nodesource.com/setup_10.x -o nodesource_setup.sh', | ||
'bash nodesource_setup.sh', | ||
'apt update', | ||
'apt install -y nodejs', | ||
'npm config set @swordfaith:registry https://npm.pkg.github.com/', | ||
`echo "//npm.pkg.github.com/:_authToken=${npmInstallToken}" >> ~/.npmrc`, | ||
'npm install -g @swordfaith/pai_copy', | ||
`export STORAGE_CONNECTION_STRING="${connectionString}"`, | ||
]; | ||
// pai_copy upload [filePath] [containerName] [blobFolder] | ||
const protocolFooterArray = [ | ||
'if [ -z ${OUTPUT_DIR+x}]; then', // eslint-disable-line no-template-curly-in-string | ||
'\techo "Not found OUTPUT_DIR environ"', | ||
'else', | ||
'\tpai_copy upload ${OUTPUT_DIR} paiuploadtest ${PAI_USER_NAME}/${PAI_JOB_NAME}/', // eslint-disable-line no-template-curly-in-string | ||
'fi', | ||
]; | ||
const taskRoleName = Object.keys(item.protocol.taskRoles)[0]; | ||
item.protocol.taskRoles[taskRoleName].commands = protocolHeaderArray.concat( | ||
item.protocol.taskRoles[taskRoleName].commands, | ||
protocolFooterArray, | ||
); | ||
export async function generateJobProtocol(item, user, useBlob) { | ||
if (useBlob === true) { | ||
const connectionString = await getConnectionString(); // can add user as key to get connection string | ||
const npmInstallToken = process.env.NPM_INSTALL_TOKEN; | ||
const protocolHeaderArray = [ | ||
'curl -sL https://deb.nodesource.com/setup_10.x -o nodesource_setup.sh', | ||
'bash nodesource_setup.sh', | ||
'apt update', | ||
'apt install -y nodejs', | ||
'npm config set @swordfaith:registry https://npm.pkg.github.com/', | ||
`echo "//npm.pkg.github.com/:_authToken=${npmInstallToken}" >> ~/.npmrc`, | ||
'npm install -g @swordfaith/pai_copy', | ||
`export STORAGE_CONNECTION_STRING="${connectionString}"`, | ||
]; | ||
// pai_copy upload [filePath] [containerName] [blobFolder] | ||
const protocolFooterArray = [ | ||
'if [ -z ${OUTPUT_DIR+x}]; then', // eslint-disable-line no-template-curly-in-string | ||
'\techo "Not found OUTPUT_DIR environ"', | ||
'else', | ||
'\tpai_copy upload ${OUTPUT_DIR} paiuploadtest ${PAI_USER_NAME}/${PAI_JOB_NAME}/', // eslint-disable-line no-template-curly-in-string | ||
'fi', | ||
]; | ||
const taskRoleName = Object.keys(item.protocol.taskRoles)[0]; | ||
item.protocol.taskRoles[taskRoleName].commands = protocolHeaderArray.concat( | ||
item.protocol.taskRoles[taskRoleName].commands, | ||
protocolFooterArray, | ||
); | ||
} | ||
return item.protocol; | ||
} |