-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathtest_complete_version.js
69 lines (63 loc) · 2.48 KB
/
test_complete_version.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
const { ClarifaiStub, grpc } = require('clarifai-nodejs-grpc');
// Initialize the gRPC client
const stub = ClarifaiStub.grpc();
const metadata = new grpc.Metadata();
const apiKey = process.env.new_clarifai_key.trim().replace(/[^a-zA-Z0-9]/g, '');
metadata.set('authorization', `Key ${apiKey}`);
async function testCompleteVersion() {
try {
const modelId = 'catsdogstest';
const versionId = `v${Date.now()}`;
console.log('Creating model version with complete structure...');
const response = await new Promise((resolve, reject) => {
stub.PostModelVersions(
{
model_id: modelId,
version: {
id: versionId,
output_info: {
data: {
concepts: [
{ id: 'cats', name: 'cats' },
{ id: 'dogs', name: 'dogs' }
]
},
output_config: {
concepts_mutually_exclusive: true,
closed_environment: true
}
},
train_info: {
params: {
template: 'classification_base',
epochs: 5,
batch_size: 32,
learning_rate: 0.001
},
dataset: {
concepts: [
{ id: 'cats', name: 'cats' },
{ id: 'dogs', name: 'dogs' }
]
}
}
}
},
metadata,
(err, response) => {
if (err) {
console.error('Error:', err);
reject(err);
} else {
console.log('Response:', JSON.stringify(response, null, 2));
resolve(response);
}
}
);
});
console.log('Model version creation response:', JSON.stringify(response, null, 2));
} catch (error) {
console.error('Test failed:', error);
}
}
testCompleteVersion();