Skip to content

Commit

Permalink
chore: linting (mem0ai#597)
Browse files Browse the repository at this point in the history
  • Loading branch information
cachho committed Sep 12, 2023
1 parent 0f9a10c commit 0314694
Show file tree
Hide file tree
Showing 11 changed files with 25 additions and 35 deletions.
22 changes: 10 additions & 12 deletions embedchain/embedchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ def load_and_embed(
src: Any,
metadata: Optional[Dict[str, Any]] = None,
source_id: Optional[str] = None,
dry_run = False
dry_run=False,
) -> Tuple[List[str], Dict[str, Any], List[str], int]:
"""The loader to use to load the data.
Expand Down Expand Up @@ -320,14 +320,14 @@ def load_and_embed(
return list(documents), metadatas, ids, count_new_chunks

def load_and_embed_v2(
self,
loader: BaseLoader,
chunker: BaseChunker,
src: Any,
metadata: Optional[Dict[str, Any]] = None,
source_id: Optional[str] = None,
dry_run = False
):
self,
loader: BaseLoader,
chunker: BaseChunker,
src: Any,
metadata: Optional[Dict[str, Any]] = None,
source_id: Optional[str] = None,
dry_run=False,
):
"""
Loads the data from the given URL, chunks it, and adds it to database.
Expand Down Expand Up @@ -364,9 +364,7 @@ def load_and_embed_v2(
# this means that doc content has changed.
if existing_doc_id and existing_doc_id != new_doc_id:
print("Doc content has changed. Recomputing chunks and embeddings intelligently.")
self.db.delete({
"doc_id": existing_doc_id
})
self.db.delete({"doc_id": existing_doc_id})

# get existing ids, and discard doc if any common id exist.
where = {"app_id": self.config.id} if self.config.id is not None else {}
Expand Down
5 changes: 1 addition & 4 deletions embedchain/loaders/csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,4 @@ def load_data(content):
lines.append(line)
result.append({"content": line, "meta_data": {"url": content, "row": i + 1}})
doc_id = hashlib.sha256((content + " ".join(lines)).encode()).hexdigest()
return {
"doc_id": doc_id,
"data": result
}
return {"doc_id": doc_id, "data": result}
2 changes: 1 addition & 1 deletion embedchain/loaders/local_qna_pair.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ def load_data(self, content):
"content": content,
"meta_data": meta_data,
}
]
],
}
2 changes: 1 addition & 1 deletion embedchain/loaders/local_text.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ def load_data(self, content):
"content": content,
"meta_data": meta_data,
}
]
],
}
10 changes: 5 additions & 5 deletions embedchain/loaders/notion.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ def load_data(self, source):
return {
"doc_id": doc_id,
"data": [
{
"content": text,
"meta_data": {"url": f"notion-{formatted_id}"},
}
],
{
"content": text,
"meta_data": {"url": f"notion-{formatted_id}"},
}
],
}
5 changes: 1 addition & 4 deletions embedchain/loaders/sitemap.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,4 @@ def load_data(self, sitemap_url):
logging.warning(f"Page is not readable (too many invalid characters): {link}")
except ParserRejectedMarkup as e:
logging.error(f"Failed to parse {link}: {e}")
return {
"doc_id": doc_id,
"data": [data[0] for data in output]
}
return {"doc_id": doc_id, "data": [data[0] for data in output]}
2 changes: 1 addition & 1 deletion embedchain/loaders/web_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def load_data(self, url):
}
content = content
doc_id = hashlib.sha256((content + url).encode()).hexdigest()
return {
return {
"doc_id": doc_id,
"data": [
{
Expand Down
2 changes: 1 addition & 1 deletion embedchain/vectordb/base_vector_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,4 @@ def reset(self):
raise NotImplementedError

def set_collection_name(self, name: str):
raise NotImplementedError
raise NotImplementedError
6 changes: 2 additions & 4 deletions embedchain/vectordb/chroma.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import logging
from typing import Dict, List, Optional, Any
from typing import Any, Dict, List, Optional

from chromadb import Collection, QueryResult
from langchain.docstore.document import Document
Expand Down Expand Up @@ -105,9 +105,7 @@ def get(self, ids=None, where=None, limit=None):
args["where"] = where
if limit:
args["limit"] = limit
return self.collection.get(
**args
)
return self.collection.get(**args)

def get_advanced(self, where):
return self.collection.get(where=where, limit=1)
Expand Down
2 changes: 1 addition & 1 deletion tests/chunkers/test_text.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,5 +76,5 @@ def load_data(self, src):
"content": src,
"meta_data": {"url": "none"},
}
]
],
}
2 changes: 1 addition & 1 deletion tests/embedchain/test_add.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from unittest.mock import MagicMock, patch

from embedchain import App
from embedchain.config import AppConfig, AddConfig, ChunkerConfig
from embedchain.config import AddConfig, AppConfig, ChunkerConfig
from embedchain.models.data_type import DataType


Expand Down

0 comments on commit 0314694

Please sign in to comment.