Skip to content

Commit

Permalink
Merge 019a2d1 into ee91173
Browse files Browse the repository at this point in the history
  • Loading branch information
afsafzal committed Oct 3, 2018
2 parents ee91173 + 019a2d1 commit a15a0d7
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 15 deletions.
6 changes: 3 additions & 3 deletions example/hello_world.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,15 +167,15 @@ def generate_with_se(sut, initial, environment, config, mission):
sut = houston.ardu.ArduCopter(snapshot, config)

# mission description
cmds = [
cmds = (
ArmDisarm(arm=False),
ArmDisarm(arm=True),
#SetMode(mode='GUIDED'),
Takeoff(altitude=3.0),
#GoTo(latitude=-35.361354, longitude=149.165218, altitude=5.0),
SetMode(mode='LAND'),
ArmDisarm(arm=False)
]
)

environment = Environment({})
initial = CopterState(
Expand Down Expand Up @@ -225,4 +225,4 @@ def generate_with_se(sut, initial, environment, config, mission):
generate_with_se(sut, initial, environment, config, mission)

finally:
pass
pass
16 changes: 8 additions & 8 deletions houston/mission.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
__all__ = ['Mission', 'MissionOutcome', 'CrashedMissionOutcome',
'MissionSuite']

from typing import Dict, Any, List, Iterator
from typing import Dict, Any, List, Iterator, Tuple

import attr

Expand All @@ -20,21 +20,21 @@ class Mission(object):
configuration = attr.ib(type=Configuration)
environment = attr.ib(type=Environment)
initial_state = attr.ib(type=State)
commands = attr.ib(type=List[Command]) # FIXME
commands = attr.ib(type=Tuple[Command]) # FIXME

@staticmethod
def from_dict(jsn: Dict[str, Any]) -> 'Mission':
env = Environment.from_json(jsn['environment'])
config = Configuration.from_json(jsn['configuration'])
initial_state = State.from_json(jsn['initial_state'])
cmds = [Command.from_json(c) for c in jsn['commands']]
cmds = tuple(Command.from_json(c) for c in jsn['commands'])
return Mission(config, env, initial_state, cmds)

def is_empty(self) -> bool:
"""
Returns True if this mission contains no commands.
"""
return self.commands == []
return self.commands == ()

def __iter__(self) -> Iterator[Command]:
"""
Expand All @@ -54,7 +54,7 @@ def extended(self, cmd: Command) -> 'Mission':
Returns a variant of this mission with a given command added onto the
end.
"""
cmds = self.commands + [cmd]
cmds = self.commands + (cmd,)
return Mission(self.environment, self.initial_state, cmds)

def to_dict(self) -> Dict[str, Any]:
Expand All @@ -72,13 +72,13 @@ class MissionOutcome(object):
a mission.
"""
passed = attr.ib(type=bool)
outcomes = attr.ib(type=List[CommandOutcome])
outcomes = attr.ib(type=Tuple[CommandOutcome])
time_setup = attr.ib(type=float)
time_total = attr.ib(type=float)

@staticmethod
def from_dict(dkt: Dict[str, Any]) -> 'CommandOutcome':
cmds = [CommandOutcome.from_json(a) for a in jsn['commands']]
cmds = tuple(CommandOutcome.from_json(a) for a in jsn['commands'])
return MissionOutcome(dkt['passed'],
cmds,
dkt['time_setup'],
Expand Down Expand Up @@ -132,7 +132,7 @@ def start_state(self) -> State:

class CrashedMissionOutcome(MissionOutcome):
def __init__(self, total_time: float) -> None:
super().__init__(False, [], 0.0, total_time)
super().__init__(False, (), 0.0, total_time)

def to_dict(self):
dkt = super().to_dict()
Expand Down
2 changes: 1 addition & 1 deletion houston/root_cause/root_cause.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def generate_mission(self,
for p in params:
parameters[p.name] = p.generate(rng)
cmds.append(cmd_class(**parameters))
return Mission(config, environment, initial_state, cmds)
return Mission(config, environment, initial_state, tuple(cmds))


class RootCauseFinder(object):
Expand Down
2 changes: 1 addition & 1 deletion houston/root_cause/symex.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def execute_symbolically(self, mission: Mission) -> List[Mission]:
all_missions.append(Mission(self.configuration,
self.environment,
self.initial_state,
commands_list))
tuple(commands_list)))

return all_missions

Expand Down
7 changes: 5 additions & 2 deletions houston/sandbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,12 +186,15 @@ def run(self, mission: Mission) -> MissionOutcome:
if not passed:
total_time = timer() - time_before_setup
return MissionOutcome(False,
outcomes,
tuple(outcomes),
setup_time,
total_time)

total_time = timer() - time_before_setup
return MissionOutcome(True, outcomes, setup_time, total_time)
return MissionOutcome(True,
tuple(outcomes),
setup_time,
total_time)

finally:
self._stop()
Expand Down

0 comments on commit a15a0d7

Please sign in to comment.