adjust model

This commit is contained in:
mr 2024-07-26 15:19:36 +02:00
parent eb1417853a
commit 87b7cda0ce
6 changed files with 43 additions and 39 deletions

View File

@ -8,31 +8,9 @@ import (
type DatacenterResource struct {
utils.AbstractResource
BookingPrice int `bson:"booking_price,omitempty" json:"booking_price,omitempty"`
CPU *DatacenterCpuModel `bson:"cpu,omitempty" json:"cpu,omitempty"`
RAM *DatacenterMemoryModel `bson:"ram,omitempty" json:"ram,omitempty"`
GPU []DatacenterGpuModel `bson:"gpu,omitempty" json:"gpu,omitempty"`
}
type DatacenterCpuModel struct {
Cores uint `bson:"cores,omitempty" json:"cores,omitempty"` //TODO: validate
Architecture string `bson:"architecture,omitempty" json:"architecture,omitempty"` //TOOD: enum
Shared bool `bson:"shared,omitempty" json:"shared,omitempty"`
MinimumMemory uint `bson:"minimum_memory,omitempty" json:"minimum_memory,omitempty"`
Platform string `bson:"platform,omitempty" json:"platform,omitempty"`
}
type DatacenterMemoryModel struct {
Size uint `bson:"size,omitempty" json:"size,omitempty" description:"Units in MB"`
Ecc bool `bson:"ecc,omitempty" json:"ecc,omitempty"`
}
type DatacenterGpuModel struct {
CudaCores uint `bson:"cuda_cores,omitempty" json:"cuda_cores,omitempty"`
Model string `bson:"model,omitempty" json:"model,omitempty"`
Memory uint `bson:"memory,omitempty" json:"memory,omitempty" description:"Units in MB"`
TensorCores uint `bson:"tensor_cores,omitempty" json:"tensor_cores,omitempty"`
CPUs []*CPU `bson:"cpus,omitempty" json:"cpus,omitempty"`
RAM *RAM `bson:"ram,omitempty" json:"ram,omitempty"`
GPUs []*GPU `bson:"gpus,omitempty" json:"gpus,omitempty"`
}
func (dma *DatacenterResource) Deserialize(j map[string]interface{}) utils.DBObject {
@ -59,3 +37,23 @@ func (d *DatacenterResource) GetAccessor() utils.Accessor {
data.SetLogger(utils.DATACENTER_RESOURCE)
return data
}
type CPU struct {
Cores uint `bson:"cores,omitempty" json:"cores,omitempty"` //TODO: validate
Architecture string `bson:"architecture,omitempty" json:"architecture,omitempty"` //TOOD: enum
Shared bool `bson:"shared,omitempty" json:"shared,omitempty"`
MinimumMemory uint `bson:"minimum_memory,omitempty" json:"minimum_memory,omitempty"`
Platform string `bson:"platform,omitempty" json:"platform,omitempty"`
}
type RAM struct {
Size uint `bson:"size,omitempty" json:"size,omitempty" description:"Units in MB"`
Ecc bool `bson:"ecc,omitempty" json:"ecc,omitempty"`
}
type GPU struct {
CudaCores uint `bson:"cuda_cores,omitempty" json:"cuda_cores,omitempty"`
Model string `bson:"model,omitempty" json:"model,omitempty"`
Memory uint `bson:"memory,omitempty" json:"memory,omitempty" description:"Units in MB"`
TensorCores uint `bson:"tensor_cores,omitempty" json:"tensor_cores,omitempty"`
}

View File

@ -9,7 +9,7 @@ import (
)
func TestStoreOneDatacenter(t *testing.T) {
dc := DatacenterResource{BookingPrice: 123,
dc := DatacenterResource{
AbstractResource: utils.AbstractResource{
AbstractObject: utils.AbstractObject{Name: "testDatacenter"},
Description: "Lorem Ipsum",
@ -27,7 +27,7 @@ func TestStoreOneDatacenter(t *testing.T) {
}
func TestLoadOneDatacenter(t *testing.T) {
dc := DatacenterResource{BookingPrice: 123,
dc := DatacenterResource{
AbstractResource: utils.AbstractResource{
AbstractObject: utils.AbstractObject{Name: "testDatacenter"},
Description: "Lorem Ipsum",

View File

@ -3,18 +3,19 @@ package processing
import (
"encoding/json"
"cloud.o-forge.io/core/oc-lib/models/resources/datacenter"
"cloud.o-forge.io/core/oc-lib/models/utils"
)
type ProcessingResource struct {
utils.AbstractResource
CPUs uint `bson:"cp_us,omitempty" json:"cp_us,omitempty"`
GPUs uint `bson:"gp_us,omitempty" json:"gp_us,omitempty"`
RAM uint `bson:"ram,omitempty" json:"ram,omitempty"`
Parallel bool `bson:"parallel,omitempty" json:"parallel,omitempty"`
ScalingModel uint `bson:"scaling_model,omitempty" json:"scaling_model,omitempty"`
DiskIO string `bson:"disk_io,omitempty" json:"disk_io,omitempty"`
CPUs []*datacenter.CPU `bson:"cpus,omitempty" json:"cp_us,omitempty"`
GPUs []*datacenter.GPU `bson:"gpus,omitempty" json:"gp_us,omitempty"`
RAM datacenter.RAM `bson:"ram,omitempty" json:"ram,omitempty"`
Storage uint `bson:"storage,omitempty" json:"storage,omitempty"`
Parallel bool `bson:"parallel,omitempty" json:"parallel,omitempty"`
ScalingModel uint `bson:"scaling_model,omitempty" json:"scaling_model,omitempty"`
DiskIO string `bson:"disk_io,omitempty" json:"disk_io,omitempty"`
// Price uint `bson:"price,omitempty" json:"price,omitempty"`
// License string `bson:"license,omitempty" json:"license,omitempty"`

View File

@ -13,9 +13,10 @@ type URL struct {
type StorageResource struct {
utils.AbstractResource
Capacity uint `bson:"capacity,omitempty" json:"capacity,omitempty"`
Url *URL `bson:"url,omitempty" json:"url,omitempty"` // Will allow to select between several protocols
Acronym string `bson:"acronym,omitempty" json:"acronym,omitempty"`
Type string `bson:"type,omitempty" json:"type,omitempty"`
Size uint `bson:"size,omitempty" json:"size,omitempty"`
Url *URL `bson:"url,omitempty" json:"url,omitempty"` // Will allow to select between several protocols
Encryption bool `bson:"encryption,omitempty" json:"encryption,omitempty"`
Redundancy string `bson:"redundancy,omitempty" json:"redundancy,omitempty"`

View File

@ -9,7 +9,7 @@ import (
)
func TestStoreOneStorage(t *testing.T) {
s := StorageResource{Capacity: 123, Url: &URL{Protocol: "http", Path: "azerty.fr"},
s := StorageResource{Size: 123, Url: &URL{Protocol: "http", Path: "azerty.fr"},
AbstractResource: utils.AbstractResource{
AbstractObject: utils.AbstractObject{Name: "testData"},
Description: "Lorem Ipsum",
@ -27,7 +27,7 @@ func TestStoreOneStorage(t *testing.T) {
}
func TestLoadOneStorage(t *testing.T) {
s := StorageResource{Capacity: 123, Url: &URL{Protocol: "http", Path: "azerty.fr"},
s := StorageResource{Size: 123, Url: &URL{Protocol: "http", Path: "azerty.fr"},
AbstractResource: utils.AbstractResource{
AbstractObject: utils.AbstractObject{Name: "testData"},
Description: "Lorem Ipsum",

View File

@ -96,6 +96,10 @@ type AbstractResource struct {
Owner string `json:"owner,omitempty" bson:"owner,omitempty" validate:"required"`
OwnerLogo string `json:"owner_logo,omitempty" bson:"owner_logo,omitempty"`
SourceUrl string `json:"source_url,omitempty" bson:"source_url,omitempty" validate:"required"`
Price string `json:"price,omitempty" bson:"price,omitempty"`
License string `json:"license,omitempty" bson:"license,omitempty"`
Inputs []interface{} `json:"inputs,omitempty" bson:"inputs,omitempty"`
Outputs []interface{} `json:"outputs,omitempty" bson:"outputs,omitempty"`
Proxy *ResourceProxy `json:"proxy,omitempty" bson:"proxy,omitempty"`
}
type ResourceProxy struct {