Skip to content
This repository has been archived by the owner on Feb 4, 2020. It is now read-only.

add support for package format 3 #168

Merged
merged 2 commits into from
Nov 14, 2017
Merged

add support for package format 3 #168

merged 2 commits into from
Nov 14, 2017

Conversation

dirk-thomas
Copy link
Contributor

@dirk-thomas dirk-thomas commented Oct 27, 2017

@dirk-thomas dirk-thomas added the in progress Actively being worked on (Kanban column) label Oct 27, 2017
@dirk-thomas dirk-thomas self-assigned this Oct 27, 2017
@dirk-thomas dirk-thomas added in review Waiting for review (Kanban column) and removed in progress Actively being worked on (Kanban column) labels Oct 31, 2017
for slot in (
'build_depends', 'build_export_depends', 'exec_depends'
):
getattr(pkg, slot).append(copy.deepcopy(d))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems a bit fragile, since there's no way to tell if a Package object has had its groups expanded or not.

Is this modifying the packages input data structure's elements (hard to tell with the redirection via the _PackageDecorator)?

If it is, I'd feel better about this change if it did not. Maybe a test to assert dependencies of the input Package objects in packages are not changed after being given to this function.

That way we could assert that sneaking these dependencies into the existing slots of the Package object is contained to this function and the functions it calls and they don't leak up out fo the function.


Alternatively, it would be more explicit, but more intrusive, to instead additionally check the group depends anywhere the depend tags are checked, rather than expanding the group depends into the existing slots.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is intentionally modifying the Package instances. So the side effect of the function is desired since that makes all other uses of the dependency transparent.

Expanding group dependencies later is with the current API currently not possible. For example when building one package the context of the other packages doesn't exist at the moment and a group dependency can't be resolved without these.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is intentionally modifying the Package instances. So the side effect of the function is desired since that makes all other uses of the dependency transparent.

That's even worse imo, because now code later may use the depends members of the Package class and based on the documentation (and the code in ament_package) about that object would conclude that the group dependencies are not part of them. This will be really hard to understand later when trying to figure out where dependencies in a Package object are coming from.

At the very least, it is not clear from comments, the code itself, or any documentation of this function that it modifies the input parameters in this way.

Expanding group dependencies later is with the current API currently not possible. For example when building one package the context of the other packages doesn't exist at the moment and a group dependency can't be resolved without these.

I would recommend that you instead expand the group dependencies into separate storage (either in new members of the Package object or as a separate object that is passed along with the Package object), then the code that needs to consider the group dependencies can check them separately from the normal dependencies, and code that doesn't want to consider the group dependencies does not have to change what it is doing.

Also, other tools will need to consider the group dependencies at some point, so maybe the logic to expand a group dependency into actual dependencies should live in the ament_package repository as a function that returns the expanded dependencies and takes the name of the group and the necessary context to expand them into dependencies. It could also be a method of the Package object which stores the result in the Package object and then you could have functions that return the combined normal + expanded group dependencies. Then you could update each place that needs to consider them.

That would allow this logic here to be reused and it would be more obvious when reading code that uses the Package object whether or not the group dependencies are being considered or not.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a GroupDependency class which can store its members. A function can populate the members which requires a list of Packages to be passed. This needs to happen for the topological order so that part still mutates the passed in packages (https://github.com/ament/ament_tools/pull/168/files#diff-6d0e8f72766cf2fab285d79a89594f8fR188). Other code like the list_dependencies verb has to do the same.

I didn't run any tests or checked if any other code (beside list_dependencies and topological_order) needs to be modified to consider group dependencies. I first want to wait for feedback if this approach is acceptable.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's more understandable to me, and since it is documented that should be fine. 👍, thanks for iterating on it.

@@ -47,6 +47,11 @@ def prepare_arguments(parser):
help='Show only test dependencies of a given package',
)
parser.add_argument(
'--group-deps',
action='store_true',
help='Show only group dependencies of a given package',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This option is good, but if I interpret the usage of it correctly, it only shows you that a given package has a group dependency and the name of the group. It does not tell you which packages in the workspace are considered a member of that group.

So, it would be good to either expand the group dependency and display them as part of this option or have an option like list --group-of <group name>.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense. dc26ceb lists all member of the group.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That looks good to me, 👍.

wjwwood
wjwwood previously approved these changes Nov 3, 2017
@dirk-thomas dirk-thomas dismissed wjwwood’s stale review November 9, 2017 19:53

Please re-review with recent changes.

@dirk-thomas
Copy link
Contributor Author

Waiting for review.

@mikaelarguedas
Copy link
Contributor

I'll review this today

@wjwwood
Copy link
Contributor

wjwwood commented Nov 14, 2017

Sorry, I don't think I got a message when the review was cleared. I can review it @mikaelarguedas, since I did the initial review.

@mikaelarguedas
Copy link
Contributor

@wjwwood sounds good to me

@dirk-thomas dirk-thomas merged commit 3b71252 into master Nov 14, 2017
@dirk-thomas dirk-thomas deleted the rep149 branch November 14, 2017 23:37
@dirk-thomas dirk-thomas removed the in review Waiting for review (Kanban column) label Nov 14, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants