Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix script to store fake data #209

Merged
merged 1 commit into from
Jan 17, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 15 additions & 8 deletions scripts/store_fake_data_in_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,17 @@ def modify_timestamps(data):
This function updates the timestamps in order to simulate jobs which have
been launched more recently than they were.
"""
# Retrieve the most recent timestamp (ie its end_time)
most_recent_timestamp = data["jobs"][0]["slurm"]["end_time"]
# most_recent_timestamp = min(job["slurm"]["end_time"] for job in data["jobs"])
# Retrieve a recent timestamp (the submit_time of the first job)
recent_timestamp = data["jobs"][0]["slurm"]["submit_time"]

for job in data["jobs"]:
new_end_time = job["slurm"]["end_time"]
if new_end_time:
if new_end_time > most_recent_timestamp:
most_recent_timestamp = new_end_time
new_submit_time = job["slurm"]["submit_time"]
if new_submit_time:
if new_submit_time > recent_timestamp:
recent_timestamp = new_submit_time

# Retrieve the time interval between this timestamp and now
time_delta = datetime.now().timestamp() - most_recent_timestamp
time_delta = datetime.now().timestamp() - recent_timestamp

# Substract it to the timestamps of the jobs
for job in data["jobs"]:
Expand All @@ -64,6 +64,13 @@ def modify_timestamps(data):
job["slurm"]["start_time"] += time_delta
if job["slurm"]["end_time"]:
job["slurm"]["end_time"] += time_delta
if "last_slurm_update" in job["cw"] and job["cw"]["last_slurm_update"]:
job["cw"]["last_slurm_update"] += time_delta
if (
"last_slurm_update_by_sacct" in job["cw"]
and job["cw"]["last_slurm_update_by_sacct"]
):
job["cw"]["last_slurm_update_by_sacct"] += time_delta


def main(argv):
Expand Down