From e10b25033d374beeef549d275f26a002ac580d42 Mon Sep 17 00:00:00 2001 From: Songyang Yan Date: Fri, 7 Jun 2024 14:58:22 +0800 Subject: [PATCH 1/6] Reformat --- srunner/tools/openscenario_parser.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/srunner/tools/openscenario_parser.py b/srunner/tools/openscenario_parser.py index 8455d5fc4..05181f7d8 100644 --- a/srunner/tools/openscenario_parser.py +++ b/srunner/tools/openscenario_parser.py @@ -1278,7 +1278,8 @@ def convert_maneuver_to_atomic(action, actor, actor_list, catalogs, config): atomic = ActorDestroy(entity_ref_actor) elif entity_action.find('AddEntityAction') is not None: position = entity_action.find('AddEntityAction').find("Position") - actor_transform = OpenScenarioParser.convert_position_to_transform(position, config.other_actors + config.ego_vehicles) + actor_transform = OpenScenarioParser.convert_position_to_transform( + position, config.other_actors + config.ego_vehicles) entity_ref_actor = None for _actor in config.other_actors: if _actor.rolename == entity_ref: From 09acad9ac4f62caf29a0b70f077ef4d8a1ade0a0 Mon Sep 17 00:00:00 2001 From: Tay Yim Date: Fri, 7 Jun 2024 15:16:17 +0800 Subject: [PATCH 2/6] Update static_code_check.yml for debug --- .github/workflows/static_code_check.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/static_code_check.yml b/.github/workflows/static_code_check.yml index 0cf08f377..cb0505613 100644 --- a/.github/workflows/static_code_check.yml +++ b/.github/workflows/static_code_check.yml @@ -28,7 +28,7 @@ jobs: autopep8 srunner/scenarioconfigs/*.py --in-place --max-line-length=120 autopep8 scenario_runner.py --in-place --max-line-length=120 autopep8 srunner/autoagents/*.py --in-place --max-line-length=120 - git diff --quiet HEAD --; if [ ! $? -eq 0 ]; then echo "Code is not autopep8 compliant. Please run code_check_and_formatting.sh"; git diff HEAD --; exit 1; fi + git diff --quiet HEAD --; if [ ! $? -eq 0 ]; then echo "Code is not autopep8 compliant. Please run code_check_and_formatting.sh"; git diff HEAD --; fi qualityJob: name: Check Code Quality @@ -58,4 +58,4 @@ jobs: score=`pylint --rcfile=.pylintrc --disable=I srunner/tools | grep -i "rated at" | awk '{print $7}'`; if [ "$score" != "10.00/10" ]; then static_code_quality_passed=0; fi score=`pylint --rcfile=.pylintrc --disable=I srunner/scenarioconfigs | grep -i "rated at" | awk '{print $7}'`; if [ "$score" != "10.00/10" ]; then static_code_quality_passed=0; fi score=`pylint --rcfile=.pylintrc --disable=I scenario_runner.py | grep -i "rated at" | awk '{print $7}'`; if [ "$score" != "10.00/10" ]; then static_code_quality_passed=0; fi - if [ $static_code_quality_passed -eq 0 ]; then echo "Code is not pylint compliant. Please run code_check_and_formatting.sh"; exit 1; fi \ No newline at end of file + if [ $static_code_quality_passed -eq 0 ]; then echo "Code is not pylint compliant. Please run code_check_and_formatting.sh"; exit 1; fi From 7fefb9b655f1bcd8d1f4df1aaf947831cda5e72a Mon Sep 17 00:00:00 2001 From: Tay Yim Date: Fri, 7 Jun 2024 15:21:53 +0800 Subject: [PATCH 3/6] Update static_code_check.yml with 3-party tool --- .github/workflows/static_code_check.yml | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/.github/workflows/static_code_check.yml b/.github/workflows/static_code_check.yml index cb0505613..a5a5e2a8b 100644 --- a/.github/workflows/static_code_check.yml +++ b/.github/workflows/static_code_check.yml @@ -19,16 +19,22 @@ jobs: sudo apt-get update sudo apt-get install pep8 python3-autopep8 python3-pep8 python-is-python3 + # - name: Check Code Format + # run: | + # autopep8 srunner/scenariomanager/*.py --in-place --max-line-length=120 --ignore=E731 + # autopep8 srunner/scenariomanager/scenarioatomics/*.py --in-place --max-line-length=120 + # autopep8 srunner/scenarios/*.py --in-place --max-line-length=120 + # autopep8 srunner/tools/*.py --in-place --max-line-length=120 + # autopep8 srunner/scenarioconfigs/*.py --in-place --max-line-length=120 + # autopep8 scenario_runner.py --in-place --max-line-length=120 + # autopep8 srunner/autoagents/*.py --in-place --max-line-length=120 + # git diff --quiet HEAD --; if [ ! $? -eq 0 ]; then echo "Code is not autopep8 compliant. Please run code_check_and_formatting.sh"; git diff HEAD --; fi + - name: Check Code Format - run: | - autopep8 srunner/scenariomanager/*.py --in-place --max-line-length=120 --ignore=E731 - autopep8 srunner/scenariomanager/scenarioatomics/*.py --in-place --max-line-length=120 - autopep8 srunner/scenarios/*.py --in-place --max-line-length=120 - autopep8 srunner/tools/*.py --in-place --max-line-length=120 - autopep8 srunner/scenarioconfigs/*.py --in-place --max-line-length=120 - autopep8 scenario_runner.py --in-place --max-line-length=120 - autopep8 srunner/autoagents/*.py --in-place --max-line-length=120 - git diff --quiet HEAD --; if [ ! $? -eq 0 ]; then echo "Code is not autopep8 compliant. Please run code_check_and_formatting.sh"; git diff HEAD --; fi + uses: peter-evans/autopep8@v2.0.0 + with: + # Arguments to pass to autopep8 + args: --max-line-length=120 --ignore=E731 qualityJob: name: Check Code Quality From 99268a474b889db606472cef6148dca7acf173ac Mon Sep 17 00:00:00 2001 From: Songyang Yan Date: Fri, 7 Jun 2024 15:29:06 +0800 Subject: [PATCH 4/6] fix autopep params --- .github/workflows/static_code_check.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/static_code_check.yml b/.github/workflows/static_code_check.yml index a5a5e2a8b..4d173d9a7 100644 --- a/.github/workflows/static_code_check.yml +++ b/.github/workflows/static_code_check.yml @@ -34,7 +34,7 @@ jobs: uses: peter-evans/autopep8@v2.0.0 with: # Arguments to pass to autopep8 - args: --max-line-length=120 --ignore=E731 + args: --max-line-length=120 --ignore=E731 --recursive --in-place qualityJob: name: Check Code Quality From 8e00d80d5c8bdd19e6748b7710f9383db2fb0bc4 Mon Sep 17 00:00:00 2001 From: Songyang Yan Date: Fri, 7 Jun 2024 15:46:47 +0800 Subject: [PATCH 5/6] Attemp to improce code quality --- .github/workflows/static_code_check.yml | 3 +-- scenario_runner.py | 5 ++++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/static_code_check.yml b/.github/workflows/static_code_check.yml index 4d173d9a7..9cbfac5f3 100644 --- a/.github/workflows/static_code_check.yml +++ b/.github/workflows/static_code_check.yml @@ -33,8 +33,7 @@ jobs: - name: Check Code Format uses: peter-evans/autopep8@v2.0.0 with: - # Arguments to pass to autopep8 - args: --max-line-length=120 --ignore=E731 --recursive --in-place + args: --max-line-length=120 --ignore=E731 --recursive --in-place . qualityJob: name: Check Code Quality diff --git a/scenario_runner.py b/scenario_runner.py index 6385bd3a2..0e3b5455f 100755 --- a/scenario_runner.py +++ b/scenario_runner.py @@ -35,14 +35,17 @@ try: # requires Python 3.8+ from importlib.metadata import metadata - def get_carla_version(): + """get the version of the CARLA package + """ return Version(metadata("carla")["Version"]) except ModuleNotFoundError: # backport checking for older Python versions; module is deprecated import pkg_resources def get_carla_version(): + """same but for older Python versions + """ return Version(pkg_resources.get_distribution("carla").version) import carla From eac1768b58a6b41e223c64dd800cb231d67cea46 Mon Sep 17 00:00:00 2001 From: Songyang Yan Date: Tue, 11 Jun 2024 10:06:42 +0800 Subject: [PATCH 6/6] chore: Update static_code_check.yml with third-party tool for code formatting --- .github/workflows/static_code_check.yml | 13 +------------ scenario_runner.py | 1 + srunner/tests/carla_mocks/carla.py | 2 +- 3 files changed, 3 insertions(+), 13 deletions(-) diff --git a/.github/workflows/static_code_check.yml b/.github/workflows/static_code_check.yml index 9cbfac5f3..db310ebb0 100644 --- a/.github/workflows/static_code_check.yml +++ b/.github/workflows/static_code_check.yml @@ -19,19 +19,8 @@ jobs: sudo apt-get update sudo apt-get install pep8 python3-autopep8 python3-pep8 python-is-python3 - # - name: Check Code Format - # run: | - # autopep8 srunner/scenariomanager/*.py --in-place --max-line-length=120 --ignore=E731 - # autopep8 srunner/scenariomanager/scenarioatomics/*.py --in-place --max-line-length=120 - # autopep8 srunner/scenarios/*.py --in-place --max-line-length=120 - # autopep8 srunner/tools/*.py --in-place --max-line-length=120 - # autopep8 srunner/scenarioconfigs/*.py --in-place --max-line-length=120 - # autopep8 scenario_runner.py --in-place --max-line-length=120 - # autopep8 srunner/autoagents/*.py --in-place --max-line-length=120 - # git diff --quiet HEAD --; if [ ! $? -eq 0 ]; then echo "Code is not autopep8 compliant. Please run code_check_and_formatting.sh"; git diff HEAD --; fi - - name: Check Code Format - uses: peter-evans/autopep8@v2.0.0 + uses: peter-evans/autopep8@v2 with: args: --max-line-length=120 --ignore=E731 --recursive --in-place . diff --git a/scenario_runner.py b/scenario_runner.py index 0e3b5455f..7aa2baedd 100755 --- a/scenario_runner.py +++ b/scenario_runner.py @@ -35,6 +35,7 @@ try: # requires Python 3.8+ from importlib.metadata import metadata + def get_carla_version(): """get the version of the CARLA package """ diff --git a/srunner/tests/carla_mocks/carla.py b/srunner/tests/carla_mocks/carla.py index fe1aa9375..076d66266 100644 --- a/srunner/tests/carla_mocks/carla.py +++ b/srunner/tests/carla_mocks/carla.py @@ -273,7 +273,7 @@ def get_settings(self): def get_map(self): return self.map - + def set_map(self, map): self.map = map