Skip to content

Commit

Permalink
Merge pull request #63 from SpiNNakerManchester/dict
Browse files Browse the repository at this point in the history
use normal dict rather than ordered dict
  • Loading branch information
dkfellows committed Apr 14, 2022
2 parents 49d9a13 + 1cb5760 commit b2e5be9
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 13 deletions.
3 changes: 1 addition & 2 deletions spalloc/scripts/alloc.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@
sent. Adding the ``--keepalive -1`` option when creating a job disables this.
"""
import argparse
from collections import OrderedDict
import logging
import os
import subprocess
Expand Down Expand Up @@ -168,7 +167,7 @@ def print_info(machine_name, connections, width, height, ip_file_filename):
"""
t_stdout = Terminal()

to_print = OrderedDict()
to_print = dict()

to_print["Hostname"] = t_stdout.bright(connections[(0, 0)])
to_print["Width"] = width
Expand Down
3 changes: 1 addition & 2 deletions spalloc/scripts/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@
their boards being powered down and re-partitioned ready for another user.
"""
import argparse
from collections import OrderedDict
import sys
from spalloc import __version__, JobState
from spalloc.term import (
Expand Down Expand Up @@ -110,7 +109,7 @@ def show_job_info(t, client, timeout, job_id):
# Get the complete job information (if the job is alive)
job_list = client.list_jobs(timeout=timeout)
job = [job for job in job_list if job["job_id"] == job_id]
info = OrderedDict()
info = dict()
info["Job ID"] = job_id

if not job:
Expand Down
4 changes: 2 additions & 2 deletions spalloc/scripts/machine.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
If the ``--watch`` option is given, the information displayed is updated in
real-time.
"""
from collections import defaultdict
import argparse
from collections import defaultdict, OrderedDict
import sys
from spalloc import __version__
from spalloc.term import (
Expand Down Expand Up @@ -149,7 +149,7 @@ def show_machine(t, machines, jobs, machine_name, compact=False):
num_in_use = sum(map(len, (job["boards"] for job in displayed_jobs)))

# Show general machine information
info = OrderedDict()
info = dict()
info["Name"] = machine["name"]
info["Tags"] = ", ".join(machine["tags"])
info["In-use"] = "{} of {}".format(num_in_use, num_boards)
Expand Down
3 changes: 1 addition & 2 deletions spalloc/scripts/where_is.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@
"""
import sys
import argparse
from collections import OrderedDict
from spalloc import __version__
from spalloc.term import render_definitions
from .support import Terminate, Script
Expand Down Expand Up @@ -145,7 +144,7 @@ def body(self, client, args): # @UnusedVariable
if location is None:
raise Terminate(4, "No boards at the specified location")

out = OrderedDict()
out = dict()
out["Machine"] = location["machine"]
out["Physical location"] = "Cabinet {}, Frame {}, Board {}".format(
*location["physical"])
Expand Down
9 changes: 4 additions & 5 deletions tests/test_term.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

from collections import OrderedDict
import pytest
from spalloc.term import (
Terminal, render_table, render_definitions, render_boards, render_cells,
Expand Down Expand Up @@ -185,13 +184,13 @@ def test_render_table():

def test_render_definitions():
# Empty case
assert render_definitions(OrderedDict()) == ""
assert render_definitions(dict()) == ""

# Singleton
assert render_definitions(OrderedDict([("foo", "bar")])) == "foo: bar"
assert render_definitions(dict([("foo", "bar")])) == "foo: bar"

# Ragged
assert render_definitions(OrderedDict([
assert render_definitions(dict([
("Key", "Value"),
("Something", "Else"),
("Another", "Thing"),
Expand All @@ -200,7 +199,7 @@ def test_render_definitions():
" Another: Thing")

# Alternative seperator
assert render_definitions(OrderedDict([("foo", "bar")]),
assert render_definitions(dict([("foo", "bar")]),
seperator="=") == "foo=bar"
# Linebreaks
assert render_definitions({"Key": "Lines\nBroken\nUp."}) == (
Expand Down

0 comments on commit b2e5be9

Please sign in to comment.