-
Notifications
You must be signed in to change notification settings - Fork 71
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
Substitutions in parameter files #168
Conversation
Signed-off-by: Ivan Santiago Paunovic <ivanpauno@ekumenlabs.com>
Signed-off-by: Ivan Santiago Paunovic <ivanpauno@ekumenlabs.com>
Signed-off-by: Ivan Santiago Paunovic <ivanpauno@ekumenlabs.com>
Signed-off-by: Ivan Santiago Paunovic <ivanpauno@ekumenlabs.com>
Signed-off-by: Ivan Santiago Paunovic <ivanpauno@ekumenlabs.com>
Signed-off-by: Ivan Santiago Paunovic <ivanpauno@ekumenlabs.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! Though I have to say I'm surprised that the substitution parser can handle multi-line strings.
f.write(contents) | ||
yield f.name | ||
finally: | ||
os.unlink(f.name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ivanpauno nit: out of curiosity, why not:
with NamedTemporaryFile() as f:
f.write(contents)
yield f.name
instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that won't unlink the file, just close it (unlink = remove from the filesystem).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It will remove it if you don't set delete=False
(which seems unnecessary in this case).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah yes, I guess that works
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in fc999d0.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I now remember why I did this ...
Windows doesn't allow opening the same file twice.
If I yield
from within the with
statement, then I have a problem when opening the file in the test (see Windows CI results).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Windows doesn't allow opening the same file twice.
That makes no sense.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It appears you can reopen it, but not easily... (see here). Oh well, nevermind.
test_launch_ros/test/test_launch_ros/descriptions/test_parameter_file.py
Outdated
Show resolved
Hide resolved
Signed-off-by: Ivan Santiago Paunovic <ivanpauno@ekumenlabs.com>
Signed-off-by: Ivan Santiago Paunovic <ivanpauno@ekumenlabs.com>
Signed-off-by: Ivan Santiago Paunovic <ivanpauno@ekumenlabs.com>
Signed-off-by: Ivan Santiago Paunovic <ivanpauno@ekumenlabs.com>
Signed-off-by: Ivan Santiago Paunovic <ivanpauno@ekumenlabs.com>
Signed-off-by: Ivan Santiago Paunovic <ivanpauno@ekumenlabs.com>
Signed-off-by: Ivan Santiago Paunovic <ivanpauno@ekumenlabs.com>
Signed-off-by: Ivan Santiago Paunovic <ivanpauno@ekumenlabs.com>
Signed-off-by: Ivan Santiago Paunovic <ivanpauno@ekumenlabs.com>
Signed-off-by: Ivan Santiago Paunovic <ivanpauno@ekumenlabs.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM pending green CI
This reverts commit fc999d0. Signed-off-by: Ivan Santiago Paunovic <ivanpauno@ekumenlabs.com>
7228ef6
to
521c910
Compare
Last force push was because I forgot to sign the revert commit. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Hey, this looks really cool. Is there a simple user-faced example / documentation available for this? I want to load a big param file and only replace certain parameter values (1-2 out of ~150). This is needed for CI testing. Here is a example code using this: https://github.com/ros-planning/navigation2/blob/b8e9fba422d6e024767d1a5b668703625454fdcb/nav2_system_tests/src/system/test_system_launch.py#L45 Would be cool to maybe merge or replace the custom nav2 with official ros2_launch tools. Thank you in advise! |
Hi @gramss, sorry for the delay but I didn't see your comment before. I didn't write an example, but it would look something like this: Node(
executable=executable_name,
package=package_name,
parameters=[ParameterFile('path/to/file', allow_substs=True)]
) The tests have an example parameter file, you can basically use the normal launch XML style substitutions in any position (see this guide for launch XML style substitutions, most of them are documented there). Adding an example would actually be a great idea. If you have any question feel free to ping me. |
@ivanpauno Is there anything blocking us from backporting this to Foxy? |
By default, we backport only fixes and not features. |
I tried cherry-picking this change to Foxy, but there are some conflicts. If someone wants to take the time to resolve them, I'm happy to review a PR. |
Equivalent to the ROS 1 feature.
Fixes #96.