Esempio n. 1
0
class Run(BaseModel):
    FAILED = -2
    CANCELED = -1
    PENDING = 0
    SUBMITTED = 1
    RUNNING = 2
    DONE = 3

    STATUS_CHOICES = (
        (FAILED, "Failed"),
        (CANCELED, "Canceled"),
        (PENDING, "Pending"),
        (SUBMITTED, "Submitted"),
        (RUNNING, "Running"),
        (DONE, "Done"),
    )

    id = CharField(null=True, primary_key=True)
    created_at = DateTimeField(default=datetime.now)
    tool = ForeignKeyField(Tool, backref="runs")
    tool_version = CharField(null=True)
    parameter_group = ForeignKeyField(ParameterGroup, backref="runs")
    task = ForeignKeyField(Task, backref="runs")
    status = IntegerField(choices=STATUS_CHOICES, default=PENDING)
    last_step = ForeignKeyField(Step, null=True)
    iteration = IntegerField(default=0)
Esempio n. 2
0
class Event(ObraModel):
    """
    A single race day - may be standalone or part of a series.
    """
    id = IntegerField(verbose_name='Event ID', primary_key=True)
    name = CharField(verbose_name='Event Name')
    discipline = CharField(verbose_name='Event Discipline', index=True)
    year = IntegerField(verbose_name='Event Year')
    date = CharField(verbose_name='Event Month/Day')
    series = ForeignKeyField(verbose_name='Event Series',
                             model=Series,
                             backref='events',
                             on_update='RESTRICT',
                             on_delete='RESTRICT',
                             null=True)
    parent = ForeignKeyField(verbose_name='Child Events',
                             model='self',
                             backref='children',
                             on_update='RESTRICT',
                             on_delete='RESTRICT',
                             null=True)
    ignore = BooleanField(verbose_name='Ignore/Hide Event', default=False)

    @property
    def discipline_title(self):
        return self.discipline.replace('_', ' ').title()
Esempio n. 3
0
class Character(BaseModel):
    name = TextField()
    stand = TextField(default=None, null=True)
    part = IntegerField()
    manga_debut = IntegerField(default=None, null=True)
    anime_debut = IntegerField(default=None, null=True)
    wiki = TextField(default=None, null=True)
    comment = TextField(default=None, null=True)
Esempio n. 4
0
class Series(ObraModel):
    """
    An OBRA race series spanning multiple events over more than one day.
    """
    id = IntegerField(verbose_name='Series ID', primary_key=True)
    name = CharField(verbose_name='Series Name')
    year = IntegerField(verbose_name='Series Year')
    dates = CharField(verbose_name='Series Months/Days')
Esempio n. 5
0
class Node(BaseModel):
    hostname = CharField(primary_key=True)
    platform = CharField(null=True)
    arch = CharField(null=True)
    python = CharField(null=True)
    cpu = CharField(null=True)
    cpu_count = IntegerField(null=True)
    cpu_min_freq = FloatField(null=True)
    cpu_max_freq = FloatField(null=True)
    mem_total = IntegerField(null=True)
    mem_available = IntegerField(null=True)
    swap_total = IntegerField(null=True)
    swap_available = IntegerField(null=True)
Esempio n. 6
0
class Race(ObraModel):
    """
    A single race at an event, with one or more results.
    """
    id = IntegerField(verbose_name='Race ID', primary_key=True)
    name = CharField(verbose_name='Race Name', index=True)
    date = DateField(verbose_name='Race Date')
    categories = JSONField(verbose_name='Race Categories')
    starters = IntegerField(verbose_name='Race Starting Field Size', default=0)
    created = DateTimeField(verbose_name='Results Created')
    updated = DateTimeField(verbose_name='Results Updated')
    event = ForeignKeyField(verbose_name='Race Event',
                            model=Event,
                            backref='races',
                            on_update='RESTRICT',
                            on_delete='RESTRICT')
Esempio n. 7
0
class RunStatistic(BaseModel):
    TIMEOUT = "TLE"
    MEMOUT = "MEM"
    RUNTIME_ERR = "RTE"
    OUTPUT_LIMIT = "OLE"
    SUCCESS = "OK"

    VERDICT_CHOICES = (
        (TIMEOUT, "Time Limit Exceeded"),
        (MEMOUT, "Memory Limit Exceeded"),
        (RUNTIME_ERR, "Runtime Error"),
        (OUTPUT_LIMIT, "Output Limit Exceeded"),
        (SUCCESS, "Run Successfully"),
    )

    created_at = DateTimeField(default=datetime.now)
    run = ForeignKeyField(Run,
                          backref="statistics",
                          on_delete="cascade",
                          primary_key=True)
    cpu_time = FloatField(help_text="CPU Time (s)", null=True)
    wall_time = FloatField(help_text="Wall Clock Time (s)", null=True)
    max_memory = FloatField(help_text="Max Memory Usage (KiB)", null=True)
    return_code = IntegerField(help_text="Process Return Code", null=True)
    verdict = CharField(choices=VERDICT_CHOICES, max_length=3, null=True)
Esempio n. 8
0
class Person(ObraModel):
    """
    A person who participated in a race.
    """
    id = IntegerField(verbose_name='Person ID', primary_key=True)
    first_name = CharField(verbose_name='First Name')
    last_name = CharField(verbose_name='Last Name')
    team_name = CharField(verbose_name='Team Name', default='')
