Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add multiple improvements. #50

Merged
merged 8 commits into from
Aug 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ htmlcov
coverage.xml
.coverage*
.python-version
generated_checker_bundle_doc.md
128 changes: 105 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,42 @@
# qc-openscenarioxml
# asam-qc-openscenarioxml

This project implements the OpenScenario Checker for the ASAM Quality Checker project.
This project implements the [ASAM OpenScenario XML Checker](checker_bundle_doc.md).

## Installation
- [asam-qc-openscenarioxml](#asam-qc-openscenarioxml)
- [Installation and usage](#installation-and-usage)
- [Installation using pip](#installation-using-pip)
- [Installation from source](#installation-from-source)
- [Default Python](#default-python)
- [Poetry](#poetry)
- [Example output](#example-output)
- [Register Checker Bundle to ASAM Quality Checker Framework](#register-checker-bundle-to-asam-quality-checker-framework)
- [Linux Manifest Template](#linux-manifest-template)
- [Tests](#tests)
- [Install using pip](#install-using-pip)
- [Install using poetry](#install-using-poetry)
- [Execute tests](#execute-tests)
- [Contributing](#contributing)

To install the project, run:

```
pip install -r requirements.txt
```
## Installation and usage

This will install the needed dependencies to your local Python.
asam-qc-openscenarioxml can be installed using pip or from source.

## Usage
### Installation using pip

The checker can be used as a Python script:
asam-qc-openscenarioxml can be installed using pip.

```bash
pip install asam-qc-openscenarioxml@git+https://github.com/asam-ev/qc-openscenarioxml@main
```
python main.py --help

**Note**: To install from different sources, you can replace `@main` with
your desired target. For example, `develop` branch as `@develop`.

To run the application:

```bash
qc_openscenario --help
usage: QC OpenScenario Checker [-h] (-d | -c CONFIG_PATH)
This is a collection of scripts for checking validity of OpenScenario (.xosc) files.
options:
Expand All @@ -26,12 +45,50 @@ options:
-c CONFIG_PATH, --config_path CONFIG_PATH
```

### Example
The following commands are equivalent:

- No issues found
```bash
qc_openscenario --help
python qc_openscenario/main.py --help
python -m qc_openscenario.main --help
```

### Installation from source

After cloning the repository, there are two options to install from source.

1. Default Python on the machine
2. [Poetry](https://python-poetry.org/)

#### Default Python

```bash
pip install -r requirements.txt
```

This will install the needed dependencies to your local Python.

#### Poetry

```bash
poetry install
```

After installing from source, the usage are similar to above.

```bash
qc_openscenario --help
python qc_openscenario/main.py --help
python -m qc_openscenario.main --help
```
python3 main.py -c example_config.xml

### Example output

- No issues found

```bash
python qc_openscenario/main.py -c example_config.xml

2024-06-12 15:14:11,864 - Initializing checks
2024-06-12 15:14:11,865 - Executing xml checks
2024-06-12 15:14:11,865 - Executing is_an_xml_document check
Expand All @@ -40,11 +97,11 @@ asam.net:xosc:0.9.0:is_an_xml_document
2024-06-12 15:14:11,865 - Done
```


- Issues found on file

```
python3 main.py -c example_config.xml
```bash
python qc_openscenario/main.py -c example_config.xml

2024-06-12 15:19:45,139 - Initializing checks
2024-06-12 15:19:45,140 - Executing xml checks
2024-06-12 15:19:45,140 - Executing is_an_xml_document check
Expand All @@ -54,24 +111,43 @@ asam.net:xosc:0.9.0:is_an_xml_document

```

## Register Checker Bundle to ASAM Quality Checker Framework

Manifest file templates are provided in the [manifest_templates](manifest_templates/) folder to register the ASAM OpenDrive Checker Bundle with the [ASAM Quality Checker Framework](https://github.com/asam-ev/qc-framework/tree/main).

### Linux Manifest Template

To register this Checker Bundle in Linux, use the [linux_manifest.json](manifest_templates/linux_manifest.json) template file. Replace the path to the Python executable `/home/user/.venv/bin/python` in the `exec_command` with the path to the Python executable where the Checker Bundle is installed.

## Tests

To run the tests, you need to have installed the main dependencies mentioned
at [Installation](#installation).
To run the tests, you need to install the extra test dependency after installing from source.

Install Python tests and development dependencies:
### Install using pip

```
```bash
pip install -r requirements-tests.txt
```

Execute tests:
### Install using poetry

```bash
poetry install --with dev
```

### Execute tests


```bash
python -m pytest -vv
```

or

```bash
poetry run pytest -vv
```

They should output something similar to:

```
Expand All @@ -86,10 +162,16 @@ You can check more options for pytest at its [own documentation](https://docs.py
For contributing, you need to install the development requirements besides the
test and installation requirements, for that run:

```
```bash
pip install -r requirements-dev.txt
```

or

```bash
poetry install --with dev
```

You need to have pre-commit installed and install the hooks:

```
Expand Down
49 changes: 49 additions & 0 deletions checker_bundle_doc.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Checker bundle: xoscBundle

* Build version: 0.1.0
* Description: ASAM OpenScenario XML checker bundle

## Parameters

* InputFile: The path of the input file.

## Checkers

### basic_xosc

* Description: Check if basic properties of input file are properly set
* Addressed rules:
* asam.net:xosc:1.0.0:xml.valid_xml_document

### schema_xosc

* Description: Check if xml properties of input file are properly set
* Addressed rules:
* asam.net:xosc:1.0.0:xml.valid_schema

### reference_xosc

* Description: Check if xml properties of input file are properly set
* Addressed rules:
* asam.net:xosc:1.2.0:reference_control.uniquely_resolvable_entity_references
* asam.net:xosc:1.2.0:reference_control.resolvable_signal_id_in_traffic_signal_state_action
* asam.net:xosc:1.2.0:reference_control.resolvable_traffic_signal_controller_by_traffic_signal_controller_ref
* asam.net:xosc:1.2.0:reference_control.valid_actor_reference_in_private_actions
* asam.net:xosc:1.2.0:reference_control.resolvable_entity_references
* asam.net:xosc:1.2.0:reference_control.resolvable_variable_reference
* asam.net:xosc:1.2.0:reference_control.resolvable_storyboard_element_reference
* asam.net:xosc:1.2.0:reference_control.unique_element_names_on_same_level

### parameters_xosc

* Description: Check if parameters properties of input file are properly set
* Addressed rules:
* asam.net:xosc:1.2.0:parameters.valid_parameter_declaration_in_catalogs

### data_type_xosc

* Description: Check if data_type properties of input file are properly set
* Addressed rules:
* asam.net:xosc:1.2.0:data_type.allowed_operators
* asam.net:xosc:1.2.0:data_type.non_negative_transition_time_in_light_state_action
* asam.net:xosc:1.2.0:data_type.positive_duration_in_phase
10 changes: 10 additions & 0 deletions manifest_templates/linux_manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"module": [
{
"name": "xoscBundle",
"exec_type": "executable",
"module_type": "checker_bundle",
"exec_command": "cd $ASAM_QC_FRAMEWORK_WORKING_DIR && /home/user/.venv/bin/python -m qc_openscenario.main -c $ASAM_QC_FRAMEWORK_CONFIG_FILE"
}
]
}
Loading