fetch capacity and simulate task fitting (#33)

This commit is contained in:
Tan N. Le 2022-08-02 10:37:31 -07:00 committed by GitHub
parent 66bd6308ce
commit 14691698f6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 171 additions and 3 deletions

View file

@ -65,6 +65,8 @@ type Job struct {
CPU float64 `yaml:"cpu"`
RAM int64 `yaml:"ram"`
Disk int64 `yaml:"disk"`
Port int64 `yaml:"port"`
GPU int64 `yaml:"gpu"`
Executor Executor `yaml:"executor"`
Instances int32 `yaml:"instances"`
MaxFailures int32 `yaml:"maxFailures"`
@ -90,6 +92,8 @@ func (j *Job) ToRealis() (*realis.AuroraJob, error) {
CPU(j.CPU).
RAM(j.RAM).
Disk(j.Disk).
AddPorts(int(j.Port)).
GPU(j.GPU).
IsService(j.Service).
Tier(j.Tier).
Priority(j.Priority).

View file

@ -118,6 +118,26 @@ func UnmarshalJob(filename string) (Job, error) {
return job, nil
}
func UnmarshalTaskConfig(filename string) (*aurora.TaskConfig, error) {
if jobsFile, err := os.Open(filename); err != nil {
return nil, errors.Wrap(err, "unable to read the task config file")
} else {
job := Job{}
if err := yaml.NewDecoder(jobsFile).Decode(&job); err != nil {
return nil, errors.Wrap(err, "unable to parse task config file")
}
if auroraJob, err := job.ToRealis(); err != nil {
return nil, errors.Wrap(err, "unable to parse task config file")
} else {
return auroraJob.JobConfig().TaskConfig, nil
}
}
return nil, nil
}
func UnmarshalUpdate(filename string) (UpdateJob, error) {
updateJob := UpdateJob{}