How to use the @terascope/job-components.JobValidator function in @terascope/job-components

To help you get started, we’ve selected a few @terascope/job-components examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github terascope / teraslice / packages / teraslice-test-harness / src / base-test-harness.ts View on Github external
protected makeContextConfig(
        job: JobConfig,
        assetDir: string = process.cwd()
    ): ExecutionContextConfig {
        const assetIds = job.assets ? [...job.assets, '.'] : ['.'];
        const resolvedAssetDir = resolveAssetDir(assetDir);
        this.context.sysconfig.teraslice.assets_directory = resolvedAssetDir;
        job.assets = assetIds;

        const jobValidator = new JobValidator(this.context);
        const executionConfig = jobValidator.validateConfig(job) as ExecutionConfig;
        return {
            context: this.context,
            executionConfig,
            assetIds
        };
    }
}
github terascope / teraslice / packages / teraslice / lib / workers / helpers / job.js View on Github external
async function validateJob(context, jobSpec) {
    const jobValidator = new JobValidator(context, {
        terasliceOpPath,
        assetPath: get(context, 'sysconfig.teraslice.assets_directory'),
    });

    try {
        return await jobValidator.validateConfig(jobSpec);
    } catch (error) {
        throw new Error(`validating job: ${error}`);
    }
}
github terascope / teraslice / packages / teraslice / lib / cluster / services / jobs.js View on Github external
module.exports = function jobsService(context) {
    let executionService;
    let exStore;
    let jobStore;

    const logger = makeLogger(context, 'jobs_service');

    const jobValidator = new JobValidator(context, {
        terasliceOpPath,
        assetPath: get(context, 'sysconfig.teraslice.assets_directory'),
    });

    /**
     * Validate the job spec
     *
     * @returns {Promise}
    */
    async function _validateJobSpec(jobSpec) {
        const parsedAssetJob = await _ensureAssets(cloneDeep(jobSpec));
        const validJob = await jobValidator.validateConfig(parsedAssetJob);
        return validJob;
    }

    async function submitJob(jobSpec, shouldRun) {