Skip to content

Comments

Fix missing instructions exception in default implementations#371

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

Fix missing instructions exception in default implementations#371
KaQuMiQ merged 1 commit intomainfrom
feature/missing_instructions

Conversation

@KaQuMiQ
Copy link
Collaborator

@KaQuMiQ KaQuMiQ commented Jul 21, 2025

No description provided.

@coderabbitai
Copy link

coderabbitai bot commented Jul 21, 2025

Walkthrough

The changes update the version number in the pyproject.toml file from "0.79.2" to "0.79.3". In both src/draive/instructions/file.py and src/draive/instructions/volatile.py, the fetch_instruction method's return type is changed from always returning an Instruction to potentially returning None if the instruction is not found. Instead of raising an InstructionMissing exception, the code now logs a debug message using ctx.log_debug and returns None.

Estimated code review effort

2 (10–30 minutes)

Possibly related PRs


📜 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 f07b2a3 and a49b199.

📒 Files selected for processing (3)
  • pyproject.toml (1 hunks)
  • src/draive/instructions/file.py (3 hunks)
  • src/draive/instructions/volatile.py (3 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.py

📄 CodeRabbit Inference Engine (CLAUDE.md)

**/*.py: Use absolute imports from draive package
Follow Ruff import ordering (standard library, third party, local)
Use Python 3.12+ type features (type unions with |, generic syntax)
Use base and abstract types like Sequence or Iterable instead of concrete types
Use custom exceptions for specific errors
Use NumPy docstring convention for all functions, classes, and methods
Skip module-level docstrings unless explicitly requested
Include sections: Parameters, Returns, Raises, Notes (if needed) in docstrings
ALWAYS use Sequence[T] instead of list[T], Mapping[K,V] instead of dict[K,V], and Set[T] instead of set[T] for collections in State, Config and DataModel classes
Immutable updates to State, Config, and DataModel classes should be performed through the .updated() method

Files:

  • src/draive/instructions/volatile.py
  • src/draive/instructions/file.py
🧠 Learnings (2)
📓 Common learnings
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.
pyproject.toml (2)

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: 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 (7)
pyproject.toml (1)

8-8: LGTM! Appropriate version bump for bug fix.

The patch-level version increment from 0.79.2 to 0.79.3 is appropriate for fixing the missing instructions exception behavior.

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

4-4: Good addition of ctx import for debug logging.

The import follows the coding guidelines for absolute imports from the haiway package.


53-54: Excellent replacement of exception with debug logging.

The debug logging approach is more appropriate than raising exceptions for missing instructions, as this might be expected behavior in some use cases.


44-44: Verify None return handling in fetch_instruction callers

The return type for fetch_instruction was changed from Instruction to Instruction | None, which may break existing call sites. We found two locations where the method is passed as a callback without obvious None checks:

• src/draive/instructions/state.py:49 (assigned to fetching)
• src/draive/instructions/state.py:61 (assigned to fetching)

Please review any code that invokes fetching(...) or calls fetch_instruction directly and ensure you handle a None result (e.g., with explicit checks or fallback logic).

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

7-7: Good import update following the existing pattern.

Adding ctx to the existing haiway import maintains clean import organization.


68-68: Consistent API change with volatile storage implementation.

The return type change to Instruction | None maintains consistency with the volatile storage implementation and follows Python 3.12+ union syntax as per coding guidelines.


81-82: Excellent debug logging with contextual information.

The debug message includes the file path, providing better context for debugging compared to the generic message in volatile storage.

✨ 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 91c0650 into main Jul 21, 2025
5 checks passed
@KaQuMiQ KaQuMiQ deleted the feature/missing_instructions branch July 21, 2025 11:37
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