<commit_before># -*- mode: python; coding: utf-8 -*-
# Copyright 2016 the HERA Collaboration
# Licensed under the 2-clause BSD license.

"""M&C logging of the uptime, load, etc., on our computers out in the Karoo.

"""

from __future__ import absolute_import, division, print_function

import datetime
import os
import socket
import uptime
import numpy as np

from sqlalchemy import BigInteger, Column, DateTime, Float, String, func

from . import MCDeclarativeBase, NotNull


class HostStatus(MCDeclarativeBase):
    """A table logging the status of HERA computers.

    """
    __tablename__ = 'host_status'

    id = Column(BigInteger, primary_key=True)
    "A unique ID number for each record; no intrinsic meaning."

    time = NotNull(DateTime)
    "The time when the information was generated; stored as SqlAlchemy UTC DateTime."

    hostname = Column(String(64))
    "The hostname of the computer that this record pertains to."

    load_average = NotNull(Float)
    "The CPU load average on this host, averaged over the past 5 minutes."

    uptime = NotNull(Float)
    "How long this host has been running since it booted; measured in days."

    def __init__(self):
        """Create a new record, gathering information relevant to the machine on which
        this code is running.

        """
        self.time = datetime.datetime.utcnow()
        self.hostname = socket.gethostname()
        self.load_average = os.getloadavg()[1]
        self.uptime = uptime.uptime / 86400.

    def __repr__(self):<commit_msg>bug fix<commit_after># -*- mode: python; coding: utf-8 -*-
# Copyright 2016 the HERA Collaboration
# Licensed under the 2-clause BSD license.

"""M&C logging of the uptime, load, etc., on our computers out in the Karoo.

"""

from __future__ import absolute_import, division, print_function

import datetime
import os
import socket
import uptime
import numpy as np

from sqlalchemy import BigInteger, Column, DateTime, Float, String, func

from . import MCDeclarativeBase, NotNull


class HostStatus(MCDeclarativeBase):
    """A table logging the status of HERA computers.

    """
    __tablename__ = 'host_status'

    id = Column(BigInteger, primary_key=True)
    "A unique ID number for each record; no intrinsic meaning."

    time = NotNull(DateTime)
    "The time when the information was generated; stored as SqlAlchemy UTC DateTime."

    hostname = Column(String(64))
    "The hostname of the computer that this record pertains to."

    load_average = NotNull(Float)
    "The CPU load average on this host, averaged over the past 5 minutes."

    uptime = NotNull(Float)
    "How long this host has been running since it booted; measured in days."

    def __init__(self):
        """Create a new record, gathering information relevant to the machine on which
        this code is running.

        """
        self.time = datetime.datetime.utcnow()
        self.hostname = socket.gethostname()
        self.load_average = os.getloadavg()[1]
        self.uptime = uptime.uptime() / 86400.

    def __repr__(self):
{'fraction_non_alphanumeric': 0.08387942332896461, 'fraction_numerical': 0.009829619921363041, 'mean_word_length': 3.349002849002849, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1839736', 'n_tokens_mistral': 911, 'n_tokens_neox': 850, 'n_words': 342}