async def register(params: CodePackJSONJob): codepack = CodePack.from_json(params.codepack) argpack = ArgPack.from_json(params.argpack) common.scheduler.add_codepack(codepack=codepack, argpack=argpack, job_id=params.job_id, trigger=params.trigger, **params.trigger_config) return {'serial_number': codepack.serial_number}
async def register_by_id(params: CodePackIDJob): storage_service = Default.get_service('codepack', 'storage_service') codepack = storage_service.load(params.id) argpack = ArgPack.from_json(params.argpack) common.scheduler.add_codepack(codepack=codepack, argpack=argpack, job_id=params.job_id, trigger=params.trigger, **params.trigger_config) return {'serial_number': codepack.serial_number}
async def run_by_snapshot(params: SnapshotJSON): snapshot = CodePackSnapshot.from_json(params.snapshot) codepack = CodePack.from_snapshot(snapshot) argpack = ArgPack.from_dict(snapshot.argpack) common.supervisor.run_codepack(codepack=codepack, argpack=argpack) return {'serial_number': codepack.serial_number}
async def run_by_id(params: CodePackID): storage_service = Default.get_service('codepack', 'storage_service') codepack = storage_service.load(params.id) argpack = ArgPack.from_json(params.argpack) common.supervisor.run_codepack(codepack=codepack, argpack=argpack) return {'serial_number': codepack.serial_number}
async def run(params: CodePackJSON): codepack = CodePack.from_json(params.codepack) argpack = ArgPack.from_json(params.argpack) common.supervisor.run_codepack(codepack=codepack, argpack=argpack) return {'serial_number': codepack.serial_number}
async def update(argpack: ArgPackJSON): storage_service = Default.get_service('argpack', 'storage_service') tmp = ArgPack.from_json(argpack.argpack) storage_service.save(item=tmp, update=True) return {'id': tmp.id}