class RawSentences(BaseModel):
    date_time = TextField(db_column='DATE_TIME', null=True)
    deployed_equipment = IntegerField(db_column='DEPLOYED_EQUIPMENT_ID',
                                      null=True)
    raw_sentence = TextField(db_column='RAW_SENTENCE', null=True)
    raw_sentence_id = PrimaryKeyField(db_column='RAW_SENTENCE_ID')

    class Meta:
        db_table = 'RAW_SENTENCES'
Esempio n. 10
0
class Result(ObraModel):
    """
    An individual race result - a Person's place in a specific Race.
    """
    id = IntegerField(verbose_name='Result ID', primary_key=True)
    race = ForeignKeyField(verbose_name='Result Race',
                           model=Race,
                           backref='results',
                           on_update='RESTRICT',
                           on_delete='RESTRICT')
    person = ForeignKeyField(verbose_name='Result Person',
                             model=Person,
                             backref='results',
                             on_update='RESTRICT',
                             on_delete='RESTRICT',
                             null=True)
    place = CharField(verbose_name='Place', index=True)
    time = IntegerField(verbose_name='Time', null=True)
    laps = IntegerField(verbose_name='Laps', null=True)
class EnviroNetRawStrings(BaseModel):
    date_time = TextField(db_column='DATE_TIME', index=True, null=True)
    deployed_equipment = IntegerField(db_column='DEPLOYED_EQUIPMENT_ID',
                                      null=True)
    enviro_net_raw_strings = PrimaryKeyField(
        db_column='ENVIRO_NET_RAW_STRINGS_ID')
    haul = TextField(db_column='HAUL_ID', null=True)
    raw_strings = TextField(db_column='RAW_STRINGS', null=True)

    class Meta:
        db_table = 'ENVIRO_NET_RAW_STRINGS'
class EnviroNetRawFiles(BaseModel):
    activation_datetime = TextField(db_column='ACTIVATION_DATETIME', null=True)
    deactivation_datetime = TextField(db_column='DEACTIVATION_DATETIME',
                                      null=True)
    deployed_equipment = IntegerField(db_column='DEPLOYED_EQUIPMENT_ID',
                                      null=True)
    enviro_net_raw_files = PrimaryKeyField(db_column='ENVIRO_NET_RAW_FILES_ID')
    haul = TextField(db_column='HAUL_ID', null=True)
    raw_file = TextField(db_column='RAW_FILE', null=True)

    class Meta:
        db_table = 'ENVIRO_NET_RAW_FILES'
Esempio n. 13
0
class Points(ObraModel):
    """
    Points toward a category upgrade - awarded for a good Result in a Race of a specific size.
    """
    result = ForeignKeyField(verbose_name='Result awarding Upgrade Points',
                             model=Result,
                             backref='points',
                             on_update='RESTRICT',
                             on_delete='RESTRICT',
                             primary_key=True)
    value = CharField(verbose_name='Points Earned for Result', default='0')
    notes = CharField(verbose_name='Notes', default='')
    needs_upgrade = BooleanField(verbose_name='Needs Upgrade', default=False)
    upgrade_confirmation = ForeignKeyField(
        verbose_name='Member Data Confirming Upgrade',
        model=ObraPersonSnapshot,
        backref='points',
        null=True)
    sum_value = IntegerField(verbose_name='Current Points Sum', default=0)
    sum_categories = JSONField(verbose_name='Current Category', default=[])
Esempio n. 14
0
class ObraPersonSnapshot(ObraModel):
    """
    A point in time record of OBRA member data.
    The OBRA website doesn't make historical data available, so we store a timestamped
    copy every time we do a lookup. Doesn't help with really old upgrades, but it should
    be useful going forward.
    """
    id = AutoField(verbose_name='Scrape ID', primary_key=True)
    date = DateField(verbose_name='Scrape Date')
    person = ForeignKeyField(verbose_name='Person',
                             model=Person,
                             backref='obra',
                             on_update='RESTRICT',
                             on_delete='RESTRICT')
    license = IntegerField(verbose_name='License', null=True)
    mtb_category = IntegerField(verbose_name='MTB Category', default=3)
    dh_category = IntegerField(verbose_name='DH Category', default=3)
    ccx_category = IntegerField(verbose_name='CX Category', default=5)
    road_category = IntegerField(verbose_name='Road Category', default=5)
    track_category = IntegerField(verbose_name='Track Category', default=5)

    class Meta:
        indexes = ((('date', 'person'), True), )

    def category_for_discipline(self, discipline):
        discipline = discipline.replace('mountain_bike', 'mtb')
        discipline = discipline.replace('short_track', 'mtb')
        discipline = discipline.replace('cyclocross', 'ccx')
        discipline = discipline.replace('criterium', 'road')
        discipline = discipline.replace('time_trial', 'road')
        discipline = discipline.replace('circuit', 'road')
        discipline = discipline.replace('gran_fondo', 'road')
        discipline = discipline.replace('gravel', 'road')
        discipline = discipline.replace('tour', 'road')
        discipline = discipline.replace('downhill', 'dh')
        discipline = discipline.replace('super_d', 'dh')
        return getattr(self, discipline + '_category')