-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: modelSkeleton #38
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
export default class ModelController { | ||
instance: ModelController | undefined; | ||
constructor() { | ||
if(this.instance) return this.instance; | ||
this.instance = this; | ||
} | ||
|
||
//TODO(woojae): implement this | ||
async isRunning(modelName: string) { | ||
return await true; | ||
} | ||
|
||
//TODO(woojae): implement this | ||
async getInformation(modelName: string) { | ||
return await true; | ||
} | ||
|
||
//TODO(woojae): implement this | ||
async calculateCost(modelName: string, requestData: string) { | ||
return await 0.3; | ||
} | ||
|
||
//TODO(woojae): implement this | ||
async chargeCredit(modelName: string, amount: number) { | ||
return await true; | ||
} | ||
|
||
//TODO(woojae): implement this | ||
async withdrawCredit(modelName: string, amount: number) { | ||
return await true; | ||
} | ||
|
||
//TODO(woojae): implement this | ||
async getCreditBalance(modelName: string) { | ||
return await 0.3; | ||
} | ||
|
||
//TODO(woojae): implement this | ||
async getCreditHistory(modelName: string) { | ||
return await true; | ||
} | ||
|
||
//TODO(woojae): implement this | ||
async use(modelName: string, requestData: string) { | ||
return await true; | ||
} | ||
|
||
//TODO(woojae): implement this | ||
//NOTE(woojae): need admin | ||
async run(modelName: string) { | ||
return await true; | ||
} | ||
|
||
//TODO(woojae): implement this | ||
//NOTE:(woojae): need admin | ||
async stop(modelName: string) { | ||
return await true; | ||
} | ||
|
||
//TODO:(woojae): implement this | ||
//NOTE:(woojae): need admin | ||
async changeModelInfo(modelName: string, config: any) { | ||
return await true; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import ModelController from "./controllers/modelController"; | ||
|
||
export default class Model { | ||
modelName: string; | ||
modelController: ModelController; | ||
|
||
constructor(modelName: string) { | ||
this.modelName = modelName; | ||
this.modelController = new ModelController(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 이 방식으로 호출하면 ModelController 안에 instance가 없어도 될 것 같습니다. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. new를 하면 modelController에서 instance를 넘깁니다. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. modelController의 constructor에서 instance가 이미 생성되었다면, if를 통해 instance를 넘깁니다. |
||
} | ||
//TODO(woojae): login not Required | ||
async isRunning() { | ||
return await this.modelController.isRunning(this.modelName); | ||
} | ||
|
||
//TODO(woojae): login not Required | ||
async getInformation() { | ||
return await this.modelController.getInformation(this.modelName); | ||
} | ||
|
||
//TODO(woojae): login not Required | ||
async calculateCost (requestData: string) { | ||
return await this.modelController.calculateCost(this.modelName, requestData); | ||
} | ||
|
||
async chargeCredit(amount: number) { | ||
return await this.modelController.chargeCredit(this.modelName, amount); | ||
} | ||
|
||
async withdrawCredit(amount: number) { | ||
return await this.modelController.withdrawCredit(this.modelName, amount); | ||
} | ||
|
||
async getCreditBalance() { | ||
return await this.modelController.getCreditBalance(this.modelName); | ||
} | ||
|
||
async getCreditHistory() { | ||
return await this.modelController.getCreditHistory(this.modelName); | ||
} | ||
|
||
async use(requestData: string) { | ||
return await this.modelController.use(this.modelName, requestData); | ||
} | ||
|
||
//NOTE(woojae): need admin | ||
async run() { | ||
await this.isAdmin(); | ||
return await this.modelController.run(this.modelName); | ||
} | ||
|
||
//NOTE(woojae): need admin | ||
async stop() { | ||
await this.isAdmin(); | ||
return await this.modelController.stop(this.modelName); | ||
} | ||
|
||
//NOTE(woojae): need admin | ||
async changeModelInfo(config: any) { | ||
await this.isAdmin(); | ||
return await this.modelController.changeModelInfo(this.modelName, config); | ||
} | ||
|
||
//TODO(woojae): implement this | ||
private async isAdmin() { | ||
return true; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
private static instance ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
적용했습니다. 추가로 코드 수정했습니다.