Closed plaethosai closed 2 weeks ago
Hey @plaethosai! Great to see you back. Hope you're doing well!
The TypeError: 'NoneType' object is not iterable
error in the celery_worker.process_integration_brain_sync
task likely occurs because the integration.get_integration_brain_by_type_integration("notion")
call returns None
instead of an iterable object (like a list). This can happen if the method get_integration_brain_by_type_integration
does not find any integrations of type "notion" and returns None
instead of an empty list or if there's an issue within the method itself that leads to an unexpected None
return.
To resolve this issue, ensure that get_integration_brain_by_type_integration
always returns an iterable object, even when no integrations are found. This can be done by returning an empty list if no results are found or by adding a check before iterating over integrations
to ensure it is not None
. Here's a quick example of how you might modify the process_integration_brain_sync
task to include such a check:
@celery.task
def process_integration_brain_sync():
integration = IntegrationBrain()
integrations = integration.get_integration_brain_by_type_integration("notion")
if integrations is None:
logger.info("No integrations found.")
return
time = datetime.now(timezone.utc)
for integration in integrations:
print(f"last_synced: {integration.last_synced}")
last_synced = datetime.strptime(
integration.last_synced, "%Y-%m-%dT%H:%M:%S.%f%z"
)
if last_synced < time - timedelta(hours=12):
process_integration_brain_sync_user_brain.delay(
brain_id=integration.brain_id, user_id=integration.user_id
)
Regarding the issue of the backend core failing to import BaseSettings
from pydantic
, this could be due to several reasons such as an incorrect Pydantic version where BaseSettings
is not available, or a misconfiguration in the environment. To resolve this, ensure that you have the correct version of Pydantic installed where BaseSettings
is available. BaseSettings
is a class provided by Pydantic for settings management, so you should ensure that your Pydantic installation is not corrupted and is up to date. You can update Pydantic using pip:
pip install -U pydantic
If the issue persists, check your import statements to ensure they are correct and that there are no circular dependencies or other import-related issues in your project.
The celery_worker.process_integration_brain_sync
task in the quivr codebase is designed to synchronize user brains with their Notion integrations. It retrieves all integrations of type "notion" from the database and checks if the last synchronization time for each integration is more than 12 hours ago. If so, it triggers the process_integration_brain_sync_user_brain
task for each of those integrations, passing the brain_id
and user_id
as arguments. This task is scheduled to run every 5 minutes. You can find more details in the backend/celery_worker.py file.
Thanks for your contributions, we'll be closing this issue as it has gone stale. Feel free to reopen if you'd like to continue the discussion.
What happened?
A bug happened! unable to create brain
Relevant log output
Twitter / LinkedIn details
No response