Skip to content

Commit

Permalink
Remove 3.8 greater code.
Browse files Browse the repository at this point in the history
  • Loading branch information
Gamenot committed Nov 4, 2022
1 parent e16032f commit 67289f9
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
1 change: 0 additions & 1 deletion smarts/core/agent_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,6 @@ def observe(
}

sim_frame = sim.cached_frame
print(f"{self.active_agents=}-{sim_frame.agent_ids=}")
for agent_id in self.active_agents:
# An agent may be pointing to its own vehicle or observing a social vehicle
vehicle_ids = self._vehicle_index.vehicle_ids_by_actor_id(
Expand Down
2 changes: 1 addition & 1 deletion smarts/core/sensors.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ def observe_parallel(
)
used_workers: List[SensorsWorker] = []
with timeit(
f"parallizable observations with {len(agent_ids)=} and {len(workers)=}",
f"parallizable observations with {len(agent_ids)} and {len(workers)}",
print,
):
if len(workers) >= 1:
Expand Down
20 changes: 11 additions & 9 deletions smarts/core/tests/test_parallel_sensors.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
from smarts.core.plan import Mission
from smarts.core.road_map import RoadMap
from smarts.core.scenario import Scenario
from smarts.core.sensors import Observation, Sensors, SensorState, SensorsWorker
from smarts.core.sensors import Observation, Sensors, SensorState, SensorsWorker, WorkerKwargs
from smarts.core.simulation_frame import SimulationFrame
from smarts.core.simulation_local_constants import SimulationLocalConstants
from smarts.core.smarts import SMARTS
Expand Down Expand Up @@ -152,24 +152,26 @@ def observe_with_processes(processes):
serial_total > parallel_1_total
or serial_total > parallel_2_total
or serial_total > parallel_3_total
), f"{serial_total=}, {parallel_1_total=}, {parallel_2_total=}, {parallel_3_total=} {parallel_4_total=}"
), f"{serial_total}, {parallel_1_total}, {parallel_2_total}, {parallel_3_total} {parallel_4_total}"


def test_sensor_worker(
simulation_frame: SimulationState,
sim: SMARTS,
):
return
del sim.cached_frame
simulation_frame: SimulationFrame = sim.cached_frame
agent_ids = set(AGENT_IDS)
worker = SensorsWorker()
worker.run()
worker.send_to_process(simulation_frame, agent_ids)
observations, dones = SensorsWorker.local(simulation_frame, agent_ids)
other_observations, other_dones = worker.result(block=True)
worker.run(sim_local_constants=sim.local_constants)
worker_args = WorkerKwargs(sim_frame=simulation_frame)
worker.send_to_process(worker_args=worker_args, agent_ids=agent_ids)
observations, dones = SensorsWorker.local(simulation_frame, sim.local_constants, agent_ids)
other_observations, other_dones = worker.result(block=True, timeout=5)

assert isinstance(observations, dict)
assert all(
[isinstance(obs, Observation) for obs in observations.values()]
), f"{observations=}"
), f"{observations}"
assert isinstance(dones, dict)
assert all([isinstance(obs, bool) for obs in dones.values()])
assert isinstance(other_observations, dict)
Expand Down

0 comments on commit 67289f9

Please sign in to comment.