Skip to content

Commit 8bd5ab3

Browse files
committed
Apply model version in getOutputInfo
1 parent cb730ed commit 8bd5ab3

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed

src/Model.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ let {
1919
PREDICT_PATH,
2020
VERSION_PREDICT_PATH,
2121
MODEL_INPUTS_PATH,
22+
MODEL_VERSION_OUTPUT_PATH,
2223
MODEL_OUTPUT_PATH,
2324
MODEL_VERSION_INPUTS_PATH,
2425
MODEL_VERSION_METRICS_PATH
@@ -277,7 +278,9 @@ class Model {
277278
* @return {Promise(Model, error)} A Promise that is fulfilled with a Model instance or rejected with an error
278279
*/
279280
getOutputInfo() {
280-
let url = `${this._config.basePath}${replaceVars(MODEL_OUTPUT_PATH, [this.id])}`;
281+
let url = `${this._config.basePath}${this.versionId ?
282+
replaceVars(MODEL_VERSION_OUTPUT_PATH, [this.id, this.versionId]) :
283+
replaceVars(MODEL_OUTPUT_PATH, [this.id])}`;
281284
return wrapToken(this._config, (headers) => {
282285
return new Promise((resolve, reject) => {
283286
axios.get(url, {headers}).then((response) => {

src/constants.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ module.exports = {
1414
MODEL_VERSION_PATH: '/models/$0/versions/$1',
1515
MODEL_PATCH_PATH: '/models/$0/output_info/data/concepts',
1616
MODEL_OUTPUT_PATH: '/models/$0/output_info',
17+
MODEL_VERSION_OUTPUT_PATH: '/models/$0/versions/$1/output_info',
1718
MODEL_SEARCH_PATH: '/models/searches',
1819
MODEL_FEEDBACK_PATH: '/models/$0/feedback',
1920
MODEL_VERSION_FEEDBACK_PATH: '/models/$0/versions/$1/feedback',

tests/integration/models-int-tests.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -607,4 +607,23 @@ describe('Integration Tests - Models', () => {
607607
})
608608
.catch(errorHandler.bind(done));
609609
});
610+
611+
it('Gets output info', done => {
612+
app.models.getOutputInfo(Clarifai.GENERAL_MODEL)
613+
.then(model => {
614+
expect(model.id).toEqual(Clarifai.GENERAL_MODEL);
615+
done();
616+
})
617+
.catch(errorHandler.bind(done));
618+
});
619+
620+
it('Gets output info when specifying model version', done => {
621+
let olderGeneralModelVersionID = 'aa9ca48295b37401f8af92ad1af0d91d';
622+
app.models.getOutputInfo({id: Clarifai.GENERAL_MODEL, version: olderGeneralModelVersionID})
623+
.then(model => {
624+
expect(model.modelVersion.id).toEqual(olderGeneralModelVersionID);
625+
done();
626+
})
627+
.catch(errorHandler.bind(done));
628+
});
610629
});

0 commit comments

Comments
 (0)