Skip to content

Commit 81f155d

Browse files
committed
use local timezone
1 parent ccfad86 commit 81f155d

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

roboflow/adapters/deploymentapi.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import requests
2-
2+
import urllib
33
from roboflow.config import DEDICATED_DEPLOYMENT_URL
44

55

@@ -58,13 +58,14 @@ def list_machine_types(api_key):
5858

5959

6060
def get_deployment_log(api_key, deployment_name, from_timestamp=None, to_timestamp=None, max_entries=-1):
61-
url = f"{DEDICATED_DEPLOYMENT_URL}/get_log?api_key={api_key}&deployment_name={deployment_name}"
61+
params = {'api_key': api_key, 'deployment_name': deployment_name}
6262
if from_timestamp is not None:
63-
url += f"&from_timestamp={from_timestamp.isoformat()}"
63+
params['from_timestamp'] = from_timestamp.isoformat() # may contain + sign
6464
if to_timestamp is not None:
65-
url += f"&to_timestamp={to_timestamp.isoformat()}"
65+
params['to_timestamp'] = to_timestamp.isoformat() # may contain + sign
6666
if max_entries > 0:
67-
url += f"&max_entries={max_entries}"
67+
params['max_entries'] = max_entries
68+
url = f"{DEDICATED_DEPLOYMENT_URL}/get_log?{urllib.parse.urlencode(params)}"
6869
response = requests.get(url)
6970
if response.status_code != 200:
7071
return response.status_code, response.text

roboflow/deployment.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ def get_deployment_log(args):
169169
print("Please provide an api key")
170170
exit(1)
171171

172-
to_timestamp = datetime.now()
172+
to_timestamp = datetime.now().astimezone() # local timezone
173173
from_timestamp = to_timestamp - timedelta(seconds=args.duration)
174174
last_log_timestamp = from_timestamp
175175
log_ids = set() # to avoid duplicate logs
@@ -183,7 +183,7 @@ def get_deployment_log(args):
183183
exit(status_code)
184184

185185
for log in msg[::-1]: # logs are sorted by reversed timestamp
186-
log_timestamp = datetime.fromisoformat(log["timestamp"]).replace(tzinfo=None)
186+
log_timestamp = datetime.fromisoformat(log["timestamp"]).astimezone() # local timezone
187187
if (log["insert_id"] in log_ids) or (log_timestamp < last_log_timestamp):
188188
continue
189189
log_ids.add(log["insert_id"])
@@ -195,5 +195,5 @@ def get_deployment_log(args):
195195

196196
time.sleep(10)
197197
from_timestamp = last_log_timestamp
198-
to_timestamp = datetime.now()
198+
to_timestamp = datetime.now().astimezone() # local timezone
199199
max_entries = 300 # only set max_entries for the first request

0 commit comments

Comments
 (0)