diff options
| author | Georgios Andreadis <g.andreadis@student.tudelft.nl> | 2017-09-25 13:50:49 +0200 |
|---|---|---|
| committer | Georgios Andreadis <g.andreadis@student.tudelft.nl> | 2017-09-25 13:50:49 +0200 |
| commit | a1589e75358558eada7ffc2efc7e3fa7160d233e (patch) | |
| tree | 7889a2364292cd8b90fe996da7907bebf200d3dc /opendc/models/machine_state.py | |
| parent | 1f34466d41ba01a3dd36b0866696367d397daf7e (diff) | |
Reformat codebase and fix spelling errors
Diffstat (limited to 'opendc/models/machine_state.py')
| -rw-r--r-- | opendc/models/machine_state.py | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/opendc/models/machine_state.py b/opendc/models/machine_state.py index 693b57d2..7f19ba01 100644 --- a/opendc/models/machine_state.py +++ b/opendc/models/machine_state.py @@ -1,8 +1,8 @@ from opendc.models.model import Model from opendc.util import database -class MachineState(Model): +class MachineState(Model): JSON_TO_PYTHON_DICT = { 'MachineState': { 'taskId': 'task_id', @@ -15,21 +15,22 @@ class MachineState(Model): } TABLE_NAME = 'machine_states' - COLUMNS = ['id', 'task_id', 'machine_id', 'experiment_id', 'tick', 'temperature_c', 'in_use_memory_mb', 'load_fraction'] + COLUMNS = ['id', 'task_id', 'machine_id', 'experiment_id', 'tick', 'temperature_c', 'in_use_memory_mb', + 'load_fraction'] - COLUMNS_PRIMARY_KEY= ['id'] + COLUMNS_PRIMARY_KEY = ['id'] @classmethod def _from_database_row(cls, row): """Instantiate a MachineState from a database row (including tick from the TaskState).""" return cls( - task_id = row[1], - machine_id = row[2], - temperature_c = row[5], - in_use_memory_mb = row[6], - load_fraction = row[7], - tick = row[4] + task_id=row[1], + machine_id=row[2], + temperature_c=row[5], + in_use_memory_mb=row[6], + load_fraction=row[7], + tick=row[4] ) @classmethod @@ -37,11 +38,11 @@ class MachineState(Model): """Query MachineStates by their Experiment id.""" machine_states = [] - + statement = 'SELECT * FROM machine_states WHERE experiment_id = %s' results = database.fetchall(statement, (experiment_id,)) - - for row in results: + + for row in results: machine_states.append(cls._from_database_row(row)) return machine_states @@ -51,11 +52,11 @@ class MachineState(Model): """Query MachineStates by their Experiment id and tick.""" machine_states = [] - + statement = 'SELECT * FROM machine_states WHERE experiment_id = %s AND machine_states.tick = %s' results = database.fetchall(statement, (experiment_id, tick)) - - for row in results: + + for row in results: machine_states.append(cls._from_database_row(row)) return machine_states |
