Skip to content

Commit

Permalink
refactor: Update imports and class names in ipfs_model_manager.js
Browse files Browse the repository at this point in the history
  • Loading branch information
endomorphosis committed Aug 21, 2024
1 parent def5254 commit c0e0528
Show file tree
Hide file tree
Showing 2 changed files with 125 additions and 95 deletions.
89 changes: 0 additions & 89 deletions ipfs_model_manager_js/s3_kit.js
Original file line number Diff line number Diff line change
Expand Up @@ -643,95 +643,6 @@ export class s3Kit {
}
}

async test() {
try{
let s3LsDir = await this.s3LsDir('', 'swissknife-models');
}
catch(err){
console.log(err);
}
}

async test1() {
const endpoint = "https://object.ord1.coreweave.com";
const accessKey = "OVEXCZJJQPUGXZOV";
const secretKey = "H1osbJRy3903PTMqyOAGD6MIohi4wLXGscnvMEduh10";
const bucket = "swissknife-models";
const dir = "bge-base-en-v1.5@hf";
const config = {
accessKey: accessKey,
secretKey: secretKey,
endpoint: endpoint,
};
this.s3cfgToBoto(config);
const s3 = this.getSession(config);
const params = {
Bucket: bucket,
Prefix: dir
};
const data = await s3.listObjectsV2(params).promise();
const directory = {};
data.Contents.forEach((obj) => {
directory[obj.Key] = {
key: obj.Key,
last_modified: obj.LastModified,
size: obj.Size,
e_tag: obj.ETag,
};
});
return directory;
}


async test2() {
const endpoint = "https://object.ord1.coreweave.com";
const accessKey = "OVEXCZJJQPUGXZOV";
const secretKey = "H1osbJRy3903PTMqyOAGD6MIohi4wLXGscnvMEduh10";
const bucket = "cloudkit-beta";
const keys = [
'stablelm-zephyr-3b-GGUF-Q2_K@gguf/manifest.json',
'stablelm-zephyr-3b-GGUF-Q2_K-Q2_K@gguf/README.md',
'stablelm-zephyr-3b-GGUF-Q2_K-Q2_K@gguf/config.json',
'stablelm-zephyr-3b-GGUF-Q2_K-Q2_K@gguf/manifest.json',
'stablelm-zephyr-3b-GGUF-Q2_K-Q2_K@gguf/stablelm-zephyr-3b.Q2_K.gguf'
];
const config = {
accessKeyId: accessKey,
secretAccessKey: secretKey,
endpoint: endpoint,
};
const s3 = new AWS.S3(config);
const results = [];
for (const key of keys) {
const params = {
Bucket: bucket,
Key: key
};
const data = await s3.getObject(params).promise();
results.push(data);
}
return results;
}

async test3() {
const endpoint = "https://object.ord1.coreweave.com";
const accessKey = "OVEXCZJJQPUGXZOV";
const secretKey = "H1osbJRy3903PTMqyOAGD6MIohi4wLXGscnvMEduh10";
const bucket = "cloudkit-beta";
const key = 'Airoboros-c34B-3.1.2-GGUF-Q4_0-Q4_0@gguf/README.md';
const config = {
accessKeyId: accessKey,
secretAccessKey: secretKey,
endpoint: endpoint,
};
const s3 = new AWS.S3(config);
const params = {
Bucket: bucket,
Key: key
};
const data = await s3.getObject(params).promise();
return data;
}
}


Expand Down
131 changes: 125 additions & 6 deletions tests/test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { rawListeners } from "npm";
import { ipfsModelManager } from "../ipfs_model_manager_js/ipfs_model_manager.js";

