Skip to content

Commit

Permalink
Workflow improvements and code quality passing (#1052)
Browse files Browse the repository at this point in the history
* CI: Checkout v4 and unit tests name correction

* Small tweaks to ensure Code Quality passes

---------

Co-authored-by: glopezdiest <[email protected]>
  • Loading branch information
jeroenlammersma and glopezdiest committed Apr 26, 2024
1 parent a762135 commit db40fb7
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 13 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/static_code_check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
runs-on: ubuntu-20.04

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Install Dependencies
run: |
Expand All @@ -35,7 +35,7 @@ jobs:
runs-on: ubuntu-20.04

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Install Dependencies
run: |
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/unit_test.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Static Code Analysis
name: Unit Tests

on:
push:
Expand All @@ -12,7 +12,7 @@ jobs:
runs-on: ubuntu-20.04

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Install Dependencies
run: |
Expand Down
4 changes: 3 additions & 1 deletion srunner/scenariomanager/carla_data_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,8 +303,10 @@ def find_weather_presets():
"""
Get weather presets from CARLA
"""
def name(string):
return ' '.join(m.group(0) for m in rgx.finditer(string))

rgx = re.compile('.+?(?:(?<=[a-z])(?=[A-Z])|(?<=[A-Z])(?=[A-Z][a-z])|$)')
name = lambda x: ' '.join(m.group(0) for m in rgx.finditer(x))
presets = [x for x in dir(carla.WeatherParameters) if re.match('[A-Z].+', x)]
return [(getattr(carla.WeatherParameters, x), name(x)) for x in presets]

Expand Down
10 changes: 5 additions & 5 deletions srunner/scenariomanager/scenarioatomics/atomic_behaviors.py
Original file line number Diff line number Diff line change
Expand Up @@ -797,9 +797,9 @@ def initialise(self):
# At the moment everything besides "shortest" will use the CARLA GlobalPlanner
grp = CarlaDataProvider.get_global_route_planner()
route = []
for i, _ in enumerate(carla_route_elements):
if carla_route_elements[i][1] == "shortest":
route.append(carla_route_elements[i][0])
for i, element in enumerate(carla_route_elements):
if element[1] == "shortest":
route.append(element[0])
else:
if i == 0:
mmap = CarlaDataProvider.get_map()
Expand All @@ -812,12 +812,12 @@ def initialise(self):
waypoint = ego_next_wp.transform.location
else:
waypoint = carla_route_elements[i - 1][0].location
waypoint_next = carla_route_elements[i][0].location
waypoint_next = element[0].location
try:
interpolated_trace = grp.trace_route(waypoint, waypoint_next)
except networkx.NetworkXNoPath:
print("WARNING: No route from {} to {} - Using direct path instead".format(waypoint, waypoint_next))
route.append(carla_route_elements[i][0])
route.append(element[0])
continue
for wp_tuple in interpolated_trace:
# The router sometimes produces points that go backward, or are almost identical
Expand Down
6 changes: 3 additions & 3 deletions srunner/scenarios/open_scenario.py
Original file line number Diff line number Diff line change
Expand Up @@ -392,9 +392,9 @@ def _create_behavior(self):
for actor in sequence.iter("Actors"):
for entity in actor.iter("EntityRef"):
entity_name = entity.attrib.get('entityRef', None)
for k, _ in enumerate(joint_actor_list):
if (joint_actor_list[k] and
entity_name == joint_actor_list[k].attributes['role_name']):
for k, actor in enumerate(joint_actor_list):
if (actor and
entity_name == actor.attributes['role_name']):
actor_ids.append(k)
break

Expand Down

0 comments on commit db40fb7

Please sign in to comment.