Skip to content
Snippets Groups Projects
Commit e51d68cc authored by Maël Madon's avatar Maël Madon
Browse files

commit for test salle info

parent 654ea957
Branches
No related tags found
No related merge requests found
{
pkgs ? import (
fetchTarball "https://github.com/NixOS/nixpkgs/archive/refs/tags/23.11.tar.gz")
{}
, kapack ? import
# pkgs ? import (
# fetchTarball "https://github.com/NixOS/nixpkgs/archive/refs/tags/23.11.tar.gz")
# {}
kapack ? import
(fetchTarball "https://github.com/oar-team/nur-kapack/archive/901a5b656f695f2c82d17c091a55db2318ed3f39.tar.gz")
{}
, pkgs ? kapack.pkgs
# {inherit pkgs;}
, python3 ? pkgs.python311
, python3Packages ? pkgs.python311Packages
, python3 ? pkgs.python3
, python3Packages ? pkgs.python3Packages
# , pybatsim-core ? kapack.pybatsim-core
}:
......@@ -58,14 +59,15 @@ let
# batexpe
# nixpkgs.qt6.qtbase
# nixpkgs.qt5.qtbase
(python3.withPackages
(ps: with ps; with python3Packages; [
# jupyter ipython
numpy
matplotlib
# plotly pip tabulate pytz isodate ordered-set yattag
])
)
# (python3.withPackages
# (ps: with ps; with python3Packages; [
# # jupyter ipython
# numpy
# matplotlib
# # plotly pip tabulate pytz isodate ordered-set yattag
# ])
# )
python3Packages.matplotlib
evalys
];
......@@ -79,11 +81,12 @@ let
test = pkgs.mkShell rec {
buildInputs = [
pkgs.stdenv.cc.cc.lib
# pkgs.stdenv.cc.cc.lib
python3Packages.poetry-core
pkgs.poetry
];
LD_LIBRARY_PATH="${pkgs.stdenv.cc.cc.lib}/lib";
# LD_LIBRARY_PATH="${pkgs.stdenv.cc.cc.lib}/lib";
};
# lib = pkgs.lib;
# pybatsim-example = python3Packages.buildPythonPackage rec {
......
"""
This scheduler is a simple FCFS:
- Released jobs are pushed in the back of one single queue
- Two jobs cannot be executed on the same machine at the same time
- Only the job at the head of the queue can be allocated
- If the job is too big (will never fit the machine), it is rejected
- If the job can fit the machine now, it is allocated (and run) instantly
- If the job cannot fit the machine now, the scheduler will waits for enough available machines
"""
from procset import ProcSet
from itertools import islice
from pybatsim.batsim.batsim import BatsimScheduler
class Fcfs2(BatsimScheduler):
def __init__(self, options):
super().__init__(options)
self.logger.info("FCFS init")
def onSimulationBegins(self):
self.nb_completed_jobs = 0
self.sched_delay = 0.5 # Simulates the time spent by the scheduler to take decisions
self.open_jobs = []
self.computing_machines = ProcSet()
self.idle_machines = ProcSet((0,self.bs.nb_compute_resources-1))
def scheduleJobs(self):
print('\n\nopen_jobs = ', self.open_jobs)
print('computingM = ', self.computing_machines)
print('idleM = ', self.idle_machines)
scheduled_jobs = []
loop = True
# If there is a job to schedule
if len(self.open_jobs) > 0:
while loop and self.open_jobs:
job = self.open_jobs[0]
nb_res_req = job.requested_resources
# Job fits now -> allocation
if nb_res_req <= len(self.idle_machines):
res = ProcSet(*islice(self.idle_machines, nb_res_req))
job.allocation = res
scheduled_jobs.append(job)
self.computing_machines |= res
self.idle_machines -= res
self.open_jobs.remove(job)
else: # Job can fit on the machine, but not now
loop = False
# update time
self.bs.consume_time(self.sched_delay)
# send decision to batsim
self.bs.execute_jobs(scheduled_jobs)
else:
# No job to schedule
self.logger.info("There is no job to schedule right now")
def onJobSubmission(self, job):
if job.requested_resources > self.bs.nb_compute_resources:
self.bs.reject_jobs([job]) # This job requests more resources than the machine has
else:
self.open_jobs.append(job)
def onJobCompletion(self, job):
self.idle_machines |= job.allocation
self.computing_machines -= job.allocation
def onNoMoreEvents(self):
self.scheduleJobs()
"""
Trivial example scheduler that rejects any job.
No hard feelings!
"""
from pybatsim.batsim.batsim import BatsimScheduler
class Newsched(BatsimScheduler):
def __init__(self, options):
"""Anything you need to initialize at class creation"""
pass
def onSimulationBegins(self):
"""Initialize your necessary variables and data structures..."""
pass
def onJobSubmission(self, job):
"""Batsim signals that a job arrived. Update the data structs.."""
pass
def onJobCompletion(self, job):
"""Batsim signals that a job completed. Update the data structs.."""
pass
def onNoMoreEvents(self):
"""Nothing else happens at this time stamp: make the scheduling decisions"""
self.scheduleJobs()
def scheduleJobs(self):
"""Make the scheduling decisions"""
pass
\ No newline at end of file
......@@ -3,9 +3,9 @@ requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
[tool.poetry]
name = "pybatsim-example"
name = "RM4ES"
version = "0.0.0"
description = "Example scheduler plugin for PyBatsim"
description = "Small schedulers for RM4ES course"
authors = []
packages = [
{include = "*.py"},
......@@ -17,3 +17,7 @@ pybatsim = "^4.0.0a0"
[tool.poetry.plugins."pybatsim.schedulers"]
rejector = "universal_rejection:UniversalRejectionScheduler"
fcfs2 = "fcfs:Fcfs2"
newSched = "new_sched:Newsched"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment