Skip to content

Commit dab3b3c

Browse files
committed
docs: improving documentation
1 parent 6497355 commit dab3b3c

File tree

5 files changed

+34
-34
lines changed

5 files changed

+34
-34
lines changed

samples/job_with_aws_input_sample.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ async function createJobWithAWSInput() {
7575
// process and you can identify and refer to a specific input by the key assigned. For example we can add:
7676
sources["second-key"] = { "image": { 'bucket': BUCKET_NAME, 'key': FILE_KEY } };
7777
sources["another-key"] = { "image": { 'bucket': BUCKET_NAME, 'key': FILE_KEY } };
78-
// If you send a wrong input key, the model fails to process the input.
78+
// If you send an incorrect input key, the model fails to process the input.
7979
sources["wrong-key"] = { "a.wrong.key": { 'bucket': BUCKET_NAME, 'key': FILE_KEY } };
8080
// If you send a correct input key, but a wrong AWS S3 value key, the model fails to process the input.
8181
sources["wrong-value"] = { "image": { 'bucket': BUCKET_NAME, 'key': "wrong-aws-file-key.png" } };

samples/job_with_embedded_input_sample.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ logger.level = "info";
1111
// The MODZY_BASE_URL should point to the API services route which may be different from the Modzy page URL.
1212
// (ie: https://modzy.example.com/api).
1313
const BASE_URL = process.env.MODZY_BASE_URL;
14-
// The MODZY_API_KEY is your own personal API key. It is composed by a public part, a dot character and a private part
14+
// The MODZY_API_KEY is your own personal API key. It is composed by a public part, a dot character, and a private part
1515
// (ie: AzQBJ3h4B1z60xNmhAJF.uQyQh8putLIRDi1nOldh).
1616
const API_KEY = process.env.MODZY_API_KEY;
1717

@@ -26,7 +26,7 @@ async function createJobWithEmbeddedInput(){
2626
try {
2727
// Get the model object:
2828
// If you already know the model identifier (i.e.: you got from the URL of the model details page or the input sample),
29-
// you can skip this step. If you don't you can find the model identifier by using its name as follows:
29+
// you can skip this step. If you don't, you can find the model identifier by using its name as follows:
3030
let model = await modzyClient.getModelByName("Multi-Language OCR");
3131
// Or if you already know the model id and want to know more about the model, you can use this instead:
3232
//let model = await modzyClient.getModel("c60c8dbd79");
@@ -37,7 +37,7 @@ async function createJobWithEmbeddedInput(){
3737
logger.info(`The model identifier is ${model.modelId} and the latest version is ${model.latestVersion}`);
3838
// Get the model version object:
3939
// If you already know the model version and the input key(s) of the model version you can skip this step. Also, you can
40-
// use the following code block to know about the inputs keys and skip the call on future job submissions.
40+
// use the following code block to know about the input keys and skip the call on future job submissions.
4141
let modelVersion = await modzyClient.getModelVersion(model.modelId, model.latestVersion);
4242
// The info stored in modelVersion provides insights about the amount of time that the model can spend processing, the inputs, and
4343
// output keys of the model.
@@ -56,7 +56,7 @@ async function createJobWithEmbeddedInput(){
5656

5757
// Send the job:
5858
// An embedded input is a byte array encoded as a string in Base64, that's very handy for small to middle size files, for
59-
// bigger files can be a memory issue because you need to load the file in memory (load + encode), use submitJobFiles instead.
59+
// bigger files can cause memory issues because you need to load the file in the memory (load + encode).
6060
const imageBytes = fs.readFileSync('samples/image.png');
6161
let configBytes = fs.readFileSync('samples/config.json');
6262
// With the info about the model (identifier), the model version (version string, input/output keys), you are ready to
@@ -65,10 +65,10 @@ async function createJobWithEmbeddedInput(){
6565
// An inference job groups input data that you send to a model. You can send any amount of inputs to
6666
// process and you can identify and refer to a specific input by the key that you assign, for example we can add:
6767
sources["second-key"] = {"input": imageBytes, "config.json":configBytes}
68-
// You don't need to load all the inputs from files, just convert to bytes as follows:
68+
// You dont need to load all the inputs from the files, just convert to bytes as follows:
6969
configBytes = Buffer.from(JSON.stringify({"languages":["spa"]}));
7070
sources["another-key"] = {"input": imageBytes, "config.json":configBytes}
71-
// If you send a wrong input key, the model fails to process the input.
71+
// If you send an incorrect input key, the model fails to process the input.
7272
sources["wrong-key"] = {"a.wrong.key": imageBytes, "config.json":configBytes}
7373
// If you send a correct input key, but some wrong values, the model fails to process the input.
7474
sources["wrong-value"] = {"input": configBytes, "config.json":imageBytes}
@@ -78,20 +78,20 @@ async function createJobWithEmbeddedInput(){
7878
// of the process, the most important being the job identifier and the job status.
7979
logger.info("job: "+job.jobIdentifier+" "+job.status);
8080
// The job moves to SUBMITTED, meaning that Modzy acknowledged the job and sent it to the queue to be processed.
81-
// We provide a helper method to listen until the job finishes processing. it will listen until the job finishes
81+
// We provide a helper method to listen until the job finishes processing. It will listen until the job finishes
8282
// and moves to COMPLETED, CANCELED, or TIMEOUT.
8383
job = await modzyClient.blockUntilComplete(job);
8484
// Get the results:
8585
// Check the status of the job. Jobs may be canceled or may reach a timeout.
8686
if( job.status === "COMPLETED" ){
8787
// A completed job means that all the inputs were processed by the model. Check the results for each
88-
// input keys provided in the source object to see the model output.
88+
// input key provided in the source object to see the model output.
8989
let result = await modzyClient.getResult(job.jobIdentifier);
9090
// The result object has some useful info:
9191
logger.info(`Result: finished: ${result.finished}, total: ${result.total}, completed: ${result.completed}, failed: ${result.failed}`);
9292
// Notice that we are iterating through the same input sources keys
9393
for( key in sources ){
94-
// The result object has the individual results of each job input. In this case the output key is called
94+
// The result object has the individual results of each job input. In this case, the output key is called
9595
// results.json, so we can get the results as follows:
9696
if( result.results[key] ){
9797
let model_res = result.results[key]["results.json"];

samples/job_with_file_input_sample.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ logger.level = "info";
1111
// The MODZY_BASE_URL should point to the API services route which may be different from the Modzy page URL.
1212
// (ie: https://modzy.example.com/api).
1313
const BASE_URL = process.env.MODZY_BASE_URL;
14-
// The MODZY_API_KEY is your own personal API key. It is composed by a public part, a dot character and a private part
14+
// The MODZY_API_KEY is your own personal API key. It is composed by a public part, a dot character, and a private part
1515
// (ie: AzQBJ3h4B1z60xNmhAJF.uQyQh8putLIRDi1nOldh).
1616
const API_KEY = process.env.MODZY_API_KEY;
1717

@@ -26,7 +26,7 @@ async function createJobWithFileInput(){
2626
try {
2727
// Get the model object:
2828
// If you already know the model identifier (i.e.: you got from the URL of the model details page or the input sample),
29-
// you can skip this step. If you don't you can find the model identifier by using its name as follows:
29+
// you can skip this step. If you don't, you can find the model identifier by using its name as follows:
3030
let model = await modzyClient.getModelByName("Multi-Language OCR");
3131
// Or if you already know the model id and want to know more about the model, you can use this instead:
3232
//let model = await modzyClient.getModel("c60c8dbd79");
@@ -37,7 +37,7 @@ async function createJobWithFileInput(){
3737
logger.info(`The model identifier is ${model.modelId} and the latest version is ${model.latestVersion}`);
3838
// Get the model version object:
3939
// If you already know the model version and the input key(s) of the model version you can skip this step. Also, you can
40-
// use the following code block to know about the inputs keys and skip the call on future job submissions.
40+
// use the following code block to know about the input keys and skip the call on future job submissions.
4141
let modelVersion = await modzyClient.getModelVersion(model.modelId, model.latestVersion);
4242
// The info stored in modelVersion provides insights about the amount of time that the model can spend processing, the inputs, and
4343
// output keys of the model.
@@ -63,10 +63,10 @@ async function createJobWithFileInput(){
6363
// An inference job groups input data that you send to a model. You can send any amount of inputs to
6464
// process and you can identify and refer to a specific input by the key that you assign, for example we can add:
6565
sources["second-key"] = {"input": imagePath, "config.json": configPath}
66-
// You don't need to load all the inputs from files, just convert to bytes as follows:
66+
// You dont need to load all the inputs from the files, just convert to bytes as follows:
6767
const configBytes = Buffer.from(JSON.stringify({"languages":["spa"]}));
6868
sources["another-key"] = {"input": imagePath, "config.json":configBytes}
69-
// If you send a wrong input key, the model fails to process the input.
69+
// If you send an incorrect input key, the model fails to process the input.
7070
sources["wrong-key"] = {"a.wrong.key": imagePath, "config.json":configPath}
7171
// If you send a correct input key, but some wrong values, the model fails to process the input.
7272
sources["wrong-value"] = {"input": configPath, "config.json":imagePath}
@@ -76,20 +76,20 @@ async function createJobWithFileInput(){
7676
// of the process, the most important being the job identifier and the job status.
7777
logger.info("job: "+job.jobIdentifier+" "+job.status);
7878
// The job moves to SUBMITTED, meaning that Modzy acknowledged the job and sent it to the queue to be processed.
79-
// We provide a helper method to listen until the job finishes processing. it will listen until the job finishes
79+
// We provide a helper method to listen until the job finishes processing. It will listen until the job finishes
8080
// and moves to COMPLETED, CANCELED, or TIMEOUT.
8181
job = await modzyClient.blockUntilComplete(job);
8282
// Get the results:
8383
// Check the status of the job. Jobs may be canceled or may reach a timeout.
8484
if( job.status === "COMPLETED" ){
8585
// A completed job means that all the inputs were processed by the model. Check the results for each
86-
// input keys provided in the source object to see the model output.
86+
// input key provided in the source object to see the model output.
8787
let result = await modzyClient.getResult(job.jobIdentifier);
8888
// The result object has some useful info:
8989
logger.info(`Result: finished: ${result.finished}, total: ${result.total}, completed: ${result.completed}, failed: ${result.failed}`);
9090
// Notice that we are iterating through the same input sources keys
9191
for( key in sources ){
92-
// The result object has the individual results of each job input. In this case the output key is called
92+
// The result object has the individual results of each job input. In this case, the output key is called
9393
// results.json, so we can get the results as follows:
9494
if( result.results[key] ){
9595
let model_res = result.results[key]["results.json"];

samples/job_with_text_input_sample.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ logger.level = "info";
1010
// The MODZY_BASE_URL should point to the API services route which may be different from the Modzy page URL.
1111
// (ie: https://modzy.example.com/api).
1212
const BASE_URL = process.env.MODZY_BASE_URL;
13-
// The MODZY_API_KEY is your own personal API key. It is composed by a public part, a dot character and a private part
13+
// The MODZY_API_KEY is your own personal API key. It is composed by a public part, a dot character, and a private part
1414
// (ie: AzQBJ3h4B1z60xNmhAJF.uQyQh8putLIRDi1nOldh).
1515
const API_KEY = process.env.MODZY_API_KEY;
1616

@@ -25,7 +25,7 @@ async function createJobWithTextInput(){
2525
try{
2626
// Get the model object:
2727
// If you already know the model identifier (i.e.: you got from the URL of the model details page or the input sample),
28-
// you can skip this step. If you don't you can find the model identifier by using its name as follows:
28+
// you can skip this step. If you don't, you can find the model identifier by using its name as follows:
2929
let model = await modzyClient.getModelByName("Sentiment Analysis");
3030
// Or if you already know the model id and want to know more about the model, you can use this instead:
3131
//let model = await modzyClient.getModel("ed542963de");
@@ -36,7 +36,7 @@ async function createJobWithTextInput(){
3636
logger.info(`The model identifier is ${model.modelId} and the latest version is ${model.latestVersion}`);
3737
// Get the model version object:
3838
// If you already know the model version and the input key(s) of the model version you can skip this step. Also, you can
39-
// use the following code block to know about the inputs keys and skip the call on future job submissions.
39+
// use the following code block to know about the input keys and skip the call on future job submissions.
4040
let modelVersion = await modzyClient.getModelVersion(model.modelId, model.latestVersion);
4141
// The info stored in modelVersion provides insights about the amount of time that the model can spend processing, the inputs, and
4242
// output keys of the model.
@@ -61,28 +61,28 @@ async function createJobWithTextInput(){
6161
// process and you can identify and refer to a specific input by the key that you assign, for example we can add:
6262
sources["second-key"] = {"input.txt": "Sometimes I really hate ribs"}
6363
sources["another-key"] = {"input.txt": "Born and raised in Pennsylvania, Swift moved to Nashville, Tennessee, at the age of 14 to pursue a career in country music"}
64-
// If you send a wrong input key, the model fails to process the input.
64+
// If you send an incorrect input key, the model fails to process the input.
6565
sources["wrong-key"] = {"a.wrong.key": "This input is wrong!"}
6666
// When you have all your inputs ready, you can use our helper method to submit the job as follows:
6767
let job = await modzyClient.submitJobText(model.modelId,modelVersion.version, sources);
6868
// Modzy creates the job and queue for processing. The job object contains all the info that you need to keep track
6969
// of the process, the most important being the job identifier and the job status.
7070
logger.info("job: "+job.jobIdentifier+" "+job.status);
7171
// The job moves to SUBMITTED, meaning that Modzy acknowledged the job and sent it to the queue to be processed.
72-
// We provide a helper method to listen until the job finishes processing. it will listen until the job finishes
72+
// We provide a helper method to listen until the job finishes processing. It will listen until the job finishes
7373
// and moves to COMPLETED, CANCELED, or TIMEOUT.
7474
job = await modzyClient.blockUntilComplete(job);
7575
// Get the results:
7676
// Check the status of the job. Jobs may be canceled or may reach a timeout.
7777
if( job.status === "COMPLETED" ){
7878
// A completed job means that all the inputs were processed by the model. Check the results for each
79-
// input keys provided in the source object to see the model output.
79+
// input key provided in the source object to see the model output.
8080
let result = await modzyClient.getResult(job.jobIdentifier);
8181
// The result object has some useful info:
8282
logger.info(`Result: finished: ${result.finished}, total: ${result.total}, completed: ${result.completed}, failed: ${result.failed}`);
8383
// Notice that we are iterating through the same input sources keys
8484
for( key in sources ){
85-
// The result object has the individual results of each job input. In this case the output key is called
85+
// The result object has the individual results of each job input. In this case, the output key is called
8686
// results.json, so we can get the results as follows:
8787
if( result.results[key] ){
8888
let model_res = result.results[key]["results.json"];

src/job-client.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ class JobClient{
115115

116116
/**
117117
*
118-
* Create a new job for the model at the specific version with the text inputs provided.
118+
* Create a new job for a specific model and version with the text inputs provided.
119119
*
120120
* @param {string} modelId - the model id string
121121
* @param {versionId} versionId - version id string
@@ -140,7 +140,7 @@ class JobClient{
140140

141141
/**
142142
*
143-
* Create a new job for the model at the specific version with the embedded inputs provided.
143+
* Create a new job for a specific model and version with the embedded inputs provided.
144144
*
145145
* @param {string} modelId - the model id string
146146
* @param {string} versionId - version id string
@@ -188,7 +188,7 @@ class JobClient{
188188

189189
/**
190190
*
191-
* Create a new job for the model at the specific version with the embedded inputs provided.
191+
* Create a new job for a specific model and version with the embedded inputs provided.
192192
*
193193
* @param {string} modelId - the model id string
194194
* @param {string} versionId - version id string
@@ -230,7 +230,7 @@ class JobClient{
230230

231231
/**
232232
*
233-
* Create a new job for the model at the specific version with the aws-s3 inputs provided.
233+
* Create a new job for a specific model and version with the aws-s3 inputs provided.
234234
*
235235
* @param {string} modelId - the model id string
236236
* @param {string} versionId - version id string
@@ -261,7 +261,7 @@ class JobClient{
261261

262262
/**
263263
*
264-
* Create a new job for the model at the specific version with the jdbc query provided,
264+
* Create a new job for a specific model and version with the jdbc query provided,
265265
*
266266
* Modzy will create a data source with the parameters provided and will execute
267267
* the query provided, then will match the inputs defined of the model with the columns
@@ -298,13 +298,13 @@ class JobClient{
298298

299299
/**
300300
*
301-
* Utility method that wait until the job finish.
301+
* Utility method that waits until the job finishes.
302302
*
303-
* This method first check the status of the job and wait until the job reach
304-
* the completed/error status by passing through the submitted and in_progress state.
303+
* This method first checks the status of the job and waits until the job reaches
304+
* the completed/error status by passing through the submitted and in_progress states.
305305
*
306306
* @param {Object} job The job to block
307-
* @return {Object} A updated instance of the job in a final state
307+
* @return {Object} an updated instance of the job in a final state
308308
* @throws {ApiError} if there is something wrong with the service or the call
309309
*/
310310
blockUntilComplete(job) {

0 commit comments

Comments
 (0)