Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix target names lookup #1477

Merged
merged 2 commits into from
Oct 24, 2024
Merged

Fix target names lookup #1477

merged 2 commits into from
Oct 24, 2024

Conversation

mdesmet
Copy link
Contributor

@mdesmet mdesmet commented Oct 22, 2024

Overview

Problem

Describe the problem you are solving. Mention the ticket/issue if applicable.

Solution

Describe the implemented solution. Add external references if needed.

Screenshot/Demo

A picture is worth a thousand words. Please highlight the changes if applicable.

How to test

  • Steps to be followed to verify the solution or code changes
  • Mention if there is any settings configuration added/changed/deleted

Checklist

  • I have run this code and it appears to resolve the stated issue
  • README.md updated and added information about my change

Important

Fix get_target_names() in dbt_core_integration.py to correctly use self.config.profile_name for profile lookup.

  • Behavior:
    • Fix get_target_names() in dbt_core_integration.py to use self.config.profile_name instead of self.project_name for profile lookup.
    • Ensures correct profile is accessed to retrieve target names from outputs.
  • Misc:
    • No changes to settings or configurations.

This description was created by Ellipsis for 5dd6acc. It will automatically update as commits are pushed.

Summary by CodeRabbit

  • New Features

    • Improved logic for retrieving target names by utilizing the correct profile context, enhancing compatibility with updated configuration structures.
  • Bug Fixes

    • Ensured correct handling of profile outputs, maintaining functionality even when outputs are not defined.

Copy link
Contributor

coderabbitai bot commented Oct 22, 2024

Walkthrough

The changes in this pull request focus on the get_target_names method within the DbtProject class in the dbt_core_integration.py file. The logic has been updated to use self.config.profile_name for accessing the profile, instead of self.project_name. This adjustment aims to ensure the correct profile is utilized for retrieving outputs. Additionally, the method retains its check for the presence of "outputs" in the profile and replaces the old variable project with profile to better align with the updated configuration management.

Changes

File Change Summary
dbt_core_integration.py Modified get_target_names method to reference self.config.profile_name instead of self.project_name. Removed variable project, replaced with profile. Retained condition for checking "outputs" presence.

Suggested reviewers

  • anandgupta42
  • saravmajestic

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ 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.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @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 generate unit testing code.
    • @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.

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 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.

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

❌ Changes requested. Reviewed everything up to 5dd6acc in 32 seconds

More details
  • Looked at 17 lines of code in 1 files
  • Skipped 0 files when reviewing.
  • Skipped posting 2 drafted comments based on config settings.
1. dbt_core_integration.py:869
  • Draft comment:
    Please provide a return type for the get_target_names function to improve clarity and ease of refactoring.
  • Reason this comment was not posted:
    Comment was on unchanged code.
2. dbt_core_integration.py:872
  • Draft comment:
    Use semantic versioning (semver) for version comparisons instead of direct array index comparisons. This issue is also present in other parts of the code, such as lines 40, 47, 62, 76, 278, 386, 398, 438, 567, 576, 726, and 856.
  • Reason this comment was not posted:
    Comment was on unchanged code.

Workflow ID: wflow_UGCIHLrEnuYyTPPG


Want Ellipsis to fix these issues? Tag @ellipsis-dev in a comment. You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

project = profile[self.project_name]
if "outputs" in project:
outputs = project["outputs"]
profile = profile[self.config.profile_name]
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider using profile.get(self.config.profile_name, {}) to avoid potential KeyError if self.config.profile_name is not in the profile dictionary.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between f596081 and 5dd6acc.

📒 Files selected for processing (1)
  • dbt_core_integration.py (1 hunks)
🧰 Additional context used
🔇 Additional comments (2)
dbt_core_integration.py (2)

Line range hint 1-874: Summary of changes and potential impact

The modifications in this file are focused on the get_target_names method of the DbtProject class. The changes improve how profiles are accessed by using self.config.profile_name instead of self.project_name. This should make the method more robust and less prone to errors.

While the changes appear to be an improvement, it's important to:

  1. Ensure that self.config.profile_name is consistently set and used throughout the project where profile access is needed.
  2. Verify that this change doesn't introduce any unintended side effects in other parts of the codebase that might rely on the previous behavior.
  3. Update any documentation or comments that might reference the old way of accessing profiles.

Overall, the changes seem to be a positive step towards more accurate profile handling, but careful testing and verification are recommended to ensure full compatibility with the rest of the system.


872-874: Verify consistent usage of profile_name vs project_name

The change from self.project_name to self.config.profile_name in the get_target_names method might have implications for other parts of the code. To ensure consistency and prevent potential issues:

  1. Review other methods in this class and related classes to check if they should also use self.config.profile_name instead of self.project_name when accessing profile information.
  2. Verify that self.config.profile_name is always set correctly throughout the project lifecycle.
#!/bin/bash
# Search for occurrences of project_name and profile_name in the codebase
echo "Occurrences of project_name:"
grep -rn "project_name" .
echo "Occurrences of profile_name:"
grep -rn "profile_name" .

This will help identify any inconsistencies in how profile and project names are used throughout the codebase.

Comment on lines +872 to +874
profile = profile[self.config.profile_name]
if "outputs" in profile:
outputs = profile["outputs"]
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Codebase verification

Inconsistent usage of profile_name detected.

The profile_name configuration is only referenced in dbt_core_integration.py:872, whereas project_name is used extensively throughout the codebase. This inconsistency may lead to configuration issues.

  • Ensure that profile_name is properly defined and utilized wherever project_name is currently in use.
🔗 Analysis chain

Improved profile access in get_target_names method.

The changes in this method improve how the profile is accessed:

  1. It now uses self.config.profile_name instead of self.project_name to access the correct profile.
  2. The method checks for the presence of "outputs" in the profile before attempting to return the keys.

These changes should make the method more robust and less prone to errors when accessing profile information.

However, to ensure full compatibility, we should verify that self.config.profile_name is always set correctly.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if profile_name is consistently set in the config
grep -rn "profile_name" . | grep -v "get_target_names"

Length of output: 1991

@mdesmet mdesmet requested a review from saravmajestic October 24, 2024 02:00
@mdesmet mdesmet merged commit 0078e1c into master Oct 24, 2024
10 checks passed
@mdesmet mdesmet deleted the fix/target branch October 24, 2024 12:55
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