Skip to content

Commit

Permalink
dump g5k
Browse files Browse the repository at this point in the history
  • Loading branch information
GuilloteauQ committed Mar 25, 2024
1 parent 4cad916 commit 5824e2d
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 9 deletions.
27 changes: 24 additions & 3 deletions oar/lib/basequery.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,20 +154,41 @@ def get_jobs_for_user(
user, from_time, to_time, states, job_ids, array_id, sql_property
)

def get_gantt_prediction(self, horizon):
def get_gantt_prediction(self, horizon_now, horizon_then):
query = (
db.query(Job)
.join(MoldableJobDescription, Job.id == MoldableJobDescription.id)
.filter(Job.queue_name == "default")
.filter(Job.stop_time == 0)
.filter(Job.state.in_(["Finishing", "Running", "Waiting", "Launching", "toLaunch"]))
.filter(Job.start_time - 60 <= horizon_now)
.filter(Job.start_time + MoldableJobDescription.walltime >= horizon_then)
)
return query

def _get_gantt_prediction(self, horizon):
columns = ("job_id", "start_time", "moldable_walltime", "message")
query = (
# db.query(Job, MoldableJobDescription)
db.query(Job)
.join(MoldableJobDescription, Job.id == MoldableJobDescription.id)
.filter(Job.queue_name == "default")
.filter(Job.stop_time == 0)
# .filter(Job.state.in_(["Running", "Waiting", "Launching", "toLaunch"]))
.filter(Job.state.in_(["Waiting", "Launching", "toLaunch"]))
.filter(Job.state.in_(["Finishing", "Running", "Waiting", "Launching", "toLaunch"]))
# .filter(Job.state.in_(["Waiting", "Launching", "toLaunch"]))
.filter(Job.start_time - 60 <= horizon)
.filter(Job.start_time + MoldableJobDescription.walltime >= horizon)
)
return query

def get_cigri_completions(self, previous_cycle, now):
query = (
db.query(Job)
.filter(Job.queue_name == "besteffort")
.filter(Job.state.in_(["Terminated"]))
.filter(Job.stop_time > previous_cycle)
)
return query


def get_resources(self, network_address, detailed=True):
Expand Down
2 changes: 1 addition & 1 deletion oar/lib/resource_handling.py
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ def update_current_scheduler_priority(job, value, state):

incr_priority = int(value) * index * coeff
db.query(Resource).filter((getattr(Resource, f)).in_(resources)).update(
{Resource.scheduler_priority: incr_priority},
{Resource.scheduler_priority: Resource.scheduler_priority + incr_priority},
synchronize_session=False,
)

Expand Down
21 changes: 16 additions & 5 deletions oar/rest_api/views/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,14 +330,25 @@ def show(job_id, detailed=None):
attach_links(g.data)

@app.route("/gantt", methods=["GET"])
@app.route("/gantt/<int:horizon>", methods=["GET"])
def gantt(horizon=0):
@app.route("/gantt/<int:horizon_now>/<int:horizon_then>", methods=["GET"])
def gantt(horizon_now=0, horizon_then=0):
now = int(time.time())
time_horizon = now + horizon
query = db.queries.get_gantt_prediction(time_horizon)
time_horizon_now = now + horizon_now
time_horizon_then = now + horizon_then
query = db.queries.get_gantt_prediction(time_horizon_now, time_horizon_then)
data = query.all()
g.data["now"] = now
g.data["horizon_now"] = time_horizon_now
g.data["horizon_then"] = time_horizon_then
g.data["items"] = data

@app.route("/cigri_completions/<int:cycle_duration>", methods=["GET"])
def cigri_completions(cycle_duration):
now = int(time.time())
previous_cycle = now - cycle_duration
query = db.queries.get_cigri_completions(previous_cycle, now)
data = query.all()
g.data["now"] = now
g.data["horizon"] = time_horizon
g.data["items"] = data


Expand Down

0 comments on commit 5824e2d

Please sign in to comment.