-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathtest_version_structure.js
51 lines (45 loc) · 1.61 KB
/
test_version_structure.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
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}`);
const modelId = 'catsdogstest';
const versionId = `v${Date.now()}`;
// Test version creation with simplified structure
const createVersion = async () => {
try {
console.log('Creating version with ID:', versionId);
const response = await new Promise((resolve, reject) => {
stub.PostModelVersions(
{
model_id: modelId,
version: {
id: versionId,
train_info: {
params: {
template: 'classification_base',
epochs: 5
}
}
}
},
metadata,
(err, response) => {
if (err) {
console.error('Error:', err);
reject(err);
} else {
console.log('Response:', JSON.stringify(response, null, 2));
resolve(response);
}
}
);
});
console.log('Version creation response:', JSON.stringify(response, null, 2));
} catch (error) {
console.error('Error creating version:', error);
}
};
// Run the test
createVersion();