Skip to content

Commit bc9a5b7

Browse files
ignacioalvarolopez
authored andcommitted
fix pep8
1 parent 4ed2580 commit bc9a5b7

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

deepaas/api/v2/train.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# under the License.
1616

1717
import asyncio
18-
import datetime
18+
from datetime import datetime
1919
import uuid
2020

2121
from aiohttp import web
@@ -64,10 +64,11 @@ def build_train_response(uuid, training):
6464
else:
6565
ret["status"] = "done"
6666
ret["result"] = training["task"].result()
67-
ret["result"]["duration"] = str(datetime.datetime.strptime(ret["result"]["finish_date"],
68-
'%Y-%m-%d %H:%M:%S.%f')
69-
- datetime.datetime.strptime(ret["date"],
70-
'%Y-%m-%d %H:%M:%S.%f'))
67+
end = datetime.strptime(ret["result"]["finish_date"],
68+
'%Y-%m-%d %H:%M:%S.%f')
69+
start = datetime.strptime(ret["date"],
70+
'%Y-%m-%d %H:%M:%S.%f')
71+
ret["result"]["duration"] = str(end - start)
7172
else:
7273
ret["status"] = "running"
7374
return ret
@@ -82,7 +83,7 @@ async def post(self, request, args, wsk_args=None):
8283
uuid_ = uuid.uuid4().hex
8384
train_task = self.model_obj.train(**args)
8485
self._trainings[uuid_] = {
85-
"date": str(datetime.datetime.now()),
86+
"date": str(datetime.now()),
8687
"task": train_task,
8788
"args": args,
8889
}

0 commit comments

Comments
 (0)