GuidesRecipesAPI ReferenceChangelogDiscussions
Log In

modzyClient.submitJobFile

Submit a job using files as inputs

modzyClient.submitJobFile(modelId, versionId, fileSources, explain=false)

Submit a job based on file (path or content) inputs, the sources dictionary is a double object structure as follows:

{
  '<<<<input-item-key>>>>': {
    '<<<<data-input-item-key>>>>: '/some/file/path.ext'
  }
}

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

ParameterTypeDescriptionExample
modelIdstringModel identifier provided by Modzy.'ed542963de'
versionIdstringThe model’s version number. It follows the semantic versioning format.'1.0.1'
textSourcesobjectA mapping of source names to binary or path sources. Each source should be a mapping of model input key to a byte array or a path.'{'my-input': {'input.txt': '/usr/inputs/some_file.txt'}}'
explainbooleanIf the model supports explainability, flag this job to return an explanation of the predictionstrue

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

sources = {"my-input": {"input.txt": "/some/file/path.txt"}}
job = await modzyClient.submitJobFile('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.submitJobFile('ed542963de', '0.0.27', sources)
  .then(
    (job)=>{
      console.log( `Job ${job.identifier} status ${job.status}` );
    }
  )
  .catch(
  	(error)=>{
      console.error(error);
    }
  );