feat: add type hints to TextData and forget module#3081
Open
jasoncobra3 wants to merge 6 commits into
Open
Conversation
## Summary - Merge current dev into main for v1.1.2 - Includes the public Cognee frontend sync and CLI UI release assets - Includes the Postgres neighborhood seed cast fix and usage logger e2e retry workflow update ## Release notes After this merges, run .github/workflows/release.yml on main to publish the main release and latest Docker tag. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added conversation-driven search with history sidebar and per-message dataset tracking. * Introduced "Brains" browser with document management, file uploads, and drag-and-drop support. * Added knowledge graph customization: select/assign graph models, generate/edit custom extraction prompts, and upload/manage ontologies. * Enhanced agent connection with tab-based onboarding and modal-driven setup flows. * Added mascot animation feedback throughout the app for loading states. * **Improvements** * Rebranded terminology: "Dataset" → "Brain" across the application. * Redesigned connections page with agent permission modeling and sharing workflows. * Integrated analytics event tracking for user interactions across major flows. * Enhanced API Keys management with tenant access controls and analytics. * Improved dashboard with updated metrics, activity feed, and embedded search. * **Bug Fixes** * Fixed PostgreSQL graph adapter seed parameter casting for proper neighborhood queries. * **Chores** * Bumped version to 1.1.2. <!-- review_stack_entry_start --> [](https://app.coderabbit.ai/change-stack/topoteretes/cognee/pull/2935?utm_source=github_walkthrough&utm_medium=github&utm_campaign=change_stack) <!-- review_stack_entry_end --> <!-- end of auto-generated comment: release notes by coderabbit.ai -->
Updated the README to clarify Cognee's purpose and features, emphasizing its role as an open-source AI memory platform for agents. Enhanced descriptions of data ingestion, knowledge graph, and cognitive science approaches.
In API mode (--api-url, remote backend) cognify_status was non-functional: it resolved the dataset via local get_default_user()/get_unique_dataset_id() (SQLite, absent in the MCP process) and get_pipeline_status() raised NotImplementedError. On main this surfaced as "not available in API mode"; on 0.5.4 it crashed with sqlite3.OperationalError. Resolve the dataset id over HTTP via list_datasets() and read status from the existing GET /api/v1/datasets/status endpoint. Direct mode is unchanged. Re-lands the fix from topoteretes#2418, which was closed unmerged and not carried by the superseding topoteretes#2459.
…etes#3068) ## Summary Makes the MCP `cognify_status` tool work in **API mode** (`cognee-mcp --api-url ...`, remote backend). Today it is non-functional there: - On `main`: returns `❌ Pipeline status is not available in API mode`. - On released 0.5.4: crashes with `sqlite3.OperationalError: unable to open database file`. Fixes topoteretes#3067. ## Root cause `cognify_status` depended on a local cognee install even in API mode: - `server.py` resolved the dataset via `get_default_user()` / `get_unique_dataset_id()` (local SQLite, absent in the MCP process). - `cognee_client.get_pipeline_status()` hard-stopped in API mode with `raise NotImplementedError("Pipeline status is not available via API")`. The endpoint the original `NotImplementedError` comment asked for already exists: `GET /api/v1/datasets/status?dataset=<id>` → `{dataset_id: PipelineRunStatus}`. ## Changes - **`cognee-mcp/src/cognee_client.py`** — `get_pipeline_status()`: in API mode, call `GET /api/v1/datasets/status` (one `dataset` query param per id) and return the parsed `{dataset_id: status}` map instead of raising. - **`cognee-mcp/src/server.py`** — `cognify_status()`: in API mode, resolve the dataset id via `list_datasets()` (HTTP), then fall through to the existing single-/multi-pipeline status logic. Returns a clear "dataset not found" message when the name is unknown. Direct mode is unchanged. ## History This re-lands topoteretes#2418 (`fix(mcp): cognify_status works in API mode via REST endpoint`), which was closed unmerged and was **not** carried by the superseding topoteretes#2459 (that PR added the dataset/`pipelines` parameters but left the API-mode path raising). The fix is rebased onto the current `main` handler, so it preserves the `pipelines` selection and agent-scoped default dataset behavior. ## Testing Verified end-to-end against a live cognee 1.x server: the patched MCP boots in API mode and `cognify_status` returns real status (`{"<dataset-id>": "DATASET_PROCESSING_STARTED"}`, `isError: false`) where upstream returned the "not available" message. ## Type of change - [x] Bug fix (non-breaking change which fixes an issue)
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Closes topoteretes#2681 Added Python type hints to function parameters and return types in two modules as part of the gradual type enforcement effort: - cognee/modules/ingestion/data_types/TextData.py Added return types to all methods: get_identifier() -> str, get_metadata() -> dict, ensure_metadata() -> None, get_data() -> AsyncGenerator[str, None] Added TextData return type to create_text_data() Added dict annotation to metadata class variable - cognee/api/v1/forget/forget.py Added user: Any type to all 7 functions to avoid circular imports while providing explicit typing signal Added Any to existing typing imports No logic changes made. ruff check passes on both files.
Contributor
|
Hello @jasoncobra3, thank you for submitting a PR! We will respond as soon as possible. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #2681
What changed
cognee/modules/ingestion/data_types/TextData.pycreate_text_data()→-> "TextData"get_identifier()→-> strget_metadata()→-> dictensure_metadata()→-> Noneget_data()→-> AsyncGenerator[str, None]dictannotation tometadataclass variablecognee/api/v1/forget/forget.pyuser: Anyto all 7 functions to avoid circularimports while providing an explicit typing signal
Anyto existingtypingimportsNotes
user: Anywas chosen over importing the User modeldirectly to avoid circular dependency issues
ruff checkpasses on both filesPart of
This is a small focused first step toward #2681
enforcing type hints gradually across the codebase.
Happy to continue with more files if maintainers
want to keep the momentum going!