sharedkernel 1.1.0__tar.gz → 1.1.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- sharedkernel-1.1.2/PKG-INFO +26 -0
- sharedkernel-1.1.2/README.md +12 -0
- sharedkernel-1.1.2/setup.py +36 -0
- sharedkernel-1.1.2/sharedkernel/database/mongo_generic_repository.py +50 -0
- sharedkernel-1.1.2/sharedkernel.egg-info/PKG-INFO +26 -0
- {sharedkernel-1.1.0 → sharedkernel-1.1.2}/sharedkernel.egg-info/SOURCES.txt +1 -2
- sharedkernel-1.1.0/PKG-INFO +0 -12
- sharedkernel-1.1.0/README.md +0 -24
- sharedkernel-1.1.0/setup.py +0 -13
- sharedkernel-1.1.0/sharedkernel/database/adapter.py +0 -6
- sharedkernel-1.1.0/sharedkernel/database/mongo_repository_base.py +0 -82
- sharedkernel-1.1.0/sharedkernel.egg-info/PKG-INFO +0 -12
- {sharedkernel-1.1.0 → sharedkernel-1.1.2}/setup.cfg +0 -0
- {sharedkernel-1.1.0 → sharedkernel-1.1.2}/sharedkernel/common.py +0 -0
- {sharedkernel-1.1.0 → sharedkernel-1.1.2}/sharedkernel/config.py +0 -0
- {sharedkernel-1.1.0 → sharedkernel-1.1.2}/sharedkernel/database/__init__.py +0 -0
- {sharedkernel-1.1.0 → sharedkernel-1.1.2}/sharedkernel/database/vector_database_repository/__init__.py +0 -0
- {sharedkernel-1.1.0 → sharedkernel-1.1.2}/sharedkernel/database/vector_database_repository/chroma_startegy.py +0 -0
- {sharedkernel-1.1.0 → sharedkernel-1.1.2}/sharedkernel/database/vector_database_repository/milvus_strategy.py +0 -0
- {sharedkernel-1.1.0 → sharedkernel-1.1.2}/sharedkernel/database/vector_database_repository/vector_database_repository.py +0 -0
- {sharedkernel-1.1.0 → sharedkernel-1.1.2}/sharedkernel/database/vector_database_repository/vector_database_strategy.py +0 -0
- {sharedkernel-1.1.0 → sharedkernel-1.1.2}/sharedkernel/enum/__init__.py +0 -0
- {sharedkernel-1.1.0 → sharedkernel-1.1.2}/sharedkernel/enum/error_code.py +0 -0
- {sharedkernel-1.1.0 → sharedkernel-1.1.2}/sharedkernel/enum/vector_database_type.py +0 -0
- {sharedkernel-1.1.0 → sharedkernel-1.1.2}/sharedkernel/exception/__init__.py +0 -0
- {sharedkernel-1.1.0 → sharedkernel-1.1.2}/sharedkernel/exception/exception.py +0 -0
- {sharedkernel-1.1.0 → sharedkernel-1.1.2}/sharedkernel/exception/exception_handlers.py +0 -0
- {sharedkernel-1.1.0 → sharedkernel-1.1.2}/sharedkernel/jwt_service.py +0 -0
- {sharedkernel-1.1.0 → sharedkernel-1.1.2}/sharedkernel/objects/__init__.py +0 -0
- {sharedkernel-1.1.0 → sharedkernel-1.1.2}/sharedkernel/objects/base_document.py +0 -0
- {sharedkernel-1.1.0 → sharedkernel-1.1.2}/sharedkernel/objects/jwt_model.py +0 -0
- {sharedkernel-1.1.0 → sharedkernel-1.1.2}/sharedkernel/objects/result.py +0 -0
- {sharedkernel-1.1.0 → sharedkernel-1.1.2}/sharedkernel/string_extentions.py +0 -0
- {sharedkernel-1.1.0 → sharedkernel-1.1.2}/sharedkernel.egg-info/dependency_links.txt +0 -0
- {sharedkernel-1.1.0 → sharedkernel-1.1.2}/sharedkernel.egg-info/requires.txt +0 -0
- {sharedkernel-1.1.0 → sharedkernel-1.1.2}/sharedkernel.egg-info/top_level.txt +0 -0
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: sharedkernel
|
|
3
|
+
Version: 1.1.2
|
|
4
|
+
Summary: sharekernel is an shared package between all python projects
|
|
5
|
+
Author: Smilinno
|
|
6
|
+
Description-Content-Type: text/markdown
|
|
7
|
+
Requires-Dist: numpy
|
|
8
|
+
Requires-Dist: requests
|
|
9
|
+
Requires-Dist: pymongo
|
|
10
|
+
Requires-Dist: fastapi==0.89.1
|
|
11
|
+
Requires-Dist: PyJWT
|
|
12
|
+
Requires-Dist: pymilvus
|
|
13
|
+
Requires-Dist: chromadb
|
|
14
|
+
|
|
15
|
+
# SharedKernel
|
|
16
|
+
this a shared kernel package
|
|
17
|
+
|
|
18
|
+
# Create Package
|
|
19
|
+
py -m pip install --upgrade build
|
|
20
|
+
py -m build
|
|
21
|
+
cd dist
|
|
22
|
+
py -m pip install --upgrade twine
|
|
23
|
+
py -m twine upload dist/*
|
|
24
|
+
|
|
25
|
+
# Pypi
|
|
26
|
+
pip install sharedkernel
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
from setuptools import setup
|
|
2
|
+
|
|
3
|
+
# read the contents of your README file
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
|
|
6
|
+
this_directory = Path(__file__).parent
|
|
7
|
+
long_description = (this_directory / "README.md").read_text()
|
|
8
|
+
|
|
9
|
+
setup(
|
|
10
|
+
# Needed to silence warnings (and to be a worthwhile package)
|
|
11
|
+
name="sharedkernel",
|
|
12
|
+
author="Smilinno",
|
|
13
|
+
packages=[
|
|
14
|
+
"sharedkernel",
|
|
15
|
+
"sharedkernel.database",
|
|
16
|
+
"sharedkernel.database.vector_database_repository",
|
|
17
|
+
"sharedkernel.enum",
|
|
18
|
+
"sharedkernel.exception",
|
|
19
|
+
"sharedkernel.objects",
|
|
20
|
+
],
|
|
21
|
+
# Needed for dependencies
|
|
22
|
+
install_requires=[
|
|
23
|
+
"numpy",
|
|
24
|
+
"requests",
|
|
25
|
+
"pymongo",
|
|
26
|
+
"fastapi==0.89.1",
|
|
27
|
+
"PyJWT",
|
|
28
|
+
"pymilvus",
|
|
29
|
+
"chromadb",
|
|
30
|
+
],
|
|
31
|
+
# *strongly* suggested for sharing
|
|
32
|
+
version="1.1.2",
|
|
33
|
+
description="sharekernel is an shared package between all python projects",
|
|
34
|
+
long_description=long_description,
|
|
35
|
+
long_description_content_type="text/markdown",
|
|
36
|
+
)
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
from pymongo import MongoClient
|
|
2
|
+
from bson import ObjectId
|
|
3
|
+
from typing import Generic, TypeVar, List, Type
|
|
4
|
+
from pydantic import BaseModel
|
|
5
|
+
from sharedkernel.string_extentions import camel_to_snake
|
|
6
|
+
|
|
7
|
+
T = TypeVar("T", bound=BaseModel)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class MongoGenericRepository(Generic[T]):
|
|
11
|
+
def __init__(self, database: MongoClient, model: Type[T]):
|
|
12
|
+
self.database = database
|
|
13
|
+
self.__collection_name = camel_to_snake(model.__name__)
|
|
14
|
+
self.__collection = self.database[self.__collection_name]
|
|
15
|
+
self.model = model
|
|
16
|
+
|
|
17
|
+
def _map_to_model(self, document: dict) -> T:
|
|
18
|
+
document["id"] = str(document.pop("_id"))
|
|
19
|
+
return self.model.parse_obj(document)
|
|
20
|
+
|
|
21
|
+
def find_one(self, id: str) -> T:
|
|
22
|
+
query = {"_id": ObjectId(id), "is_deleted": False}
|
|
23
|
+
result = self.__collection.find_one(query)
|
|
24
|
+
return self._map_to_model(result) if result else None
|
|
25
|
+
|
|
26
|
+
def insert_one(self, data: T) -> str:
|
|
27
|
+
delattr(data, "id")
|
|
28
|
+
result = self.__collection.insert_one(data.dict())
|
|
29
|
+
return str(result.inserted_id)
|
|
30
|
+
|
|
31
|
+
def insert_many(self, data: List[T]) -> List[str]:
|
|
32
|
+
data_list = [delattr(d.dict(), "id") for d in data]
|
|
33
|
+
result = self.__collection.insert_many(data_list)
|
|
34
|
+
return [str(id_) for id_ in result.inserted_ids]
|
|
35
|
+
|
|
36
|
+
def update_one(self, id: str, data: T) -> int:
|
|
37
|
+
delattr(data, "id")
|
|
38
|
+
query = {"_id": ObjectId(id)}
|
|
39
|
+
result = self.__collection.update_one(query, {"$set": data.dict()})
|
|
40
|
+
return result.modified_count
|
|
41
|
+
|
|
42
|
+
def delete_one(self, id: str) -> int:
|
|
43
|
+
query = {"_id": ObjectId(id)}
|
|
44
|
+
result = self.__collection.delete_one(query)
|
|
45
|
+
return result.deleted_count
|
|
46
|
+
|
|
47
|
+
def get_all(self, page_number=1, page_size=10) -> List[T]:
|
|
48
|
+
skip_count = (page_number - 1) * page_size
|
|
49
|
+
result = self.__collection.find().skip(skip_count).limit(page_size)
|
|
50
|
+
return [self._map_to_model(doc) for doc in result]
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: sharedkernel
|
|
3
|
+
Version: 1.1.2
|
|
4
|
+
Summary: sharekernel is an shared package between all python projects
|
|
5
|
+
Author: Smilinno
|
|
6
|
+
Description-Content-Type: text/markdown
|
|
7
|
+
Requires-Dist: numpy
|
|
8
|
+
Requires-Dist: requests
|
|
9
|
+
Requires-Dist: pymongo
|
|
10
|
+
Requires-Dist: fastapi==0.89.1
|
|
11
|
+
Requires-Dist: PyJWT
|
|
12
|
+
Requires-Dist: pymilvus
|
|
13
|
+
Requires-Dist: chromadb
|
|
14
|
+
|
|
15
|
+
# SharedKernel
|
|
16
|
+
this a shared kernel package
|
|
17
|
+
|
|
18
|
+
# Create Package
|
|
19
|
+
py -m pip install --upgrade build
|
|
20
|
+
py -m build
|
|
21
|
+
cd dist
|
|
22
|
+
py -m pip install --upgrade twine
|
|
23
|
+
py -m twine upload dist/*
|
|
24
|
+
|
|
25
|
+
# Pypi
|
|
26
|
+
pip install sharedkernel
|
|
@@ -10,8 +10,7 @@ sharedkernel.egg-info/dependency_links.txt
|
|
|
10
10
|
sharedkernel.egg-info/requires.txt
|
|
11
11
|
sharedkernel.egg-info/top_level.txt
|
|
12
12
|
sharedkernel/database/__init__.py
|
|
13
|
-
sharedkernel/database/
|
|
14
|
-
sharedkernel/database/mongo_repository_base.py
|
|
13
|
+
sharedkernel/database/mongo_generic_repository.py
|
|
15
14
|
sharedkernel/database/vector_database_repository/__init__.py
|
|
16
15
|
sharedkernel/database/vector_database_repository/chroma_startegy.py
|
|
17
16
|
sharedkernel/database/vector_database_repository/milvus_strategy.py
|
sharedkernel-1.1.0/PKG-INFO
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.1
|
|
2
|
-
Name: sharedkernel
|
|
3
|
-
Version: 1.1.0
|
|
4
|
-
Summary: sharekernel is an shared package between all python projects
|
|
5
|
-
Author: Smilinno
|
|
6
|
-
Requires-Dist: numpy
|
|
7
|
-
Requires-Dist: requests
|
|
8
|
-
Requires-Dist: pymongo
|
|
9
|
-
Requires-Dist: fastapi==0.89.1
|
|
10
|
-
Requires-Dist: PyJWT
|
|
11
|
-
Requires-Dist: pymilvus
|
|
12
|
-
Requires-Dist: chromadb
|
sharedkernel-1.1.0/README.md
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
# SharedKernel
|
|
2
|
-
this a shared kernel package
|
|
3
|
-
|
|
4
|
-
# Create Package
|
|
5
|
-
py -m pip install --upgrade build
|
|
6
|
-
py -m build
|
|
7
|
-
cd dist
|
|
8
|
-
py -m pip install --upgrade twine
|
|
9
|
-
py -m twine upload dist/*
|
|
10
|
-
|
|
11
|
-
# Pypi
|
|
12
|
-
pip install sharedkernel==1.0.0
|
|
13
|
-
# Sample Code
|
|
14
|
-
```python
|
|
15
|
-
from fastapi import FastAPI,Depends
|
|
16
|
-
|
|
17
|
-
from sharedkernel import jwt_service
|
|
18
|
-
from sharedkernel.objects import JwtModel
|
|
19
|
-
from sharedkernel import config
|
|
20
|
-
app = FastAPI(title="Sample Apis",dependencies=[Depends(jwt_service.JWTBearer(JwtModel(secret_key=config.JWT_SECRETKEY,
|
|
21
|
-
algorithms=config.JWT_ALGORITHM,
|
|
22
|
-
audience=config.JWT_AUDIENCE,
|
|
23
|
-
issuer=config.JWT_ISSURE)))])
|
|
24
|
-
```
|
sharedkernel-1.1.0/setup.py
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
from setuptools import setup
|
|
2
|
-
|
|
3
|
-
setup(
|
|
4
|
-
# Needed to silence warnings (and to be a worthwhile package)
|
|
5
|
-
name='sharedkernel',
|
|
6
|
-
author='Smilinno',
|
|
7
|
-
packages=['sharedkernel','sharedkernel.database','sharedkernel.database.vector_database_repository','sharedkernel.enum','sharedkernel.exception','sharedkernel.objects'],
|
|
8
|
-
# Needed for dependencies
|
|
9
|
-
install_requires=['numpy','requests','pymongo','fastapi==0.89.1','PyJWT','pymilvus','chromadb'],
|
|
10
|
-
# *strongly* suggested for sharing
|
|
11
|
-
version='1.1.0',
|
|
12
|
-
description='sharekernel is an shared package between all python projects',
|
|
13
|
-
)
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
from typing import (Optional,
|
|
2
|
-
List
|
|
3
|
-
)
|
|
4
|
-
from bson.objectid import ObjectId
|
|
5
|
-
from typing import Generic, TypeVar
|
|
6
|
-
from pydantic import BaseModel
|
|
7
|
-
from pydantic import parse_obj_as
|
|
8
|
-
|
|
9
|
-
from sharedkernel.string_extentions import camel_to_snake
|
|
10
|
-
from .adapter import MongoDBClient
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
from sharedkernel.exception.exception import BusinessException
|
|
14
|
-
from sharedkernel.enum.error_code import ErrorCode
|
|
15
|
-
|
|
16
|
-
mongo_client= MongoDBClient()
|
|
17
|
-
|
|
18
|
-
ResultT = TypeVar("ResultT")
|
|
19
|
-
|
|
20
|
-
T = TypeVar("T", bound=BaseModel)
|
|
21
|
-
|
|
22
|
-
class MongoRepositoryBase(Generic[T]):
|
|
23
|
-
|
|
24
|
-
def __init__(self,model):
|
|
25
|
-
self.model = model
|
|
26
|
-
self.model_name= camel_to_snake(self.model.__name__)
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
def find(self,id: str) -> T:
|
|
30
|
-
if (not ObjectId.is_valid(id)):
|
|
31
|
-
raise BusinessException(ErrorCode.Item_NotFound)
|
|
32
|
-
|
|
33
|
-
query = {"_id": ObjectId(id),"is_deleted":False}
|
|
34
|
-
|
|
35
|
-
item = mongo_client.domain[self.model_name].find_one(query)
|
|
36
|
-
|
|
37
|
-
if (not item):
|
|
38
|
-
raise BusinessException(ErrorCode.Item_NotFound)
|
|
39
|
-
|
|
40
|
-
item['_id']=str(item['_id'])
|
|
41
|
-
item['id']= item['_id']
|
|
42
|
-
item.pop('_id')
|
|
43
|
-
|
|
44
|
-
return self.model.parse_obj(item) if item else None
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
def get_all(self,query:dict = None) -> Optional[List]:
|
|
48
|
-
if query:
|
|
49
|
-
query["is_deleted"]= False
|
|
50
|
-
else:
|
|
51
|
-
query= {"is_deleted":False}
|
|
52
|
-
items = list(mongo_client.domain[self.model_name].find(query))
|
|
53
|
-
|
|
54
|
-
for item in items:
|
|
55
|
-
item['_id'] = str(item['_id'])
|
|
56
|
-
item['id']= item['_id']
|
|
57
|
-
item.pop('_id')
|
|
58
|
-
|
|
59
|
-
return parse_obj_as(List[self.model],items)
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
def insert(self, insert_data: T) -> str:
|
|
63
|
-
delattr(insert_data, "id")
|
|
64
|
-
inserted_data= mongo_client.domain[self.model_name].insert_one(insert_data.dict())
|
|
65
|
-
|
|
66
|
-
return str(inserted_data.inserted_id)
|
|
67
|
-
|
|
68
|
-
def bulk_insert(self, insert_data: List[T]):
|
|
69
|
-
insert_data=[delattr(data, "id") for data in insert_data]
|
|
70
|
-
mongo_client.domain[self.model_name].insert_many(insert_data)
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
def update(self,id:str,update_data: T):
|
|
75
|
-
query = {"_id": ObjectId(id)}
|
|
76
|
-
delattr(update_data, "id")
|
|
77
|
-
mongo_client.domain[self.model_name].update_one(query, {"$set": update_data.dict()}, upsert=False)
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
def query(self):
|
|
81
|
-
return mongo_client.domain[self.model_name]
|
|
82
|
-
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.1
|
|
2
|
-
Name: sharedkernel
|
|
3
|
-
Version: 1.1.0
|
|
4
|
-
Summary: sharekernel is an shared package between all python projects
|
|
5
|
-
Author: Smilinno
|
|
6
|
-
Requires-Dist: numpy
|
|
7
|
-
Requires-Dist: requests
|
|
8
|
-
Requires-Dist: pymongo
|
|
9
|
-
Requires-Dist: fastapi==0.89.1
|
|
10
|
-
Requires-Dist: PyJWT
|
|
11
|
-
Requires-Dist: pymilvus
|
|
12
|
-
Requires-Dist: chromadb
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|