Skip to content

Commit

Permalink
update metrics
Browse files Browse the repository at this point in the history
Signed-off-by: Praneeth Bedapudi <[email protected]>
  • Loading branch information
bedapudi6788 committed Sep 4, 2023
1 parent b7bcbb3 commit 86f1fbc
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion smartlog/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
EMAIL = "[email protected]"
AUTHOR = "BEDAPUDI PRANEETH"
REQUIRES_PYTHON = ">=3.6.0"
VERSION = "0.0.1.dev19"
VERSION = "0.0.1.dev19.1"

# What packages are required for this module to be executed?
REQUIRED = ["requests", "liteindex"]
Expand Down
12 changes: 11 additions & 1 deletion smartlog/smartlogger/smartlogger.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ def upload_to_smartdash():
"--server_url", type=str, help="Smartdash server URL", required=True
)
args = parser.parse_args()

print(f"Starting sync to {args.server_url}")
_upload_to_smartdash(args.save_dir, args.server_url)


Expand All @@ -27,6 +29,7 @@ def _upload_to_smartdash(log_dir, url, batch_size=100):
from glob import glob

def upload_data(name, index_type, db_prefix):
last_sync_failed = False
try:
index = DefinedIndex(
f"{name}_{index_type}",
Expand All @@ -48,17 +51,24 @@ def upload_data(name, index_type, db_prefix):

if batch:
try:
resp = requests.post(f"{url}/{index_type}", json=batch).json()
resp = requests.post(
f"{url}/{index_type}", json=batch, timeout=5
).json()
if not resp["success"] == True:
1 / 0

index.delete(keys)
backoff_time = 1
last_sync_failed = False
except:
if len(keys) >= 50000:
index.delete(keys[:50000])
keys = keys[50000:]

if not last_sync_failed:
print(f"Failed to sync {name} logs to {url}")
last_sync_failed = True

backoff_time = min(backoff_time * 2, 60)
time.sleep(backoff_time)
else:
Expand Down

0 comments on commit 86f1fbc

Please sign in to comment.