export default class testIpfsModelManager {
constructor() {

}

async init() {
Expand Down Expand Up @@ -53,6 +55,8 @@ export default class testIpfsModelManager {
this.modelManager = new ipfsModelManager(null, meta);
}



async test(kwargs = {}) {
await this.init();
await this.loadCollectionCache();
Expand All @@ -76,11 +80,126 @@ export default class testIpfsModelManager {
}
}

export class testS3Kit {
constructor() {

}

async test() {
try{
let s3LsDir = await this.s3LsDir('', 'swissknife-models');
}
catch(err){
console.log(err);
}
}

async test1() {
const endpoint = "https://object.ord1.coreweave.com";
const accessKey = "OVEXCZJJQPUGXZOV";
const secretKey = "H1osbJRy3903PTMqyOAGD6MIohi4wLXGscnvMEduh10";
const bucket = "swissknife-models";
const dir = "bge-base-en-v1.5@hf";
const config = {
accessKey: accessKey,
secretKey: secretKey,
endpoint: endpoint,
};
this.s3cfgToBoto(config);
const s3 = this.getSession(config);
const params = {
Bucket: bucket,
Prefix: dir
};
const data = await s3.listObjectsV2(params).promise();
const directory = {};
data.Contents.forEach((obj) => {
directory[obj.Key] = {
key: obj.Key,
last_modified: obj.LastModified,
size: obj.Size,
e_tag: obj.ETag,
};
});
return directory;
}


async test2() {
const endpoint = "https://object.ord1.coreweave.com";
const accessKey = "OVEXCZJJQPUGXZOV";
const secretKey = "H1osbJRy3903PTMqyOAGD6MIohi4wLXGscnvMEduh10";
const bucket = "cloudkit-beta";
const keys = [
'stablelm-zephyr-3b-GGUF-Q2_K@gguf/manifest.json',
'stablelm-zephyr-3b-GGUF-Q2_K-Q2_K@gguf/README.md',
'stablelm-zephyr-3b-GGUF-Q2_K-Q2_K@gguf/config.json',
'stablelm-zephyr-3b-GGUF-Q2_K-Q2_K@gguf/manifest.json',
'stablelm-zephyr-3b-GGUF-Q2_K-Q2_K@gguf/stablelm-zephyr-3b.Q2_K.gguf'
];
const config = {
accessKeyId: accessKey,
secretAccessKey: secretKey,
endpoint: endpoint,
};
const s3 = new AWS.S3(config);
const results = [];
for (const key of keys) {
const params = {
Bucket: bucket,
Key: key
};
const data = await s3.getObject(params).promise();
results.push(data);
}
return results;
}

async test3() {
const endpoint = "https://object.ord1.coreweave.com";
const accessKey = "OVEXCZJJQPUGXZOV";
const secretKey = "H1osbJRy3903PTMqyOAGD6MIohi4wLXGscnvMEduh10";
const bucket = "cloudkit-beta";
const key = 'Airoboros-c34B-3.1.2-GGUF-Q4_0-Q4_0@gguf/README.md';
const config = {
accessKeyId: accessKey,
secretAccessKey: secretKey,
endpoint: endpoint,
};
const s3 = new AWS.S3(config);
const params = {
Bucket: bucket,
Key: key
};
const data = await s3.getObject(params).promise();
return data;
}


async init() {

}
}

if (require.main === module) {
const test = new testIpfsModelManager();
test.test().then((result) => {
console.log("testIpfsModelManager: ", result);
}).catch((error) => {
console.log("testIpfsModelManager error: ", error);
});
const testIpfs = new testIpfsModelManager();
const testS3 = new testS3Kit();
try{
await testIpfs.test().then((result) => {
console.log("testIpfsModelManager: ", result);
}).catch((error) => {
console.log("testIpfsModelManager error: ", error);
raise(error);
});
await testS3.test().then((result) => {
console.log("testS3Kit: ", result);
}).catch((error) => {
console.log("testS3Kit error: ", error);
raise(error);
});
}
catch(err){
console.log(err);
process.exit(1);
}
}

0 comments on commit c0e0528

Please sign in to comment.