Skip to content

Conversation

elliot-barn
Copy link
Contributor

  • remove depsets from the config
  • move build arg sets to the workspace (config is pure utility)
  • replace get depset with get depset by id
  • using a depset map to fetch and retrieve the depset and build arg combination (Using a tuple of both as the id)

Signed-off-by: elliot-barn <[email protected]>
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request refactors the handling of build argument sets for dependency sets, which is a good improvement for modularity. The key idea of using a (depset_name, build_arg_set_name) tuple as a unique identifier is sound. My review focuses on a correctness issue in how depsets are retrieved, a few opportunities to improve code clarity and documentation, and a suggestion to optimize performance in the new depset expansion logic.

Comment on lines +105 to +112
build_arg_set = next(
(
build_arg_set
for build_arg_set in build_arg_sets
if build_arg_set.name == build_arg_set_name
),
None,
)
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

This search for build_arg_set is inefficient. It iterates through the build_arg_sets list for every name in build_arg_set_matrix, leading to O(N*M) complexity. For better performance, you could convert the build_arg_sets list to a dictionary before this function is called, allowing for an O(1) lookup here.

This would involve:

  1. In Workspace.build_depset_map, create a dict from self.build_arg_sets.
  2. Pass this dict to Config.to_depset_map and then to this function.
  3. Here, you could replace this block with a simple dictionary lookup, like build_arg_set = build_arg_sets.get(build_arg_set_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.

Will do this in another PR

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done here: #55557

Signed-off-by: elliot-barn <[email protected]>
@elliot-barn elliot-barn requested a review from aslonnie August 12, 2025 23:19
elliot-barn and others added 3 commits August 12, 2025 16:19
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Signed-off-by: Elliot Barnwell <[email protected]>
Signed-off-by: elliot-barn <[email protected]>
@elliot-barn elliot-barn changed the title [ci] raydepsets: refactor build arg sets [ci] raydepsets: refactor depsets - using depset map Aug 12, 2025
depset.name, operation="subset", depset=depset
self.build_graph.add_node(depset_id, operation="subset", depset=depset)
self.build_graph.add_edge(
(depset.source_depset, depset.build_arg_set_name), depset_id
Copy link
Collaborator

Choose a reason for hiding this comment

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

what does this add edge mean now? I am a bit confused on a tuple.

Comment on lines 98 to 103
try:
return self.depset_map[depset_id]
except KeyError:
raise KeyError(
f"Dependency set {depset_id[0]} with build arg set {depset_id[1]} not found"
)
Copy link
Collaborator

Choose a reason for hiding this comment

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

use get and check if it is None? don't use try catch.

Comment on lines +135 to +138
self.build_arg_sets = Config.parse_build_arg_sets(
data.get("build_arg_sets", [])
)
return Config.to_depset_map(data, self.build_arg_sets)
Copy link
Collaborator

Choose a reason for hiding this comment

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

de-indent so that the file can be closed?

@staticmethod
def from_dict(data: dict) -> "Config":
build_arg_sets = Config.parse_build_arg_sets(data.get("build_arg_sets", []))
def to_depset_map(
Copy link
Collaborator

Choose a reason for hiding this comment

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

can we still keep the source config struct, and convert to map in another step function? having the source config around can be useful for debugging and error reporting.

like now this Config class is just empty and useless now.

Signed-off-by: elliot-barn <[email protected]>
@ray-gardener ray-gardener bot added core Issues that should be addressed in Ray Core ci-test labels Aug 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ci-test core Issues that should be addressed in Ray Core
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants