Skip to content

Commit 54a1eb5

Browse files
author
Agathe Guillemot
committed
Use properties for id
Add utils#CallableStr for backward compatibility
1 parent a4e34e4 commit 54a1eb5

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

dataikuapi/dss/apideployer.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import json
22
from .future import DSSFuture
3-
3+
from ..utils import CallableStr
44

55
class DSSAPIDeployer(object):
66
"""
@@ -160,8 +160,9 @@ def __init__(self, client, infra_id):
160160
self.client = client
161161
self.infra_id = infra_id
162162

163+
@property
163164
def id(self):
164-
return self.infra_id
165+
return CallableStr(self.infra_id)
165166

166167
def get_status(self):
167168
"""
@@ -292,8 +293,9 @@ def __init__(self, client, deployment_id):
292293
self.client = client
293294
self.deployment_id = deployment_id
294295

296+
@property
295297
def id(self):
296-
return self.deployment_id
298+
return CallableStr(self.deployment_id)
297299

298300
def get_status(self):
299301
"""
@@ -462,8 +464,9 @@ def __init__(self, client, service_id):
462464
self.client = client
463465
self.service_id = service_id
464466

467+
@property
465468
def id(self):
466-
return self.service_id
469+
return CallableStr(self.service_id)
467470

468471
def get_status(self):
469472
"""

dataikuapi/utils.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,3 +94,10 @@ def str_to_bool(s):
9494
doublequote=True):
9595
yield [none_if_throws(caster)(val)
9696
for (caster, val) in dku_zip_longest(casters, uncasted_tuple)]
97+
98+
class CallableStr(str):
99+
def __init__(self, val):
100+
self.val = val
101+
102+
def __call__(self):
103+
return self.val

0 commit comments

Comments
 (0)