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

support for local time #5

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
19 changes: 18 additions & 1 deletion tempmon/utils/preprocess_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,21 @@

import numpy as np
import pandas as pd
import pendulum
import pytz
from definitions import PROJECT_ROOT


def convert_utc_to_local_time(utc_time):
cet = pytz.timezone('CET')
tz_abbreviation = utc_time.astimezone(cet).tzname()

if tz_abbreviation == 'CET':
print("The time is in Central European Time (CET).")
elif tz_abbreviation == 'CEST':
print("The time is in Central European Summer Time (CEST).")


class BaseLineReader:
def __init__(self):
self.per_line_dict = {
Expand Down Expand Up @@ -72,10 +84,15 @@ def read_line(self, line):
# Format 3: outdoor temp: 27, GPU jobs: 16, CPU jobs: 0, CPU on GPU jobs: 0, total jobs: 16, server room temp: 22.81, date: Fri Jul 28 17:00:02 CEST 2023
time_format = "%a %b %d %H:%M:%S %Z %Y"
record = line.strip().split(", ")

utc_time = datetime.strptime(record[6].split(": ")[1], time_format)
pendulum_time = pendulum.instance(utc_time)
local_time = pendulum_time.in_tz("Europe/Vienna")

my_line = copy.deepcopy(self.per_line_dict)
my_line.update({"outdoor temp": float(record[0].split(": ")[1]), "GPU jobs": int(record[1].split(": ")[1]), "CPU jobs": int(record[2].split(": ")[1]),
"CPU on GPU jobs": int(record[3].split(": ")[1]), "total jobs": int(record[4].split(": ")[1]), "server room temp": float(record[5].split(": ")[1]),
"date": datetime.strptime(record[6].split(": ")[1], time_format)})
"date": local_time})
return my_line

class BufferReader:
Expand Down