Skip to content

Commit

Permalink
fix test_ExpeDBLinearLocator_store
Browse files Browse the repository at this point in the history
  • Loading branch information
wd400 committed Mar 8, 2024
1 parent 97d9a34 commit da09e6c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,8 @@ def mock_checkpoint():


def test_ExpeDBLocator_store():
bin = b"123 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
bin = b"123"
loc = ExpeDBLocator(resource_uri=RESOURCE_URI)
print('loc', loc)
uid = loc.store(bin)
print('uid', uid)

Expand All @@ -70,9 +69,11 @@ def test_ExpeDBLocator_store():
print('mongo_id', mongo_id)
response_bin = requests.get(RESOURCE_URI + "/" + mongo_id + "/metadata").content

print('response_bin', response_bin)

response_bin = codecs.decode(response_bin, encoding="base64")

print('response_bin', response_bin)


assert response_bin == bin

Expand Down Expand Up @@ -126,11 +127,18 @@ def test_ExpeDBLinearLocator_store():
bin = saver.serialize()
dbname, _ = FileLinearLocator.parse_bin(bin)

print("dbname", dbname)

# delete doc if exists
response_arr = expedb_locators._query_uid(RESOURCE_URI, dbname)
mongo_id = response_arr[0]["_id"]
entrypoint_url = os.path.join(RESOURCE_URI, mongo_id)
requests.delete(entrypoint_url)
if len(response_arr)==1:
mongo_id = response_arr[0]["_id"]
entrypoint_url = os.path.join(RESOURCE_URI, mongo_id)
requests.delete(entrypoint_url)
elif len(response_arr)>1:
raise Exception("Weird, there are multiple documents with the same name")



# store
loc = ExpeDBLinearLocator(resource_uri=RESOURCE_URI)
Expand Down
2 changes: 1 addition & 1 deletion services/base/ExpeDB/API/flask_app/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def _get_file_from_document(document, filename, _filename: str = ""):
else:
try:
print("filename", filename, file=sys.stderr)
file = fs.get(document[filename])
file = fs.get(ObjectId(document[filename]))
except:
# if can't find file, try to follow pointer one level
new_filename = str(document[filename])
Expand Down

0 comments on commit da09e6c

Please sign in to comment.