Skip to content

Conversation

@doctrino
Copy link
Collaborator

@doctrino doctrino commented Jul 4, 2025

Description

Changelog

  • Patch
  • Minor
  • Skip

cdf

Added

  • You can now specify a .toolkitignore to tell Toolkit what to ignore in the cdf build command.

templates

No changes.

@gemini-code-assist
Copy link
Contributor

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.

@doctrino
Copy link
Collaborator Author

doctrino commented Jul 4, 2025

/gemini review

@github-actions
Copy link

github-actions bot commented Jul 4, 2025

☂️ Python Coverage

current status: ✅

Overall Coverage

Lines Covered Coverage Threshold Status
21114 16689 79% 60% 🟢

New Files

File Coverage Status
cognite_toolkit/_cdf_tk/utils/ignore_patterns.py 79% 🟢
TOTAL 79% 🟢

Modified Files

File Coverage Status
cognite_toolkit/_cdf_tk/constants.py 100% 🟢
cognite_toolkit/_cdf_tk/data_classes/_module_directories.py 91% 🟢
cognite_toolkit/_cdf_tk/feature_flags.py 100% 🟢
cognite_toolkit/_cdf_tk/utils/init.py 100% 🟢
TOTAL 98% 🟢

updated for commit: 8f7e2c0 by action🐍

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 introduces .toolkitignore functionality, allowing users to specify files and directories to be excluded from the cdf build command. The implementation adds new classes for pattern parsing and integrates this logic into the ModuleLocation data class. While the overall approach is sound, a critical issue exists in how ignore patterns are applied, which could lead to incorrect filtering of files and directories. Additionally, there are minor maintainability improvements that can be made.

Comment on lines 104 to 105
if not ignore_parser.is_ignored(Path(directory_name), is_directory=True):
invalid_resource_directory.add(directory_name)
Copy link
Contributor

Choose a reason for hiding this comment

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

critical

The ignore_parser.is_ignored method is currently called with Path(directory_name), which represents only the top-level directory name relative to the module. This is incorrect because .toolkitignore patterns can target specific files or nested directories (e.g., sub_dir/file.txt or nested/folder/). For accurate pattern matching, the is_ignored method should be called with the full relative_to_module path, which provides the complete path relative to the module's root. This is a critical correctness issue as it prevents proper filtering of ignored files and directories, leading to unexpected build outcomes.

Suggested change
if not ignore_parser.is_ignored(Path(directory_name), is_directory=True):
invalid_resource_directory.add(directory_name)
if not ignore_parser.is_ignored(relative_to_module, is_directory=True):
invalid_resource_directory.add(directory_name)

if not is_file_in_resource_folder:
invalid_resource_directory.add(relative_to_module.parts[0])
directory_name = relative_to_module.parts[0]
directory_path = self.dir / directory_name
Copy link
Contributor

Choose a reason for hiding this comment

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

high

The variable directory_path is defined but not used. Unused variables add clutter and can be misleading for future maintainers. It's good practice to remove them to improve code readability and maintainability1.

Style Guide References

Suggested change
directory_path = self.dir / directory_name
# directory_path = self.dir / directory_name

Footnotes

  1. Write code that is easy to modify and extend. Unused variables hinder maintainability. (link)

"""

import fnmatch
import re
Copy link
Contributor

Choose a reason for hiding this comment

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

high

The re module is imported but does not appear to be used anywhere in this file. Unused imports should be removed to keep the codebase clean and improve maintainability1.

Style Guide References

Footnotes

  1. Write code that is easy to modify and extend. Unused imports hinder maintainability. (link)

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