modzyClient.submitJobEmbedded

Submit a job using bytes or byte arrays as inputs

modzyClient.submitJobEmbedded(modelId, versionId, mediaType, embeddedSources, explain=false)

Submit a job based on byte array inputs, the sources dictionary is a double object structure as follows:

{
  '<<<<input-item-key>>>>': {
    '<<<<data-input-item-key>>>>: b'This is binary content'
  }
}

Where:

<<<<input-item-key>>>>: are user defined keys to identify the input items.
<<<<data-input-item-key>>>>: are model defined keys (usually file names).

Parameters

Parameter

Type

Description

Example

modelId

string

Model identifier provided by Modzy.

'ed542963de'

versionId

string

The model’s version number. It follows the semantic versioning format.

'1.0.1'

embeddedSources

object

A mapping of source names to byte arrays. Each source should be a mapping of model input key to a byte array.

'{'my-input': {'input.txt': Buffer.from("Some string")}}'

explain

boolean

If the model supports explainability, flag this job to return an explanation of the predictions

true

Returns

A Job object with the status from the server

{
    "$schema": "http://json-schema.org/draft-06/schema#",
    "$ref": "#/definitions/Job",
    "definitions": {
        "Job": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
                "model": {
                    "$ref": "#/definitions/Model"
                },
                "status": {
                    "type": "string"
                },
                "totalInputs": {
                    "type": "integer"
                },
                "jobIdentifier": {
                    "type": "string",
                    "format": "uuid"
                },
                "accessKey": {
                    "type": "string"
                },
                "explain": {
                    "type": "boolean"
                },
                "jobType": {
                    "type": "string"
                },
                "accountIdentifier": {
                    "type": "string"
                },
                "team": {
                    "$ref": "#/definitions/Team"
                },
                "user": {
                    "$ref": "#/definitions/User"
                },
                "jobInputs": {
                    "$ref": "#/definitions/JobInputs"
                },
                "submittedAt": {
                    "type": "string",
                    "format": "date-time"
                },
                "imageClassificationModel": {
                    "type": "boolean"
                }
            },
            "required": [
                "accessKey",
                "accountIdentifier",
                "explain",
                "imageClassificationModel",
                "jobIdentifier",
                "jobInputs",
                "jobType",
                "model",
                "status",
                "submittedAt",
                "team",
                "totalInputs",
                "user"
            ]            
        },
        "JobInputs": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
                "identifier": {
                    "type": "array",
                    "items": {
                        "type": "string"
                    }
                }
            },
            "required": [
                "identifier"
            ]            
        },
        "Model": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
                "identifier": {
                    "type": "string"
                },
                "version": {
                    "type": "string"
                },
                "name": {
                    "type": "string"
                }
            },
            "required": [
                "identifier",
                "name",
                "version"
            ]            
        },
        "Team": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
                "identifier": {
                    "type": "string"
                }
            },
            "required": [
                "identifier"
            ]            
        },
        "User": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
                "identifier": {
                    "type": "string",
                    "format": "uuid"
                },
                "firstName": {
                    "type": "string"
                },
                "lastName": {
                    "type": "string"
                },
                "email": {
                    "type": "string"
                }
            },
            "required": [
                "email",
                "firstName",
                "identifier",
                "lastName"
            ]            
        }
    }
}

Examples

const fs = require('fs');
sources = {"my-input": {"input.txt": fs.readFileSync("/some/file/path.txt")}}
job = await modzyClient.submitJobEmbedded('ed542963de', '0.0.27', sources);
console.log( `Job ${job.identifier} status ${job.status}` );

Using promises

sources = {"my-input": {"input.txt": Buffer.from("You can also use bytes")}}
modzyClient.submitJobEmbedded('ed542963de', '0.0.27', sources)
  .then(
    (job)=>{
      console.log( `Job ${job.identifier} status ${job.status}` );
    }
  )
  .catch(
    (error)=>{
      console.error(error);
    }
  );

Did this page help you?