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 16, 2024
1 parent e7e16cd commit 162b859
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
12 changes: 11 additions & 1 deletion config/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,17 @@ export function loadConfig(self, configPath, overrides = None){
}

export function requireConfig(opts){
const configPath = findConfig() || opts.config
if (opts != undefined){
if (Object.keys(opts).includes('config')){
const configPath = opts.config
}
else{
const configPath = findConfig()
}
}
else{
const configPath = findConfig()
}

if(!configPath){
console.error(`no config file found`)
Expand Down
14 changes: 13 additions & 1 deletion ipfs_model_manager_js/ipfs_model_manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import rimraf from 'rimraf';
import _ from 'lodash';
import * as temp_file from "./tmp_file.js";
import { execSync } from 'child_process';
import { requireConfig } from '../config/config.js';


const readFile = util.promisify(fs.readFile);
const writeFile = util.promisify(fs.writeFile);
Expand All @@ -24,7 +26,17 @@ const tmpFile = new temp_file.TempFileManager()

class ModelManager {
constructor(resources = null, meta = null) {

this.thisDir = path.dirname(import.meta.url);
if (this.thisDir.startsWith("file://")) {
this.thisDir = this.thisDir.replace("file://", "");
}
this.parentDir = path.dirname(this.thisDir);
if (fs.existsSync(path.join(this.parentDir, "config", "config.toml"))) {
this.config = new requireConfig({config: path.join(this.parentDir, "config", "config.toml")});
}
else{
// this.config = new requireConfig();
}
this.models = {
"s3_models": [],
"ipfs_models": [],
Expand Down

0 comments on commit 162b859

Please sign in to comment.