Skip to content

Commit

Permalink
feature: update constants in files
Browse files Browse the repository at this point in the history
  • Loading branch information
klich3 committed Jan 2, 2024
1 parent 435eb64 commit 1dec0a1
Show file tree
Hide file tree
Showing 3 changed files with 147 additions and 0 deletions.
10 changes: 10 additions & 0 deletions Samples/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Sample implementation

Files:
* `generial`: post, get, count, delete
* `post`: post

1) create virtual environment `virtual ./.venv`
2) activate it ` . ./venv/bin/activate`
3) install dependencies `pip install Rocket-Store`
4) run test `python test.py`
108 changes: 108 additions & 0 deletions Samples/generic_example.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
"""
█▀ █▄█ █▀▀ █░█ █▀▀ █░█
▄█ ░█░ █▄▄ █▀█ ██▄ ▀▄▀
Author: <Anton Sychev> (anton at sychev dot xyz)
sample.py (c) 2023
Created: 2023-12-01 01:02:01
Desc: sample create instance of RocketStore
Docs: documentation
"""

from Rocketstore import Rocketstore

rs = Rocketstore(**{"data_storage_area": "./test",
"data_format": Rocketstore._FORMAT_JSON})

rs.post("cars", "Mercedes_Benz_GT_R", {"owner": "Lisa Simpson"})

print("GET: ", rs.get("cars", ""), "\n-----\n")
# GET: {'count': 1, 'key': ['Mercedes_Benz_GT_R'], 'result': [{'owner': 'Lisa Simpson'}]}

rs.post("cars", "BMW_740li", {
"owner": "Greg Onslow"}, Rocketstore._ADD_AUTO_INC)
rs.post("cars", "BMW_740li", {"owner": "Sam Wise"}, Rocketstore._ADD_AUTO_INC)
rs.post("cars", "BMW_740li", {"owner": "Bill Bo"}, Rocketstore._ADD_AUTO_INC)
# tienen que haber un BMW_740li

print("GET ALL CARS: ", rs.get("cars", "*"), "\n-----\n")
'''
Get all records:
{
count: 2,
key: [ 'Mercedes_Benz_GT_R', 'BMW_740li' ],
result: [ { owner: 'Lisa Simpson' }, { owner: 'Bill Bo' } ]
}
'''


dataset = {
"Gregs_BMW_740li": {"owner": "Greg Onslow"},
"Lisas_Mercedes_Benz_GT_R": {"owner": "Lisa Simpson"},
"Bills_BMW_740li": {"owner": "Bill Bo"},
}

for i in dataset:
rs.post("cars", i, dataset[i])

print("GET BMW's: ", rs.get("cars", "*BMW*"), "\n-----\n")
'''
Get BMW's:
{
count: 3,
key: [ 'BMW_740li', 'Gregs_BMW_740li', 'Bills_BMW_740li' ],
result: [
{ owner: 'Bill Bo' },
{ owner: 'Greg Onslow' },
{ owner: 'Bill Bo' }
]
}
'''


print("Get list ordered by alphabetically descending keys: ",
rs.get("cars", "", Rocketstore._ORDER_DESC), "\n-----\n")
'''
Get list ordered by alphabetically descending keys:
{
count: 5,
key: [
'Mercedes_Benz_GT_R',
'BMW_740li',
'Gregs_BMW_740li',
'Lisas_Mercedes_Benz_GT_R',
'Bills_BMW_740li'
],
result: [
{ owner: 'Lisa Simpson' },
{ owner: 'Bill Bo' },
{ owner: 'Greg Onslow' },
{ owner: 'Lisa Simpson' },
{ owner: 'Bill Bo' }
]
}
'''

r = rs.delete("cars", "*Mercedes*")
print("Delete all Mercedes's: ", r, "\n-----\n")
''''
Delete all Mercedes's:
{ count: 2 }
'''

print("Return all cars: ", rs.get("cars", "*"), "\n-----\n")
'''
{
count: 3,
key: [ 'BMW_740li', 'Gregs_BMW_740li', 'Bills_BMW_740li' ],
result: [
{ owner: 'Bill Bo' },
{ owner: 'Greg Onslow' },
{ owner: 'Bill Bo' }
]
}
'''


print("Delete all records: ", rs.delete(), "\n-----\n")
29 changes: 29 additions & 0 deletions Samples/post.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
from Rocketstore import Rocketstore

rs = Rocketstore(**{"data_storage_area": "./test"})

print(rs)
print("test Constants:", rs._ADD_AUTO_INC)
print("test Constants: ", Rocketstore._ADD_AUTO_INC)

dataInput = {
"content": "hello asfalsdfsalfaslflasl",
"embeddings": [0.2, 0.31231312, 0.111],
}


out = rs.post("glOtc6EzYQTZEt0J18cU1f4Ycdz1H8WWTDVkBQTp1Gv2BWgb",
"memories", dataInput)

print(out)


out = rs.post("glOtc6EzYQTZEt0J18cU1f4Ycdz1H8WWTDVkBQTp1Gv2BWgb",
"memories", dataInput, rs._ADD_AUTO_INC)

print(out)

out = rs.post("glOtc6EzYQTZEt0J18cU1f4Ycdz1H8WWTDVkBQTp1Gv2BWgb",
"memories", dataInput, Rocketstore._ADD_AUTO_INC)

print(out)

0 comments on commit 1dec0a1

Please sign in to comment.