models

package
v0.0.0-...-88c21d1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 3, 2023 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const MAX_DATES uint = 1000 // Max number of dates to retrieve
View Source
const MAX_SCHEDULES int = 200
View Source
const SchedulesDB = "schedules"
View Source
const WorkflowDB = "workflows"

Assure consistency by using a const which refers to the MongoDB entry name Workspace.Projects

Variables

This section is empty.

Functions

func AddResource

func AddResource(userID, rID, rType string) (err error)

func CheckSchedule

func CheckSchedule(cronString string, duration uint, cronFirstDate, cronLastDate time.Time, desiredToSchedule ExecutionRequirementsModel) (err error)

func CreateObjectInWorkflow

func CreateObjectInWorkflow(userID, workflowName, rID string) (rObjID2 *string, err error)

func CreateWorkflow

func CreateWorkflow(userID, workflowName string) (err error)

func FindInSlice

func FindInSlice(slice []string, val string) (int, bool)

FindInSlice takes a slice and looks for an element in it. If found it will return it's key, otherwise it will return -1 and a bool of false.

func FindSliceInSlice

func FindSliceInSlice(slice1 []string, slice2 []string) (int, int, bool)

At least one element exist in both slices Return index1, index2 and if exist

func GetAllWorkspaces

func GetAllWorkspaces() <-chan *Workspace

func GetFarSchedules

func GetFarSchedules(baseDate time.Time, isNext bool) *time.Time

func GetHost

func GetHost(hosts []string) (host *string)

func GetMultipleComputing

func GetMultipleComputing(IDs []string) (object *[]ComputingModel, err error)

func GetMultipleData

func GetMultipleData(IDs []string) (object *[]DataModel, err error)

func GetMultipleDatacenter

func GetMultipleDatacenter(IDs []string) (object *[]DatacenterModel, err error)

func GetMultipleStorage

func GetMultipleStorage(IDs []string) (object *[]StorageModel, err error)

func GetMxGraph

func GetMxGraph(username, workflowName string) (xmlData *string, err error)

func IsValidResource

func IsValidResource(rID, rType string) (*primitive.ObjectID, error)

func LinkObjectsInWorkspace

func LinkObjectsInWorkspace(userID, workflowName, rObjIDsource string, isInput bool, rObjIDtarger string) (err error)

func Login

func Login(username, password string) bool

func ParseMxGraph

func ParseMxGraph(username, workflowName, xmlData string) (err error, mxissues []error)

func PostOneComputing

func PostOneComputing(obj ComputingNEWModel) (ID string, err error)

func PostOneData

func PostOneData(obj DataNEWModel) (string, error)

func PostOneDatacenter

func PostOneDatacenter(obj DatacenterNEWModel) (string, error)

func PostOneStorage

func PostOneStorage(obj StorageNEWModel) (string, error)

func RemoveResource

func RemoveResource(userID, rID, rType string) error

Types

type ComputingModel

type ComputingModel struct {
	ID                string `json:"ID" bson:"_id" required:"true" example:"5099803df3f4948bd2f98391"`
	ComputingNEWModel `bson:",inline"`
}

func GetOneComputing

func GetOneComputing(ID string) (object *ComputingModel, err error)

type ComputingNEWModel

type ComputingNEWModel struct {
	Description      string `json:"description" required:"true"`
	Name             string `json:"name,omitempty" required:"true" validate:"required" description:"Name of the computing"`
	ShortDescription string `json:"short_description" required:"true" validate:"required"`

	Type    string `json:"type,omitempty" required:"true"`
	Owner   string `json:"owner"`
	License string `json:"license"`
	Price   uint   `json:"price"`

	ExecutionRequirements ExecutionRequirementsModel `json:"execution_requirements"`

	Dinputs  []string
	Doutputs []string

	Repository RepositoryModel `json:"repository"`
}

type ComputingObject

type ComputingObject struct {
	ReferenceID primitive.ObjectID `json:"referenceID" description:"Computing model ID"`

	Inputs  []string `json:"inputs"`
	Outputs []string `json:"outputs"`

	DataCenterID string `json:"datacenterID" description:"Datacenter where the computing will be executed"`
}

