Skip to content

Conversation

@Jintao-Huang
Copy link
Collaborator

No description provided.

@Jintao-Huang
Copy link
Collaborator Author

/gemini review

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 addresses a bug related to non-deterministic ordering of candidate_templates, which likely caused issues with dataset hashing. The fix correctly uses dict.fromkeys to ensure a unique and order-preserved list of templates. The change is effective and improves the robustness of the code. I have one suggestion to slightly refactor the implementation for better readability.

Comment on lines +90 to +91
self.candidate_templates = list(
dict.fromkeys(t for t in [self.template] + [mg.template for mg in self.model_groups] if t is not 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

While the use of dict.fromkeys is a clever way to get unique elements while preserving order, the single line is quite long and a bit hard to read. Consider breaking it into two lines for improved readability and to adhere to common line length limits.

Suggested change
self.candidate_templates = list(
dict.fromkeys(t for t in [self.template] + [mg.template for mg in self.model_groups] if t is not None))
templates = [self.template] + [mg.template for mg in self.model_groups]
self.candidate_templates = list(dict.fromkeys(t for t in templates if t is not None))

@Jintao-Huang Jintao-Huang merged commit fb4be50 into modelscope:main Jan 27, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants