Skip to content
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

Added sync start #66

Merged
merged 5 commits into from
Feb 20, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 3 additions & 1 deletion commands/sync/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
const watch = require('./watch');
const create = require('./create');
const start = require('./start');

module.exports = {
watch,
create
create,
start
};
66 changes: 66 additions & 0 deletions commands/sync/start.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
const { post } = require('../../helpers/request-helper');

const startHandler = async ({ endpoint, rejectUnauthorized, algorithmName, devFolder, $0: appName }) => {
// get all parameters, decorate,
const body = {
name: algorithmName,
options: {
devMode: true,
devFolder
}
};
// send update, if doesn't exist, exit.
const res = await post({ endpoint, rejectUnauthorized, path: 'store/algorithms?overwrite=true', body });
if (res.result.error || res.error) {
let msg;
if (res.result.error.code === 400) {
msg = "algorithm doesn't exist";
}
else {
msg = res.result.error.message;
}
console.log(`code: ${res.result.error.code}, message: ${msg}`);
return;
}
console.log(`algorithm ${algorithmName} modified to be in development mode.`);
console.log('to sync the folder to the algorithm run');
console.log(`${appName} sync watch -a ${algorithmName} -f localAlgoFolder}`);
};
module.exports = {
command: 'start',
description: 'start an existing algorithm in development mode',
options: {
},
builder: {
algorithmName: {
demandOption: true,
describe: 'The name of the algorithm to sync data into',
type: 'string',
alias: ['a']
},
devFolder: {
demandOption: true,
describe: 'folder in pod to sync to',
type: 'string',
alias: ['f']
},
env: {
describe: 'algorithm runtime environment',
type: 'string',
choices: ['python', 'nodejs']

},
entryPoint: {
describe: 'the main file of the algorithm',
type: 'string',
alias: ['e']
},
baseImage: {
describe: 'base image for the algorithm',
type: 'string'
}
},
handler: async (argv) => {
await startHandler(argv);
}
};
Loading