Skip to content

Commit 7405151

Browse files
fix(pre_commit): 🎨 auto format pre-commit hooks
1 parent 25b3a2f commit 7405151

File tree

1 file changed

+20
-10
lines changed

1 file changed

+20
-10
lines changed

roboflow/deployment.py

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,24 @@
55
from roboflow.adapters import deploymentapi
66
from roboflow.config import load_roboflow_api_key
77

8+
89
def is_valid_ISO8601_timestamp(ts):
910
try:
1011
datetime.fromisoformat(ts)
1112
return True
1213
except:
1314
return False
1415

16+
1517
def check_from_to_timestamp(from_timestamp, to_timestamp, default_timedelta):
1618
if from_timestamp and not is_valid_ISO8601_timestamp(from_timestamp):
1719
print("Please provide a valid from_timestamp in ISO8601 format")
1820
exit(1)
19-
21+
2022
if to_timestamp and not is_valid_ISO8601_timestamp(to_timestamp):
2123
print("Please provide a valid to_timestamp in ISO8601 format")
2224
exit(1)
23-
25+
2426
time_now = datetime.now().replace(tzinfo=None)
2527
if from_timestamp is None and to_timestamp is None:
2628
from_timestamp = time_now - default_timedelta
@@ -37,7 +39,7 @@ def check_from_to_timestamp(from_timestamp, to_timestamp, default_timedelta):
3739
if from_timestamp >= to_timestamp:
3840
print("from_timestamp should be earlier than to_timestamp")
3941
exit(1)
40-
42+
4143
return from_timestamp, to_timestamp
4244

4345

@@ -109,14 +111,22 @@ def add_deployment_parser(subparsers):
109111

110112
deployment_usage_workspace_parser.set_defaults(func=get_workspace_usage)
111113
deployment_usage_workspace_parser.add_argument("-a", "--api_key", help="api key")
112-
deployment_usage_workspace_parser.add_argument("-f", "--from_timestamp", help="begin time stamp in ISO8601 format (YYYY-MM-DD HH:MM:SS)", default=None)
113-
deployment_usage_workspace_parser.add_argument("-t", "--to_timestamp", help="end time stamp in ISO8601 format (YYYY-MM-DD HH:MM:SS)", default=None)
114-
114+
deployment_usage_workspace_parser.add_argument(
115+
"-f", "--from_timestamp", help="begin time stamp in ISO8601 format (YYYY-MM-DD HH:MM:SS)", default=None
116+
)
117+
deployment_usage_workspace_parser.add_argument(
118+
"-t", "--to_timestamp", help="end time stamp in ISO8601 format (YYYY-MM-DD HH:MM:SS)", default=None
119+
)
120+
115121
deployment_usage_deployment_parser.set_defaults(func=get_deployment_usage)
116122
deployment_usage_deployment_parser.add_argument("-a", "--api_key", help="api key")
117123
deployment_usage_deployment_parser.add_argument("deployment_name", help="deployment name")
118-
deployment_usage_deployment_parser.add_argument("-f", "--from_timestamp", help="begin time stamp in ISO8601 format (YYYY-MM-DD HH:MM:SS)", default=None)
119-
deployment_usage_deployment_parser.add_argument("-t", "--to_timestamp", help="end time stamp in ISO8601 format (YYYY-MM-DD HH:MM:SS)", default=None)
124+
deployment_usage_deployment_parser.add_argument(
125+
"-f", "--from_timestamp", help="begin time stamp in ISO8601 format (YYYY-MM-DD HH:MM:SS)", default=None
126+
)
127+
deployment_usage_deployment_parser.add_argument(
128+
"-t", "--to_timestamp", help="end time stamp in ISO8601 format (YYYY-MM-DD HH:MM:SS)", default=None
129+
)
120130

121131
deployment_delete_parser.set_defaults(func=delete_deployment)
122132
deployment_delete_parser.add_argument("-a", "--api_key", help="api key")
@@ -208,7 +218,7 @@ def get_workspace_usage(args):
208218
if api_key is None:
209219
print("Please provide an api key")
210220
exit(1)
211-
221+
212222
from_timestamp, to_timestamp = check_from_to_timestamp(args.from_timestamp, args.to_timestamp, timedelta(days=1))
213223
status_code, msg = deploymentapi.get_workspace_usage(api_key, from_timestamp, to_timestamp)
214224
if status_code != 200:
@@ -222,7 +232,7 @@ def get_deployment_usage(args):
222232
if api_key is None:
223233
print("Please provide an api key")
224234
exit(1)
225-
235+
226236
from_timestamp, to_timestamp = check_from_to_timestamp(args.from_timestamp, args.to_timestamp, timedelta(days=1))
227237
status_code, msg = deploymentapi.get_deployment_usage(api_key, args.deployment_name, from_timestamp, to_timestamp)
228238
if status_code != 200:

0 commit comments

Comments
 (0)