Skip to content

Comments

Fix Instructions resolution#370

Merged
KaQuMiQ merged 1 commit intomainfrom
feature/instructions_fix
Jul 21, 2025
Merged

Fix Instructions resolution#370
KaQuMiQ merged 1 commit intomainfrom
feature/instructions_fix

Conversation

@KaQuMiQ
Copy link
Collaborator

@KaQuMiQ KaQuMiQ commented Jul 21, 2025

No description provided.

@coderabbitai
Copy link

coderabbitai bot commented Jul 21, 2025

Walkthrough

This change set refactors several components in the draive project, primarily focused on renaming methods and internal functions for clarity and consistency. The methods listing and instruction in both InstructionsFileStorage and InstructionsVolatileStorage are renamed to fetch_list and fetch_instruction. Corresponding updates are made in the Instructions class to reference these new method names. Internal async functions in state.py are renamed, and the handling of default cases in the fetch method is refined. The InstructionTemplate constructor's parameter order is changed. The Instruction.of method is refactored to use explicit conditionals instead of pattern matching, and the Instruction.format method's fallback logic is slightly adjusted. The pyproject.toml version is incremented.

Estimated code review effort

3 (30–60 minutes)

Possibly related PRs

  • Cleanup and formatting #343: This PR also modifies internal async functions and their signatures in src/draive/instructions/state.py, closely related to the refactoring of instruction fetching and state handling in the current PR.

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3d43d2a and 971869f.

📒 Files selected for processing (6)
  • pyproject.toml (1 hunks)
  • src/draive/instructions/file.py (2 hunks)
  • src/draive/instructions/state.py (4 hunks)
  • src/draive/instructions/template.py (2 hunks)
  • src/draive/instructions/types.py (4 hunks)
  • src/draive/instructions/volatile.py (2 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: CR
PR: miquido/draive#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-01T09:39:43.008Z
Learning: Applies to draive/**/*.{py} : Immutable updates through copy, same for State, Config and DataModel
Learnt from: KaQuMiQ
PR: miquido/draive#338
File: src/draive/lmm/__init__.py:1-2
Timestamp: 2025-06-16T10:28:07.434Z
Learning: The draive project requires Python 3.12+ as specified in pyproject.toml with "requires-python = ">=3.12"" and uses Python 3.12+ specific features like PEP 695 type aliases and generic syntax extensively throughout the codebase.
Learnt from: KaQuMiQ
PR: miquido/draive#327
File: src/draive/helpers/instruction_preparation.py:28-34
Timestamp: 2025-05-28T17:41:57.460Z
Learning: The draive project uses and requires Python 3.12+, so PEP-695 generic syntax with square brackets (e.g., `def func[T: Type]()`) is valid and should be used instead of the older TypeVar approach.
pyproject.toml (3)

Learnt from: KaQuMiQ
PR: #338
File: src/draive/lmm/init.py:1-2
Timestamp: 2025-06-16T10:28:07.434Z
Learning: The draive project requires Python 3.12+ as specified in pyproject.toml with "requires-python = ">=3.12"" and uses Python 3.12+ specific features like PEP 695 type aliases and generic syntax extensively throughout the codebase.

Learnt from: CR
PR: miquido/draive#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-01T09:39:43.008Z
Learning: Applies to draive/**/*.py : Use absolute imports from draive package

Learnt from: KaQuMiQ
PR: #327
File: src/draive/helpers/instruction_preparation.py:28-34
Timestamp: 2025-05-28T17:41:57.460Z
Learning: The draive project uses and requires Python 3.12+, so PEP-695 generic syntax with square brackets (e.g., def func[T: Type]()) is valid and should be used instead of the older TypeVar approach.

🔇 Additional comments (17)
pyproject.toml (1)

8-8: Version bump is appropriate for the refactoring scope.

The patch version increment correctly reflects the internal method renaming and refactoring changes without breaking the public API.

src/draive/instructions/template.py (2)

23-31: Constructor parameter reordering improves API clarity.

Moving function to positional and name to keyword-only makes the API more intuitive and explicit.


107-107: Consistent with constructor signature change.

The function call correctly reflects the new parameter ordering.

src/draive/instructions/file.py (2)

37-41: Method renaming improves descriptiveness.

Renaming listing to fetch_list makes the method's purpose clearer and aligns with consistent naming conventions.


63-69: Method renaming enhances clarity.

Renaming instruction to fetch_instruction provides better semantic meaning and maintains consistency with fetch_list.

src/draive/instructions/types.py (2)

123-147: Refactoring from match to if-elif-else maintains functionality.

The explicit conditional logic is equivalent to the previous match statement and may improve readability. The functionality remains identical.


177-177: Format method simplification is robust.

Always calling format_map(self.arguments) is safe since format_map handles empty dictionaries correctly, and this removes unnecessary conditional logic.

src/draive/instructions/volatile.py (3)

15-18: Adding slots improves memory efficiency.

The __slots__ definition restricts instance attributes and provides memory optimization, which aligns well with the @final decorator.


31-35: Method renaming maintains consistency.

Renaming listing to fetch_list aligns with the naming convention changes across the instructions subsystem.


37-43: Method renaming improves API clarity.

Renaming instruction to fetch_instruction provides clearer semantic meaning and maintains consistency with other storage implementations.

src/draive/instructions/state.py (7)

21-21: LGTM: Improved function naming for clarity.

The rename from _empty to _empty_list makes the function's purpose more explicit and improves code readability.


27-27: LGTM: Improved function naming for clarity.

The rename from _none to _no_instruction makes the function's purpose more explicit and improves code readability.


48-49: LGTM: Updated method references align with storage interface refactoring.

The changes from storage.listing/storage.instruction to storage.fetch_list/storage.fetch_instruction are consistent with the coordinated refactoring mentioned in the AI summary.


60-61: LGTM: Consistent method reference updates.

These changes maintain consistency with the storage interface refactoring applied in the of method.


129-131: LGTM: Improved control flow clarity.

The explicit handling of the default is None case before other conditions improves code readability and makes the logic flow more explicit.


139-143: LGTM: Proper fallback handling for non-string default values.

The else clause correctly handles the case where default is an Instruction object, completing the refined control flow logic.


145-146: LGTM: Updated assignments use renamed functions consistently.

The assignments correctly reference the renamed functions _empty_list and _no_instruction, maintaining consistency with the function renames.

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@KaQuMiQ KaQuMiQ merged commit f07b2a3 into main Jul 21, 2025
5 checks passed
@KaQuMiQ KaQuMiQ deleted the feature/instructions_fix branch July 21, 2025 11:09
@coderabbitai coderabbitai bot mentioned this pull request Oct 21, 2025
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.

1 participant