type DCstatus

type DCstatus struct {
	DCname      string
	DCobjID     string //FIXME: Probably should be model ID
	IsReachable bool

	IsAvailable bool
	Booked      *ScheduleInfo

	ErrorMessage string
}

When we check the schedule of a workflow, we report with this

func CheckAndBookWorkflowSchedule

func CheckAndBookWorkflowSchedule(username, workflowName string, book bool) (myRet []DCstatus, err error)

type DataIO

type DataIO struct {
	Counter uint `description:"Incremental number starting from 0"`
}

type DataModel

type DataModel struct {
	ID           string `json:"ID" bson:"_id" required:"true" validate:"required"`
	DataNEWModel `bson:",inline"`
}

func GetOneData

func GetOneData(ID string) (object *DataModel, err error)

type DataNEWModel

type DataNEWModel struct {
	Name             string `json:"name,omitempty" required:"true" validate:"required" description:"Name of the data"`
	ShortDescription string `json:"short_description" required:"true" validate:"required"`
	Description      string `json:"description" required:"true" validate:"required"`

	Type     string   `json:"type,omitempty" required:"true" validate:"required" description:"Define type of data" example:"file"`
	Example  string   `json:"example" required:"true" validate:"required" description:"base64 encoded data"`
	Location string   `json:"location" required:"true" validate:"required"`
	Dtype    string   `json:"dtype"`
	Protocol []string `json:"protocol"` //TODO Enum type
}

TODO: Define better the different types of Data model with model herarchy TODO: review why swagger are not using the metadata when we do herarchy

type DataObject

type DataObject struct {
	ReferenceID primitive.ObjectID `json:"referenceID" description:"Data model ID"`
}

type DatacenterCpuModel

type DatacenterCpuModel struct {
	Cores         uint   `json:"cores" required:"true"` //TODO: validate
	Architecture  string `json:"architecture"`          //TOOD: enum
	Shared        bool   `json:"shared"`
	MinimumMemory uint   `json:"minimum_memory"`
	Platform      string `json:"platform"`
}

type DatacenterGpuModel

type DatacenterGpuModel struct {
	CudaCores   uint   `json:"cuda_cores"`
	Model       string `json:"model"`
	Memory      uint   `json:"memory" description:"Units in MB"`
	TensorCores uint   `json:"tensor_cores"`
}

type DatacenterMemoryModel

type DatacenterMemoryModel struct {
	Size uint `json:"size" description:"Units in MB"`
	Ecc  bool `json:"ecc"`
}

type DatacenterModel

type DatacenterModel struct {
	ID                 string `json:"ID" bson:"_id" required:"true"`
	DatacenterNEWModel `bson:",inline"`
}

func GetDatacenterFromAcronym

func GetDatacenterFromAcronym(DC_name string) (retObj *DatacenterModel)

func GetOneDatacenter

func GetOneDatacenter(ID string) (object *DatacenterModel, err error)

func (DatacenterModel) GetTotalCPUs

func (obj DatacenterModel) GetTotalCPUs() uint

func (DatacenterModel) GetTotalGPUs

func (obj DatacenterModel) GetTotalGPUs() uint

func (DatacenterModel) GetTotalRAM

func (obj DatacenterModel) GetTotalRAM() uint

type DatacenterNEWModel

type DatacenterNEWModel struct {
	Name             string   `json:"name" required:"true"`
	Type             string   `json:"type,omitempty" required:"true"`
	Acronym          string   `json:"acronym" required:"true" description:"id of the DC"`
	Hosts            []string `json:"hosts" required:"true" description:"list of host:port"`
	Description      string   `json:"description" required:"true"`
	ShortDescription string   `json:"short_description" required:"true" validate:"required"`

	CPU DatacenterCpuModel    `json:"cpu" required:"true"`
	RAM DatacenterMemoryModel `json:"ram" required:"true"`
	GPU []DatacenterGpuModel  `json:"gpu" required:"true"`

	Owner        string `json:"owner" `
	BookingPrice int    `json:"bookingPrice" `
}

type DatacenterObject

type DatacenterObject struct {
	ReferenceID primitive.ObjectID `json:"referenceID" description:"Data model ID"`
}

type ExecutionRequirementsModel

type ExecutionRequirementsModel struct {
	CPUs uint `json:"cpus" required:"true"`
	GPUs uint `json:"gpus" description:"Amount of GPUs needed"`
	RAM  uint `json:"ram" required:"true" description:"Units in MB"`

	Parallel     bool   `json:"parallel"`
	ScalingModel uint   `json:"scaling_model"`
	DiskIO       string `json:"disk_io"`
}

type LinkingState

type LinkingState uint
const (
	NO_LINK LinkingState = iota
	INPUT
	OUTPUT
)

type MxCell

type MxCell struct {
	XMLName xml.Name `xml:"mxCell"`
	ID      string   `xml:"id,attr"`
	Parent  *string  `xml:"parent,attr"`
	RID     *string  `xml:"rID,attr"`
	Source  *string  `xml:"source,attr"`
	Target  *string  `xml:"target,attr"`
}

type MxGraphModel

type MxGraphModel struct {
	XMLName xml.Name `xml:"mxGraphModel"`

	Root struct {
		XMLName xml.Name `xml:"root"`
		MxCell  []MxCell `xml:"mxCell"`
	}
}

type RepositoryModel

type RepositoryModel struct {
	Credentials string `json:"credentials"`
	Url         string `json:"url"`
}

type ResourceModel

type ResourceModel interface {
	// contains filtered or unexported methods
}

type ResourceObject

type ResourceObject interface {
	// contains filtered or unexported methods
}

type ScheduleDB

type ScheduleDB struct {
	StartDate   time.Time
	StopDate    time.Time
	Workflow    string
	ResourceQty ExecutionRequirementsModel
}

func GetSchedules

func GetSchedules(startDate, stopDate time.Time) (data []ScheduleDB, maxLimit bool, err error)

type ScheduleInfo

type ScheduleInfo struct {
	Total          int
	NextExecutions [5]string
}

func CreateScheduleWorkflow

func CreateScheduleWorkflow(dcName, userID, workflowName, cronString string, duration uint, startDate, stopDate time.Time, requirements ExecutionRequirementsModel) (ret ScheduleInfo, err error)

func SetWorkflowSchedule

func SetWorkflowSchedule(username, workflowName, cronString, events string, isService bool, startDate, stopDate time.Time, duration uint) (NextSchedules *ScheduleInfo, err error)

type SearchResult

type SearchResult struct {
	Computing  []ComputingModel  `json:"computing" required:"true"`
	Datacenter []DatacenterModel `json:"datacenter"`
	Storage    []StorageModel    `json:"storage"`
	Data       []DataModel       `json:"data"`
}

func FindByWord

func FindByWord(word string) (object *SearchResult, err error)

type StorageModel

type StorageModel struct {
	ID              string `json:"ID" bson:"_id" required:"true"`
	StorageNEWModel `bson:",inline"`
}

func GetOneStorage

func GetOneStorage(ID string) (object *StorageModel, err error)

type StorageNEWModel

type StorageNEWModel struct {
	Name             string `json:"name" required:"true"`
	Description      string `json:"description" required:"true"`
	ShortDescription string `json:"short_description" required:"true" validate:"required"`
	Type             string `json:"type,omitempty" required:"true"`

	DCacronym string `json:"DCacronym" required:"true" description:"Unique ID of the DC where it is the storage"`

	Size         uint   `json:"size" required:"true"`
	Encryption   bool   `json:"encryption" `
	Redundancy   string `json:"redundancy" `
	Throughput   string `json:"throughput" `
	BookingPrice uint   `json:"bookingPrice" `
}

type StorageObject

type StorageObject struct {
	ReferenceID primitive.ObjectID `json:"referenceID" description:"Storage model ID"`

	Inputs  []string `json:"inputs" `
	Outputs []string `json:"outputs" `
}

type UserModel

type UserModel struct {
	ID       string `json:"id,omitempty",bson:"_id"`
	Username string `json:"username,omitempty"`
	Password string `json:"password,omitempty"`
	Email    string `json:"email,omitempty"`
}

type Workflow

type Workflow struct {
	// The key of the map is the ID of the object itself
	Data       map[string]DataObject       `json:"data"`
	Computing  map[string]ComputingObject  `json:"computing"`
	Storage    map[string]StorageObject    `json:"storage"`
	Datacenter map[string]DatacenterObject `json:"datacenter"` //TODO: Decide if there should be multiple objects of a datacenter

	Schedules WorkflowSchedule `json:"schedules"`

	MxgraphXML string `description:"State of the mxgraph"`
}

func GetWorkflow

func GetWorkflow(userID, workflowName string) (workflow *Workflow, err error)

func (*Workflow) AddObj

func (w *Workflow) AddObj(robj ResourceObject) *primitive.ObjectID

func (*Workflow) CreateResourceObject

func (w *Workflow) CreateResourceObject(rt rtype.Rtype) ResourceObject

func (Workflow) GetExecutionRequirements

func (w Workflow) GetExecutionRequirements(dcIDobj string) (ret ExecutionRequirementsModel, err error)

Get a sum of all execution requirements attached to a DC obj

func (*Workflow) GetResource

func (w *Workflow) GetResource(rObjID *string) (retObj ResourceObject)

func (*Workflow) GetResourceMapByRtype

func (w *Workflow) GetResourceMapByRtype(rt rtype.Rtype) interface{}

func (*Workflow) UpdateDB

func (w *Workflow) UpdateDB(userID, workflowName string) error

func (*Workflow) UpdateObj

func (w *Workflow) UpdateObj(robj ResourceObject, objID string)

type WorkflowSchedule

type WorkflowSchedule struct {
	IsService bool `description:"Service: true, Task: false"`
	StartDate time.Time
	StopDate  time.Time
	Cron      string `json:"cron"`
	Duration  uint   `json:"duration" description:"Durantion in seconds" example:"7200"`
	Events    string `json:"events"`
	IsBooked  bool   `json:"isBooked"`
}

func GetWorkflowSchedule

func GetWorkflowSchedule(username, workflowName string) (Currentschedule *WorkflowSchedule, err error)

type Workspace

type Workspace struct {
	UserID string `bson:"_id" json:"user_id"`

	Workflows map[string]Workflow //WorkflowDB

	// ID: rtype
	Data       []string `json:"data"`
	Computing  []string `json:"computing"`
	Datacenter []string `json:"datacenter"`
	Storage    []string `json:"storage"`
}

func GetWorkspace

func GetWorkspace(userID string) (retObj *Workspace)

func NewWorkspace

func NewWorkspace(userID string) (*Workspace, error)

func (Workspace) ConsumeMxGraphModel

func (w Workspace) ConsumeMxGraphModel(xmlmodel MxGraphModel) (ret *Workflow, err error, issues []error)

func (*Workspace) GetAllWorkspacesProjects

func (w *Workspace) GetAllWorkspacesProjects() <-chan *Workflow

func (*Workspace) GetResources

func (w *Workspace) GetResources() map[rtype.Rtype][]string

func (*Workspace) GetWorkflow

func (w *Workspace) GetWorkflow(workflowName string) *Workflow

func (*Workspace) GetWorkflows

func (w *Workspace) GetWorkflows() []string

func (*Workspace) NewResource

func (w *Workspace) NewResource(rID string, rType string) (err error)

type WorkspaceModel

type WorkspaceModel struct {
	UserID string `bson:"_id" json:"user_id"`

	Data       []DataModel       `json:"data"`
	Computing  []ComputingModel  `json:"computing"`
	Datacenter []DatacenterModel `json:"datacenter"`
	Storage    []StorageModel    `json:"storage"`
}

func ListFullWorkspace

func ListFullWorkspace(userID string) (*WorkspaceModel, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL