Documentation
¶
Index ¶
- func CreateContest(baseDir string, contest *Contest) error
- func CreateProblem(contest *Contest, problem *Problem) error
- func DeleteContest(contest *Contest) error
- func DeleteProblem(contest *Contest, problemID string) error
- func FindContestDirs(rootPath string) ([]string, error)
- func LoadAllContestsAndProblems(contestDirs []string) (map[string]*Contest, map[string]*Problem, error)
- func RecoverAndCleanup(db *gorm.DB, cfg *config.Config) error
- func RequeuePendingSubmissions(db *gorm.DB, s *Scheduler, appState *AppState) error
- func UpdateContest(contest *Contest) error
- func UpdateProblem(problem *Problem) error
- type Announcement
- type AppState
- type ClusterState
- type Contest
- type Dispatcher
- type DockerManager
- func (m *DockerManager) CleanupContainer(containerID string)
- func (m *DockerManager) CopyToContainer(containerID string, srcDir string, dstDir string) error
- func (m *DockerManager) CreateContainer(image, volumeName string, cpu int, cpusetCpus string, memory int64, ...) (string, error)
- func (m *DockerManager) CreateVolume(name string) error
- func (m *DockerManager) ExecInContainer(ctx context.Context, containerID string, cmd []string, ...) (ExecResult, error)
- func (m *DockerManager) RemoveVolume(name string) error
- func (m *DockerManager) StartContainer(containerID string) error
- type ExecResult
- type JudgeResult
- type Mount
- type NodeDetail
- type NodeState
- type Problem
- type QueuedSubmission
- type Scheduler
- func (s *Scheduler) GetClusterStates() map[string]ClusterState
- func (s *Scheduler) GetNodeDetails(clusterName, nodeName string) (*NodeDetail, error)
- func (s *Scheduler) GetQueueLengths() map[string]int
- func (s *Scheduler) PauseNode(clusterName, nodeName string) error
- func (s *Scheduler) ReleaseResources(clusterName, nodeName string, coresToRelease []int, memory int64)
- func (s *Scheduler) ResumeNode(clusterName, nodeName string) error
- func (s *Scheduler) Run()
- func (s *Scheduler) Submit(submission *models.Submission, problem *Problem)
- type ScoreConfig
- type TmpfsOptions
- type UploadLimit
- type WorkflowStep
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateContest ¶ added in v0.5.0
CreateContest creates a new contest directory and its configuration files. baseDir is the root directory where all contests are stored (e.g., "contests/").
func CreateProblem ¶ added in v0.5.0
CreateProblem creates a new problem directory and files within a contest. It also updates the parent contest's YAML file.
func DeleteContest ¶ added in v0.5.0
DeleteContest removes the entire directory for a contest.
func DeleteProblem ¶ added in v0.5.0
DeleteProblem removes a problem's directory and updates the parent contest's YAML.
func FindContestDirs ¶ added in v0.5.0
FindContestDirs scans a root directory and returns a slice of all its immediate subdirectories.
func RecoverAndCleanup ¶
RecoverAndCleanup handles the recovery process on application startup. It finds submissions and containers that were in a 'Running' state and cleans up their associated Docker containers before marking them as 'Failed' in the database.
func RequeuePendingSubmissions ¶
RequeuePendingSubmissions loads submissions with 'Queued' status from the DB and adds them back to the scheduler's queue on startup.
func UpdateContest ¶ added in v0.5.0
UpdateContest updates an existing contest's configuration files.
func UpdateProblem ¶ added in v0.5.0
UpdateProblem updates an existing problem's configuration files.
Types ¶
type Announcement ¶ added in v0.5.0
type AppState ¶
type AppState struct {
sync.RWMutex
Contests map[string]*Contest
Problems map[string]*Problem
ProblemToContestMap map[string]*Contest
}
AppState holds the shared, reloadable state of contests and problems.
type ClusterState ¶
type Contest ¶
type Contest struct {
ID string `yaml:"id" json:"id"`
Name string `yaml:"name" json:"name"`
StartTime time.Time `yaml:"starttime" json:"starttime"`
EndTime time.Time `yaml:"endtime" json:"endtime"`
ProblemDirs []string `yaml:"problems" json:"-"` // Renamed from ProblemDirs to problems in YAML, hide from JSON
ProblemIDs []string `yaml:"-" json:"problem_ids"`
Description string `yaml:"-" json:"description"`
BasePath string `yaml:"-" json:"-"` // Store the base path to find assets, hide from both
Announcements []*Announcement `yaml:"-" json:"announcements"` // Loaded from announcements.yaml, hidden from contest.yaml
}
type Dispatcher ¶
type Dispatcher struct {
// contains filtered or unexported fields
}
func NewDispatcher ¶
func (*Dispatcher) Dispatch ¶
func (d *Dispatcher) Dispatch(sub *models.Submission, prob *Problem, node *NodeState, allocatedCores []int)
type DockerManager ¶
type DockerManager struct {
// contains filtered or unexported fields
}
func NewDockerManager ¶
func NewDockerManager(cfg config.DockerConfig) (*DockerManager, error)
func (*DockerManager) CleanupContainer ¶
func (m *DockerManager) CleanupContainer(containerID string)
func (*DockerManager) CopyToContainer ¶
func (m *DockerManager) CopyToContainer(containerID string, srcDir string, dstDir string) error
func (*DockerManager) CreateContainer ¶
func (*DockerManager) CreateVolume ¶ added in v0.6.0
func (m *DockerManager) CreateVolume(name string) error
func (*DockerManager) ExecInContainer ¶
func (m *DockerManager) ExecInContainer(ctx context.Context, containerID string, cmd []string, outputCallback func(streamType string, data []byte)) (ExecResult, error)
func (*DockerManager) RemoveVolume ¶ added in v0.6.0
func (m *DockerManager) RemoveVolume(name string) error
func (*DockerManager) StartContainer ¶
func (m *DockerManager) StartContainer(containerID string) error
type ExecResult ¶
type JudgeResult ¶
type Mount ¶
type Mount struct {
Type string `yaml:"type" json:"type"`
Source string `yaml:"source" json:"source"`
Target string `yaml:"target" json:"target"`
ReadOnly *bool `yaml:"readonly" json:"readonly"`
TmpfsOption TmpfsOptions `yaml:"tmpfs_options" json:"tmpfs_options,omitempty"`
}
type NodeDetail ¶
type Problem ¶
type Problem struct {
ID string `yaml:"id" json:"id"`
Name string `yaml:"name" json:"name"`
Level string `yaml:"level" json:"level"`
StartTime time.Time `yaml:"starttime" json:"starttime"`
EndTime time.Time `yaml:"endtime" json:"endtime"`
MaxSubmissions int `yaml:"max_submissions" json:"max_submissions"`
Cluster string `yaml:"cluster" json:"cluster"`
CPU int `yaml:"cpu" json:"cpu"`
Memory int64 `yaml:"memory" json:"memory"`
Upload UploadLimit `yaml:"upload" json:"upload"`
Workflow []WorkflowStep `yaml:"workflow" json:"workflow"`
Score ScoreConfig `yaml:"score" json:"score"`
Description string `json:"description"`
BasePath string `yaml:"-" json:"-"` // Store the base path to find assets, hide from both
}
type QueuedSubmission ¶
type QueuedSubmission struct {
Submission *models.Submission
Problem *Problem
}
type Scheduler ¶
type Scheduler struct {
// contains filtered or unexported fields
}
func NewScheduler ¶
func (*Scheduler) GetClusterStates ¶
func (s *Scheduler) GetClusterStates() map[string]ClusterState
func (*Scheduler) GetNodeDetails ¶
func (s *Scheduler) GetNodeDetails(clusterName, nodeName string) (*NodeDetail, error)
func (*Scheduler) GetQueueLengths ¶
func (*Scheduler) ReleaseResources ¶
func (*Scheduler) ResumeNode ¶
type ScoreConfig ¶
type TmpfsOptions ¶ added in v0.6.0
type UploadLimit ¶
type UploadLimit struct {
MaxNum int `yaml:"maxnum" json:"max_num"`
MaxSize int `yaml:"maxsize" json:"max_size"`
UploadForm bool `yaml:"upload_form" json:"upload_form"`
UploadFiles []string `yaml:"upload_files" json:"upload_files"`
Editor bool `yaml:"editor" json:"editor"`
EditorFiles []string `yaml:"editor_files" json:"editor_files"`
}
type WorkflowStep ¶
type WorkflowStep struct {
Name string `yaml:"name" json:"name"`
Image string `yaml:"image" json:"image"`
Root bool `yaml:"root" json:"root"`
Timeout int `yaml:"timeout" json:"timeout"`
Show bool `yaml:"show" json:"show"`
Steps [][]string `yaml:"steps" json:"steps"`
Mounts []Mount `yaml:"mounts" json:"mounts"`
Network bool `yaml:"network" json:"network"`
}