|
1 | 1 | import { getConnectionString } from 'App/utils/marketplace_api';
|
2 | 2 |
|
3 |
| -export async function generateJobProtocol(item, user) { |
4 |
| - const connectionString = await getConnectionString(); // can add user as key to get connection string |
5 |
| - const npmInstallToken = process.env.NPM_INSTALL_TOKEN; |
6 |
| - const protocolHeaderArray = [ |
7 |
| - 'curl -sL https://deb.nodesource.com/setup_10.x -o nodesource_setup.sh', |
8 |
| - 'bash nodesource_setup.sh', |
9 |
| - 'apt update', |
10 |
| - 'apt install -y nodejs', |
11 |
| - 'npm config set @swordfaith:registry https://npm.pkg.github.com/', |
12 |
| - `echo "//npm.pkg.github.com/:_authToken=${npmInstallToken}" >> ~/.npmrc`, |
13 |
| - 'npm install -g @swordfaith/pai_copy', |
14 |
| - `export STORAGE_CONNECTION_STRING="${connectionString}"`, |
15 |
| - ]; |
16 |
| - // pai_copy upload [filePath] [containerName] [blobFolder] |
17 |
| - const protocolFooterArray = [ |
18 |
| - 'if [ -z ${OUTPUT_DIR+x}]; then', // eslint-disable-line no-template-curly-in-string |
19 |
| - '\techo "Not found OUTPUT_DIR environ"', |
20 |
| - 'else', |
21 |
| - '\tpai_copy upload ${OUTPUT_DIR} paiuploadtest ${PAI_USER_NAME}/${PAI_JOB_NAME}/', // eslint-disable-line no-template-curly-in-string |
22 |
| - 'fi', |
23 |
| - ]; |
24 |
| - const taskRoleName = Object.keys(item.protocol.taskRoles)[0]; |
25 |
| - item.protocol.taskRoles[taskRoleName].commands = protocolHeaderArray.concat( |
26 |
| - item.protocol.taskRoles[taskRoleName].commands, |
27 |
| - protocolFooterArray, |
28 |
| - ); |
| 3 | +export async function generateJobProtocol(item, user, useBlob) { |
| 4 | + if (useBlob === true) { |
| 5 | + const connectionString = await getConnectionString(); // can add user as key to get connection string |
| 6 | + const npmInstallToken = process.env.NPM_INSTALL_TOKEN; |
| 7 | + const protocolHeaderArray = [ |
| 8 | + 'curl -sL https://deb.nodesource.com/setup_10.x -o nodesource_setup.sh', |
| 9 | + 'bash nodesource_setup.sh', |
| 10 | + 'apt update', |
| 11 | + 'apt install -y nodejs', |
| 12 | + 'npm config set @swordfaith:registry https://npm.pkg.github.com/', |
| 13 | + `echo "//npm.pkg.github.com/:_authToken=${npmInstallToken}" >> ~/.npmrc`, |
| 14 | + 'npm install -g @swordfaith/pai_copy', |
| 15 | + `export STORAGE_CONNECTION_STRING="${connectionString}"`, |
| 16 | + ]; |
| 17 | + // pai_copy upload [filePath] [containerName] [blobFolder] |
| 18 | + const protocolFooterArray = [ |
| 19 | + 'if [ -z ${OUTPUT_DIR+x}]; then', // eslint-disable-line no-template-curly-in-string |
| 20 | + '\techo "Not found OUTPUT_DIR environ"', |
| 21 | + 'else', |
| 22 | + '\tpai_copy upload ${OUTPUT_DIR} paiuploadtest ${PAI_USER_NAME}/${PAI_JOB_NAME}/', // eslint-disable-line no-template-curly-in-string |
| 23 | + 'fi', |
| 24 | + ]; |
| 25 | + const taskRoleName = Object.keys(item.protocol.taskRoles)[0]; |
| 26 | + item.protocol.taskRoles[taskRoleName].commands = protocolHeaderArray.concat( |
| 27 | + item.protocol.taskRoles[taskRoleName].commands, |
| 28 | + protocolFooterArray, |
| 29 | + ); |
| 30 | + } |
29 | 31 | return item.protocol;
|
30 | 32 | }
|
0 commit comments