-
Notifications
You must be signed in to change notification settings - Fork 26
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
DevOps Dojo: CI - JSON Schema Validation of YAML Parameter File(s) #232
Comments
I spoke to @ambroise-arm earlier today. Arm is willing to take this issue on and with your input and feedback, add the validation into GitHub Actions. |
json-yaml-validate might be a better option since frontmatter-json-schema-validator is for YAML front matter. Maybe we can also use the same action to validate the JSON files too. |
autowarefoundation/autoware.universe#4002 is a PR for validating the JSON Schema files against their meta-schema. This is the first half of the work. The other half is validating the yaml configuration files against the schema files, I still need to look at that. EDIT: I am not using the suggested json-yaml-validate for that because it is designed to take in a single schema to validate multiple files against. Whereas our usecase is to have multiple pairs of yaml/json where we want to validate each yaml config file against its associated json schema. |
@ambroise-arm thanks for taking this on! There might be cases where the are more than one |
The GitHub action which validates the parameter file using the schema is now merged! |
Find the GitHub action running here: https://github.com/autowarefoundation/autoware.universe/actions/workflows/json-schema-check.yaml |
@KYabuuchi thanks for your comment and helping us create a more rigid way with the parameters aspect of Autoware. I'm not quite following your thought process and I don't understand where the complication is. I've tried to describe the process in a few bullet points:
Am I addressing the issue with these bullet points? We have not yet started the DevOps Dojo: ROS Node Launch. I do believe that overwriting parameters can be useful but also has risks, as you also mention. As soon as a parameter is configured outside of the parameter file, it cannot be validated by the schema, or at least not with how we validate parameter files today. |
@kaspermeck-arm Thank you for describing. I noticed that a PR has been developed to address case 3 of my concerns. This will eventually be resolved. 👍 However, the bullet points do not consider nodes that load multiple parameter files. Some nodes store their parameters in separate files and load multiple parameter files during launch. For example, probabilistic_occupancy_grid_map loads two files. Additionally, parameter overrides within launch files might lead to misunderstandings and bugs. Nevertheless, removing parameters determined at startup is challenging, so it would be helpful to have a method for handling this on the validation side. |
Just to understand.
|
In cases where developers want to prepare presets corresponding to several modes, they create multiple parameter files. Moreover, when some parameters are shared with other nodes, multiple parameter files may also be passed to a node.
The paths for maps and DNN models and the localization mode are provided by the user during startup. |
and parameter file
|
Yes, It is one way to resolve this. But I think the launch_ros rules in https://github.com/ros2/launch_ros/blob/humble/launch_ros/launch_ros/actions/node.py#L175-L182 are not that complex. And they would allow to keep all schema fields as required, even if some of the parameter from the config file are meant to always be overridden. In order to avoid bugs, I think the only thing we need to ensure is that the default parameter file of a package uses a "/**" namespace, which should already be enforced in the schema files (for example: https://github.com/autowarefoundation/autoware.universe/blob/main/perception/lidar_apollo_segmentation_tvm_nodes/schema/lidar_apollo_segmentation_tvm_nodes.schema.json#L87). It may indeed hurt clarity, as changing some of the values of the package's parameter file will have an effect, but not for others. But I think it is already not clear where parameters are set and how they are propagated in launch files, so it seems like a minor issue to me. Also about validating multiple parameter files, I think the goal was never to validate the parameter files held by the launch packages. So I don't think multiple parameter file is an issue beyond validating those default parameters files. Please someone correct me if my assumption is incorrect. And keeping all fields required seems especially important if we intend to rework the launch files in the future, as it keeps things clean and consistent. (but also I am not in charge of maintaining the launch and parameter files working well together, and I understand the reluctance to change what currently works)
It might, but I don't think we want to introduce another way to set parameters. |
Sorry, is this method actually valid for ros2 node? I have never seen this approach, and when I tried it, the variables were passed as strings without being interpreted. Even if it is a valid method, I also do not think we want to introduce a new way to set parameters. |
I suggest the following:
Schema:
and parameter file:
Which will be overwritten using:
Does this sound OK? |
@KYabuuchi Yes, you just need to allow the launch file to interpret it correctly. See yolo_v2_tiny_example.param.yaml and
@kaspermeck-arm I think the point of @KYabuuchi was that those For the data path of the artifacts, I think the yolo_v2_tiny links above are also a very good example of what can be done then. But then I think there is a distinction between using |
@KYabuuchi - I aligned with @ambroise-arm and this is our proposal. All parameters which are expected to be used in a node must exist in the schema and parameter file according to the contribution guide. This is necessary for rendering the table view in the documentation and for testing purposes. There is nothing preventing multiple parameter files in the launch file. The yolov2 tiny example resolves the environmental parameter issue. In the schema the
And the corresponding parameter file
Finally, in the launch file the following line needs to be added:
Note Does this solve the problems which you're facing? |
@kaspermeck-arm Thank you for explaining the method using environment variables. But, it is difficult for me to judge whether that method is appropriate or not. |
@KYabuuchi - that's a good point that this could be a larger discussion. I'll bring this topic up in the next OADK meeting! In my opinion there is no technical difference to setting the environmental parameters in the parameter file vs the launch file. It is however more transparent and follows the current contribution implementation details to do this in the parameter file. |
When and who performs the variable substitution here? As late as node initialization or at an earlier step? |
@doganulus - my understanding is that it's resolved when running the |
Launch configuration can also be used. I think this is easier to use because it has a narrower scope than environment variables. test.param.yaml /**:
ros__parameters:
foo: $(var foo)
bar: data-bar
baz: data-baz test.launch.xml <group>
<let name="foo" value="test-foo"/>
<node pkg="test_pkg" exec="node" name="node">
<param from="$(find-pkg-share test_pkg)/config/test.param.yaml" allow_substs="true"/>
</node>
</group> output
|
I am leaning towards that keeping So the following solution would be more robust if my last assumption is true. First, we have a pure yaml parameter file. # test.param.yml
/**:
ros__parameters:
foo: /opt/autoware/<component>/<node>/config/test.param.yaml # Hardcoded conventional path
bar: data-bar
baz: data-baz Then, I assume parameter overwrite will work as follows (needs to be verified): # test.launch.xml
<group>
<node pkg="test_pkg" exec="node" name="node">
<param from="$(find-pkg-share test_pkg)/config/test.param.yaml" allow_substs="true"/>
<param name="foo" value="test-foo"/>
</node>
</group> |
@doganulus - I'm not following your reasoning regarding Bluechi and Ankaios. These are orchestrators, like k3s. Are you suggesting that these will remove the need to use the |
@kaspermeck-arm Yes, in the long run though. Those projects are at early stages but I think they can start ROS/Zenoh executables or containers directly. |
@doganulus - moving away from using The experience I have with BlueChi is that it is Kubernetes yaml compatible, translates these files to systemd service files and then runs containers as systemd services. When the container is launched, a command/file inside that environment is run (e.g., entry point file) and for ROS that would be the |
Definitely needs a bigger discussion. Below is a starting example. For the example, let's work in a test container:
And we install some example ROS nodes inside the container, create an example apt update && apt install -y ros-humble-demo-nodes-cpp
printf '/**:\n ros__parameters:\n a_string: $(env HOME)/autoware_data\n' >> param.yml
/opt/ros/humble/lib/demo_nodes_cpp/parameter_blackboard --ros-args --params-file param.yml & # Launch the node directly
ros2 param get parameter_blackboard a_string # Check the parameter set Normally, the command Then, if we can start nodes directly in this way, |
I understand your point of not being dependent on How about we find a way to evaluate these variable/shell commands and then write the output to a new interpreted parameter file which is free of variable/shell commands and with the correct, e.g., paths to local directories. What do you think? |
I am not absolutely against parameter file templates and environment variables in parameter files. They can be very handy when they are used right. The current implementation does not feel right, as parameter files reside at a lower level than launch descriptions. Hence, parameter files should not be aware of specific But this is not an easy task to handle properly. So I do not suggest immediate action as we gonna use |
In the end, Autoware is a ROS project and I am in favor of using the features which ROS provides to make it more convenient to configure nodes. The situation with adding a schema was different as there was no solution to this built into ROS already. I suggest that if someone has different needs, i.e., no dynamic variables in the parameter file, then they can make these changes themselves with, e.g., a parameter resolving script. If you want to bring this topic further, I suggest you create a new discussion with all the background. |
The clash between ROS practices and modern cloud-native practices is unavoidable. I side with the latter when they overlap. As a compromise: We can at least restrict it to |
Checklist
Description
JSON Schema validation to ensure that parameter file(s) are valid.
Purpose
Ensure that parameter files are valid to mitigate misconfiguration of ROS nodes.
Possible approaches
E.g., https://github.com/marketplace/actions/frontmatter-json-schema-validator
Definition of done
Pass/Fail for the JSON Schema validation using draft-07.
Pass/Fail for
/<path_to_package>/schema/*.schema.json
validation of parameter file(s) in/<path_to_package>/config/*.param.json
.The text was updated successfully, but these errors were encountered: