Skip to content

docs: Add module-level docstrings to cognee/__init__.py#2361

Open
haroldfabla2-hue wants to merge 4 commits intotopoteretes:mainfrom
haroldfabla2-hue:feature/issue-2311-add-docstrings
Open

docs: Add module-level docstrings to cognee/__init__.py#2361
haroldfabla2-hue wants to merge 4 commits intotopoteretes:mainfrom
haroldfabla2-hue:feature/issue-2311-add-docstrings

Conversation

@haroldfabla2-hue
Copy link

@haroldfabla2-hue haroldfabla2-hue commented Mar 10, 2026

Summary

Add comprehensive docstrings to the main public API functions exported from cognee/__init__.py. This improves IDE autocomplete and provides clear usage examples for new users.

Changes

  • Added module-level docstring explaining the package
  • Documented all 7 main functions: add(), cognify(), search(), memify(), delete(), config(), datasets()
  • Added example usage code

Issue

Fixes #2311

Checklist

  • Code passes linting
  • Documentation is accurate

Summary by CodeRabbit

  • Bug Fixes

    • Improved Docker container initialization for better Windows compatibility by switching from shell script to Python-based startup process.
  • Documentation

    • Added comprehensive module-level documentation describing the project and its usage.
  • Tests

    • Added new unit test coverage for storage utility functions, ensuring core functionality works as expected.

Alberto Farah and others added 4 commits March 7, 2026 07:44
- Add entrypoint.py as portable alternative to bash script
- Windows Docker Desktop has issues executing .sh files
- Python entrypoint works cross-platform without shell dependencies
- Fallback bash entrypoint.sh kept for Linux/macOS environments

Fixes: topoteretes#2274
…coded 'public' schema

This fixes the bug where delete_dataset() fails in non-public Postgres
schemas because the schema was hardcoded to 'public'.

The fix changes the default schema_name from 'public' to None, which
makes the function use the database's search_path configuration.

Closes: topoteretes#2291
- Add test_utils.py with tests for copy_model() and get_own_properties()
- Tests cover basic copying, include_fields, exclude_fields, and edge cases
- Follows existing test structure in cognee/tests/unit/modules/
Add comprehensive docstrings to the main public API functions exported
from cognee/__init__.py. This improves IDE autocomplete and provides
clear usage examples for new users.

Addresses: topoteretes#2311
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 10, 2026

Note

Currently processing new changes in this PR. This may take a few minutes, please wait...

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 704a5350-f07f-4ab6-8fa0-75f29309bfc4

📥 Commits

Reviewing files that changed from the base of the PR and between 07a4916 and 7602801.

📒 Files selected for processing (6)
  • Dockerfile
  • cognee/__init__.py
  • cognee/infrastructure/databases/relational/sqlalchemy/SqlAlchemyAdapter.py
  • cognee/tests/unit/modules/storage/__init__.py
  • cognee/tests/unit/modules/storage/test_utils.py
  • entrypoint.py
 _____________________
< Git gud or git out. >
 ---------------------
  \
   \   \
        \ /\
        ( )
      .( o ).

✏️ Tip: You can disable in-progress messages and the fortune message in your review settings.

Tip

You can generate walkthrough in a markdown collapsible section to save space.

Enable the reviews.collapse_walkthrough setting to generate walkthrough in a markdown collapsible section.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Tip

Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs).
Share your feedback on Discord.


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

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 10, 2026

Caution

Failed to replace (edit) comment. This is likely due to insufficient permissions or the comment being deleted.

Error details
{"name":"HttpError","status":500,"request":{"method":"PATCH","url":"https://api.github.com/repos/topoteretes/cognee/issues/comments/4032149980","headers":{"accept":"application/vnd.github.v3+json","user-agent":"octokit.js/0.0.0-development octokit-core.js/7.0.6 Node.js/24","authorization":"token [REDACTED]","content-type":"application/json; charset=utf-8"},"body":{"body":"<!-- This is an auto-generated comment: summarize by coderabbit.ai -->\n<!-- walkthrough_start -->\n\n## Walkthrough\n\nThis pull request introduces a Python-based Docker entrypoint script to replace shell-based startup, adds module-level documentation to the main package, updates a database adapter method's default parameter, and expands test coverage for storage utilities with comprehensive unit tests.\n\n## Changes\n\n|Cohort / File(s)|Summary|\n|---|---|\n|**Docker & Container Entrypoint** <br> `Dockerfile`, `entrypoint.py`|Dockerfile modified to copy and execute entrypoint.py instead of entrypoint.sh; new entrypoint.py script handles database migrations (alembic upgrade or fallback setup), debugging configuration, and Gunicorn/uvicorn server launch with environment-aware settings (debug mode, reload behavior).|\n|**Module Documentation** <br> `cognee/__init__.py`|Added comprehensive module-level docstring describing project purpose, main functions, and usage example without functional or API changes.|\n|**Database Adapter** <br> `cognee/infrastructure/databases/relational/sqlalchemy/SqlAlchemyAdapter.py`|Updated `delete_entity_by_id` method signature: `schema_name` parameter default changed from `\"public\"` to `None`, with updated docstring noting that `None` respects database search_path for multi-schema setups.|\n|**Test Coverage** <br> `cognee/tests/unit/modules/storage/test_utils.py`|New unit test module covering `copy_model` (basic behavior, field inclusion/exclusion, combined filters) and `get_own_properties` (core property extraction, nested structure handling, primitive value preservation).|\n\n## Estimated code review effort\n\n🎯 3 (Moderate) | ⏱️ ~20 minutes\n\n## Possibly related PRs\n\n- PR `#449`: Modifies container entrypoint/startup logic with similar scope of changing how the Docker container initializes.\n- PR `#111`: Updates Docker entrypoint and container startup behavior, closely aligned with entrypoint changes.\n- PR `#779`: Modifies container startup flow through Dockerfile ENTRYPOINT and entrypoint script implementation.\n\n## Suggested labels\n\n`run-checks`\n\n## Suggested reviewers\n\n- Vasilije1990\n- borisarzentar\n\n<!-- walkthrough_end -->\n\n\n<!-- pre_merge_checks_walkthrough_start -->\n\n<details>\n<summary>🚥 Pre-merge checks | ✅ 1 | ❌ 4</summary>\n\n### ❌ Failed checks (4 warnings)\n\n|         Check name         | Status     | Explanation                                                                                                                                                                                                                                                                               | Resolution                                                                                                                                                                                                             |\n| :------------------------: | :--------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n|         Title check        | ⚠️ Warning | The PR title claims to add docstrings to cognee/__init__.py, which only partially reflects the changeset. The PR also includes Dockerfile changes, a new entrypoint.py, database schema handling updates, and new test files, making the title incomplete and misleading.                 | Update the title to accurately reflect all major changes, such as 'Add entrypoint.py, update Dockerfile, add docstrings, and expand test coverage' or focus on the primary change if this is truly the main objective. |\n|      Description check     | ⚠️ Warning | The PR description only mentions adding docstrings to cognee/__init__.py and fixing issue `#2311`, but fails to document other significant changes: Dockerfile modifications, entrypoint.py creation, SqlAlchemyAdapter schema handling changes, and new test files.                        | Expand the description to include all file changes: Dockerfile entrypoint migration, new entrypoint.py script, schema parameter default changes, and new test coverage added.                                          |\n|     Linked Issues check    | ⚠️ Warning | Issue `#2311` requires unit tests for TextChunker and LangchainChunker in cognee/tests/unit/modules/chunking/, but the PR only adds tests for storage utilities in test_utils.py and does not address the chunking module tests at all.                                                     | Add unit tests for TextChunker and LangchainChunker under cognee/tests/unit/modules/chunking/ to fulfill the linked issue requirements, or update the issue reference if the scope has changed.                        |\n| Out of Scope Changes check | ⚠️ Warning | The PR includes multiple out-of-scope changes not mentioned in the PR description or linked issue: Dockerfile refactoring to use Python entrypoint, SqlAlchemyAdapter schema parameter changes, and entrypoint.py creation are unrelated to the docstring improvements or chunking tests. | Either add these changes to the PR description and ensure they align with an issue objective, or move them to separate PRs to maintain focused scope.                                                                  |\n\n<details>\n<summary>✅ Passed checks (1 passed)</summary>\n\n|     Check name     | Status   | Explanation                                                                         |\n| :----------------: | :------- | :---------------------------------------------------------------------------------- |\n| Docstring Coverage | ✅ Passed | Docstring coverage is 91.67% which is sufficient. The required threshold is 80.00%. |\n\n</details>\n\n<sub>✏️ Tip: You can configure your own custom pre-merge checks in the settings.</sub>\n\n</details>\n\n<!-- pre_merge_checks_walkthrough_end -->\n\n<!-- finishing_touch_checkbox_start -->\n\n<details>\n<summary>✨ Finishing Touches</summary>\n\n<details>\n<summary>🧪 Generate unit tests (beta)</summary>\n\n- [ ] <!-- {\"checkboxId\": \"f47ac10b-58cc-4372-a567-0e02b2c3d479\", \"radioGroupId\": \"utg-output-choice-group-unknown_comment_id\"} -->   Create PR with unit tests\n- [ ] <!-- {\"checkboxId\": \"07f1e7d6-8a8e-4e23-9900-8731c2c87f58\", \"radioGroupId\": \"utg-output-choice-group-unknown_comment_id\"} -->   Post copyable unit tests in a comment\n\n</details>\n\n</details>\n\n<!-- finishing_touch_checkbox_end -->\n\n<!-- announcements_start -->\n\n> [!TIP]\n> Try [Coding Plans](https://www.coderabbit.ai/issue-planner). Let us write the prompt for your AI agent so you can ship faster (with fewer bugs).\n> Share your feedback on [Discord](https://discord.com/invite/coderabbit).\n\n<!-- announcements_end -->\n\n<!-- tips_start -->\n\n---\n\nThanks for using [CodeRabbit](https://coderabbit.ai?utm_source=oss&utm_medium=github&utm_campaign=topoteretes/cognee&utm_content=2361)! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.\n\n<details>\n<summary>❤️ Share</summary>\n\n- [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai)\n- [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai)\n- [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai)\n- [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code)\n\n</details>\n\n<sub>Comment `@coderabbitai help` to get the list of available commands and usage tips.</sub>\n\n<!-- tips_end -->\n\n<!-- internal state start -->\n\n\n<!-- DwQgtGAEAqAWCWBnSTIEMB26CuAXA9mAOYCmGJATmriQCaQDG+Ats2bgFyQAOFk+AIwBWJBrngA3EsgEBPRvlqU0AgfFwA6NPEgQAfACgjoCEYDEZyAAUASpETZWaCrKPR1AGxJda+Boi4AQVp6ZkVsLzAvKQ9IX39cCngMImQCBSJyEgB6AH1c5PV8jW55AApbSDMAJgBmADYARgBKNwRkSrQQ5CZmXhJYMkRJEkgw2giSKJIYuL9EROTUyHTcQZ40BgBrNFJIdhdufGTcSAAzeC8MrLyCjCLcktkNSABhWExSZGSGD2wldCQcgAdzG4Ui0RIsSUiAYSW44nwWHwZxW624mx2pAANHMEkkUsgzvg+GtRogZmQxtosNxsAIPPAGJBAlYAJLnbAYMTwJHIEgADyOFBo9DOFBYaNG40mkDKXVoZWauKYmXgZ1kStxFOcDFgWrGJGY6s1yriUJINANTAwFyIBto1DQFNwiCVZsw9EFaD6V2wiF2oyYAOJpNg+ApnO5iIwiBecHJuGodEgRHwaFiqHS8D6EqkkDZABEAKI4Ai9bheGjoDD0Xj4CTwAG/EjOSD+wP7AU+yvSc4koEkUH+yhxmDrSoUEhnShkBh9z3neACvtIByjGq1RqNF7vURbRkLFA0ZjfWtM5OQRkYcQpGv0eKOdjUXlYTYMbBUBjyYGzyBSJILjoDRzEsAB5YRRHEKQiQlZgr2SLYUzXbBpCMAAZRDkMQdcqjqbdICnABHVCFmQBUlnbe5ThoMj+zDINYC5LZKJlK4ylVG42OkbI9WYpZsjNRBuFEdULw8Dx5FDGBBVwd5mMoe9IHQz49RpeSMCQigXggkQeRgjgjCgV4p0vLl1BWaRXXoyABHwNYZIFOSmM0xTFxUlI1OSDStKopQ+E4kgclo11snM3Bsm4xBeJcli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3qANM6s9WeoQ1jYaAaoKoFoCNAaxYKbUS/CgA402A6sF9Mjx2pdw4aI1beMIQxAjhDqyYHcaTWXgU1Mx+omqBSFoAls0OqNOgEzWNByRTGuADmsbBnHri8Am4k8S+jU4vpVx+gIAA -->\n\n<!-- internal state end -->"},"request":{"retryCount":3,"retries":3,"retryAfter":16}}}

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: 3

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
cognee/infrastructure/databases/relational/sqlalchemy/SqlAlchemyAdapter.py (1)

275-288: ⚠️ Potential issue | 🔴 Critical

Critical: None default causes runtime failure on PostgreSQL.

Changing schema_name default from "public" to None will break deletions on PostgreSQL. The get_table method (line 380) doesn't handle None properly:

  1. When schema_name=None is passed to get_table, line 31 evaluates to f"None.{table_name}" (literal string "None.table_name")
  2. This won't match any key in metadata.tables since reflect(schema=None) produces unqualified table names
  3. Result: EntityNotFoundError is always raised

The existing caller in cognee/modules/data/methods/delete_dataset.py:58 calls delete_entity_by_id without schema_name, so this change will break dataset deletion.

Either fix get_table to handle None properly, or keep the "public" default for consistency with other methods (delete_table, insert_data, get_table, get_all_data_from_table).

Option 1: Revert to "public" default for consistency
 async def delete_entity_by_id(
-    self, table_name: str, data_id: UUID, schema_name: Optional[str] = None
+    self, table_name: str, data_id: UUID, schema_name: Optional[str] = "public"
 ):
Option 2: Fix get_table to handle None schema
 async def get_table(self, table_name: str, schema_name: Optional[str] = "public") -> Table:
     ...
         else:
             # Create a MetaData instance to load table information
             metadata = MetaData()
             # Load table information from schema into MetaData
             await connection.run_sync(metadata.reflect, schema=schema_name)
-            # Define the full table name
-            full_table_name = f"{schema_name}.{table_name}"
-            # Check if table is in list of tables for the given schema
-            if full_table_name in metadata.tables:
-                return metadata.tables[full_table_name]
-            raise EntityNotFoundError(message=f"Table '{full_table_name}' not found.")
+            # Define the full table name (handle None schema)
+            if schema_name is None:
+                full_table_name = table_name
+            else:
+                full_table_name = f"{schema_name}.{table_name}"
+            # Check if table is in list of tables for the given schema
+            if full_table_name in metadata.tables:
+                return metadata.tables[full_table_name]
+            raise EntityNotFoundError(message=f"Table '{full_table_name}' not found.")
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@cognee/infrastructure/databases/relational/sqlalchemy/SqlAlchemyAdapter.py`
around lines 275 - 288, The failure is caused by get_table building a qualified
key like f"{schema_name}.{table_name}" when schema_name is None, producing
"None.table" and causing EntityNotFoundError; fix get_table (used by
delete_entity_by_id) to handle None by checking unqualified table keys too: if
schema_name is None (or equals the string "None") look up metadata.tables by
table_name (and as a fallback try f"{schema_name}.{table_name}" for explicit
schemas), and ensure reflect(schema=None) behavior is considered when building
keys; update the lookup logic in get_table (and any helper that constructs the
key) so delete_entity_by_id can safely be called without a schema_name.
🧹 Nitpick comments (1)
Dockerfile (1)

31-31: Keep entrypoint.py out of the dependency-cache layer.

Including entrypoint.py in the COPY before uv sync --no-install-project means any entrypoint-only change now forces a full dependency reinstall. Copy it with the application sources instead so Docker only rebuilds the cheap layers for this kind of change.

♻️ Suggested layering change
-COPY README.md pyproject.toml uv.lock entrypoint.sh entrypoint.py ./
+COPY README.md pyproject.toml uv.lock entrypoint.sh ./
@@
 COPY ./cognee /app/cognee
 COPY ./distributed /app/distributed
+COPY ./entrypoint.py /app/entrypoint.py
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@Dockerfile` at line 31, The Dockerfile currently copies entrypoint.py into
the layer used for dependency caching (COPY README.md pyproject.toml uv.lock
entrypoint.sh entrypoint.py ./), causing any change to entrypoint.py to bust the
dependency-install layer; remove entrypoint.py from that COPY (keep README.md,
pyproject.toml, uv.lock, and entrypoint.sh as needed), run the uv sync
--no-install-project dependency step, then copy entrypoint.py together with the
application sources in the later application COPY (the same step that copies
your app files) so changes to entrypoint.py only rebuild the cheap app layer
rather than forcing a full dependency reinstall.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@cognee/__init__.py`:
- Around line 17-21: The example in the module shows top-level await which is
invalid; wrap the sequence of await calls to cognee.add, cognee.cognify, and
cognee.search inside an async entrypoint (e.g., define async def main(): ...),
then run that entrypoint with asyncio.run(main()) so the example is runnable in
standard Python; ensure the example imports asyncio and calls
asyncio.run(main()) instead of using await at top-level.

In `@cognee/tests/unit/modules/storage/test_utils.py`:
- Around line 95-105: The test test_get_own_properties_excludes_nested currently
uses belongs_to_set=["item1","item2"], which is a list[str] and won't trigger
the exclusion logic in get_own_properties; update the test to supply a list
whose first element is a DataPoint (e.g., belongs_to_set=[DataPoint(...)] or
similar nested DataPoint instance) so the exclusion branch in get_own_properties
(in cognee/modules/storage/utils/__init__.py) is exercised and the assertion
that "belongs_to_set" is not in properties will pass.
- Around line 13-25: The test test_copy_model_basic is passing a DataPoint
instance to copy_model but copy_model expects a class and uses model.__name__;
update the test to pass the class (DataPoint) instead of an instance, then
assert the copied model name matches the class name (e.g., "DataPoint") and that
"id" and "type" are in copied.model_fields; alternatively, if you prefer
copy_model to accept instances, adjust copy_model to extract the name from the
instance's type field (accessing instance.type) and update its usage in
copy_model where model.__name__ is referenced.

---

Outside diff comments:
In `@cognee/infrastructure/databases/relational/sqlalchemy/SqlAlchemyAdapter.py`:
- Around line 275-288: The failure is caused by get_table building a qualified
key like f"{schema_name}.{table_name}" when schema_name is None, producing
"None.table" and causing EntityNotFoundError; fix get_table (used by
delete_entity_by_id) to handle None by checking unqualified table keys too: if
schema_name is None (or equals the string "None") look up metadata.tables by
table_name (and as a fallback try f"{schema_name}.{table_name}" for explicit
schemas), and ensure reflect(schema=None) behavior is considered when building
keys; update the lookup logic in get_table (and any helper that constructs the
key) so delete_entity_by_id can safely be called without a schema_name.

---

Nitpick comments:
In `@Dockerfile`:
- Line 31: The Dockerfile currently copies entrypoint.py into the layer used for
dependency caching (COPY README.md pyproject.toml uv.lock entrypoint.sh
entrypoint.py ./), causing any change to entrypoint.py to bust the
dependency-install layer; remove entrypoint.py from that COPY (keep README.md,
pyproject.toml, uv.lock, and entrypoint.sh as needed), run the uv sync
--no-install-project dependency step, then copy entrypoint.py together with the
application sources in the later application COPY (the same step that copies
your app files) so changes to entrypoint.py only rebuild the cheap app layer
rather than forcing a full dependency reinstall.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 704a5350-f07f-4ab6-8fa0-75f29309bfc4

📥 Commits

Reviewing files that changed from the base of the PR and between 07a4916 and 7602801.

📒 Files selected for processing (6)
  • Dockerfile
  • cognee/__init__.py
  • cognee/infrastructure/databases/relational/sqlalchemy/SqlAlchemyAdapter.py
  • cognee/tests/unit/modules/storage/__init__.py
  • cognee/tests/unit/modules/storage/test_utils.py
  • entrypoint.py

Comment on lines +17 to +21
Example Usage:
>>> import cognee
>>> await cognee.add("Cognee builds AI memory.", dataset_name="demo")
>>> await cognee.cognify(dataset_name="demo")
>>> results = await cognee.search("What does Cognee do?")
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🌐 Web query:

Does the standard Python 3.12 interpreter or REPL allow awaitat top level outside anasync def? Please cite the relevant Python documentation.

💡 Result:

No. In standard Python 3.12 code (including the normal interactive REPL), await cannot be used at top level; the language reference states that an await expression “can only be used inside a coroutine function” (i.e., inside async def). [1]

If you want a standard-library REPL that does accept top-level await, Python provides the asyncio REPL via python -m asyncio, which explicitly says to “Use await directly instead of asyncio.run()” and shows await ... at the prompt. [2]

Sources
[1] Python 3.12 Language Reference — 6.4. Await expression https://docs.python.org/3.12/reference/expressions.html
[2] Python docs — asyncio REPL (python -m asyncio) https://docs.python.org/3.12/library/asyncio.html


Wrap the example in an async entrypoint.

The example code shows await at the top level of the Python REPL, which is not valid in standard Python. The await keyword can only be used inside a coroutine function (inside async def). To make this example runnable, wrap it in an async function and use asyncio.run() to execute it:

>>> import asyncio
>>> import cognee
>>> async def main():
...     await cognee.add("Cognee builds AI memory.", dataset_name="demo")
...     await cognee.cognify(dataset_name="demo")
...     results = await cognee.search("What does Cognee do?")
>>> asyncio.run(main())
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@cognee/__init__.py` around lines 17 - 21, The example in the module shows
top-level await which is invalid; wrap the sequence of await calls to
cognee.add, cognee.cognify, and cognee.search inside an async entrypoint (e.g.,
define async def main(): ...), then run that entrypoint with asyncio.run(main())
so the example is runnable in standard Python; ensure the example imports
asyncio and calls asyncio.run(main()) instead of using await at top-level.

Comment on lines +13 to +25
def test_copy_model_basic(self):
"""Test basic DataPoint copying without modifications."""
original = DataPoint(
id=UUID("12345678-1234-5678-1234-567812345678"),
type="TestPoint",
)

copied = copy_model(original)

assert copied.__name__ == "TestPoint"
assert "id" in copied.model_fields
assert "type" in copied.model_fields

Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "copy_model implementation:"
sed -n '23,40p' cognee/modules/storage/utils/__init__.py

echo
echo "new copy_model tests:"
sed -n '13,25p' cognee/tests/unit/modules/storage/test_utils.py

Repository: topoteretes/cognee

Length of output: 1237


Pass a class to copy_model(), not an instance.

copy_model() expects a class as its model parameter and uses model.__name__ to get the class name. The test passes a DataPoint instance instead, which means model.__name__ resolves to "DataPoint" (the class name), not "TestPoint" (the field value). The assertion assert copied.__name__ == "TestPoint" will fail.

Either pass the class (DataPoint itself) or redesign the function to accept instances and extract the name from a field (e.g., type field).

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@cognee/tests/unit/modules/storage/test_utils.py` around lines 13 - 25, The
test test_copy_model_basic is passing a DataPoint instance to copy_model but
copy_model expects a class and uses model.__name__; update the test to pass the
class (DataPoint) instead of an instance, then assert the copied model name
matches the class name (e.g., "DataPoint") and that "id" and "type" are in
copied.model_fields; alternatively, if you prefer copy_model to accept
instances, adjust copy_model to extract the name from the instance's type field
(accessing instance.type) and update its usage in copy_model where
model.__name__ is referenced.

Comment on lines +95 to +105
def test_get_own_properties_excludes_nested(self):
"""Test that nested objects are excluded."""
data_point = DataPoint(
type="TestPoint",
belongs_to_set=["item1", "item2"],
)

properties = get_own_properties(data_point)

# belongs_to_set should be excluded as it's a list with specific types
assert "belongs_to_set" not in properties
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

This case does not hit the exclusion branch you are asserting.

In cognee/modules/storage/utils/__init__.py:43-61, get_own_properties() only filters lists when the first element is a DataPoint. belongs_to_set=["item1", "item2"] is a list[str], so this property will be preserved and Line 105 will fail. Use a nested DataPoint list here if you want to test the exclusion path.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@cognee/tests/unit/modules/storage/test_utils.py` around lines 95 - 105, The
test test_get_own_properties_excludes_nested currently uses
belongs_to_set=["item1","item2"], which is a list[str] and won't trigger the
exclusion logic in get_own_properties; update the test to supply a list whose
first element is a DataPoint (e.g., belongs_to_set=[DataPoint(...)] or similar
nested DataPoint instance) so the exclusion branch in get_own_properties (in
cognee/modules/storage/utils/__init__.py) is exercised and the assertion that
"belongs_to_set" is not in properties will pass.

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.

Add unit tests for chunking module (TextChunker, LangchainChunker)

1 participant