Skip to content

Commit d45766c

Browse files
committed
Enhanced get_object, get_object_shapes
1 parent 0d528bf commit d45766c

4 files changed

Lines changed: 28 additions & 73 deletions

File tree

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
# DataLab Simple Client Releases #
22

3+
## Version 0.3.0 ##
4+
5+
Changes:
6+
7+
* Remote API:
8+
* `get_object` method now takes either object number, UUID or a title
9+
* `get_object_shapes` method now takes either object number, UUID or a title
10+
* Removed deprecated `get_object_from_uuid` and `get_object_from_title` methods
11+
312
## Version 0.2.0 ##
413

514
Changes:

cdlclient/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
from cdlclient.baseproxy import SimpleBaseProxy
1717
from cdlclient.remote import SimpleRemoteProxy
1818

19-
__version__ = "0.2.0"
19+
__version__ = "0.3.0"
2020
__docurl__ = "https://cdlclient.readthedocs.io/en/latest/"
2121
__homeurl__ = "https://github.com/Codra-Ingenierie-Informatique/DataLabSimpleClient/"
2222
__supporturl__ = "https://github.com/Codra-Ingenierie-Informatique/DataLabSimpleClient/issues/new/choose"

cdlclient/baseproxy.py

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -255,20 +255,15 @@ def get_object_uuids(self, panel: str | None = None) -> list[str]:
255255
@abc.abstractmethod
256256
def get_object_shapes(
257257
self,
258-
index: int | None = None,
259-
group_index: int | None = None,
258+
nb_id_title: int | str | None = None,
260259
panel: str | None = None,
261260
) -> list:
262261
"""Get plot item shapes associated to object (signal/image).
263262
264263
Args:
265-
index: Object index in current panel. Defaults to None.
266-
group_index: Group index. Defaults to None.
267-
panel: Panel name. Defaults to None.
268-
269-
If ``index`` is not specified, returns the currently selected object.
270-
If ``group_index`` is not specified, return an object from the current group.
271-
If ``panel`` is not specified, return an object from the current panel.
264+
nb_id_title: Object number, or object id, or object title.
265+
Defaults to None (current object).
266+
panel: Panel name. Defaults to None (current panel).
272267
273268
Returns:
274269
List of plot item shapes

cdlclient/remote.py

Lines changed: 14 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -217,9 +217,9 @@ class SimpleRemoteProxy(SimpleBaseProxy):
217217
['toto']
218218
>>> proxy.get_object_from_title("toto")
219219
<cdlclient.model.signal.SignalObj at 0x7f7f1c0b4a90>
220-
>>> proxy.get_object(0)
220+
>>> proxy.get_object(1)
221221
<cdlclient.model.signal.SignalObj at 0x7f7f1c0b4a90>
222-
>>> proxy.get_object(0).data
222+
>>> proxy.get_object(1).data
223223
array([1., 2., 3.])
224224
"""
225225

@@ -382,92 +382,43 @@ def calc(self, name: str, param: gds.DataSet | None = None) -> gds.DataSet:
382382
return self._cdl.calc(name)
383383
return self._cdl.calc(name, dataset_to_json(param))
384384

385-
def get_object_from_title(
386-
self, title: str, panel: str | None = None
387-
) -> SignalObj | ImageObj:
388-
"""Get object (signal/image) from title
389-
390-
Args:
391-
title (str): object
392-
panel (str | None): panel name (valid values: "signal", "image").
393-
If None, current panel is used.
394-
395-
Returns:
396-
Union[SignalObj, ImageObj]: object
397-
398-
Raises:
399-
ValueError: if object not found
400-
ValueError: if panel not found
401-
"""
402-
param_data = self._cdl.get_object_from_title(title, panel)
403-
return json_to_dataset(param_data)
404-
405385
def get_object(
406386
self,
407-
index: int | None = None,
408-
group_index: int | None = None,
387+
nb_id_title: int | str | None = None,
409388
panel: str | None = None,
410389
) -> SignalObj | ImageObj:
411390
"""Get object (signal/image) from index.
412391
413392
Args:
414-
index (int): Object index in current panel. Defaults to None.
415-
group_index (int | None): Group index. Defaults to None.
416-
panel (str | None): Panel name. Defaults to None.
417-
418-
If ``index`` is not specified, returns the currently selected object.
419-
If ``group_index`` is not specified, return an object from the current group.
420-
If ``panel`` is not specified, return an object from the current panel.
393+
nb_id_title: Object number, or object id, or object title.
394+
Defaults to None (current object).
395+
panel: Panel name. Defaults to None (current panel).
421396
422397
Returns:
423-
Union[SignalObj, ImageObj]: object
398+
Object
424399
425400
Raises:
426-
IndexError: if object not found
401+
KeyError: if object not found
427402
"""
428-
param_data = self._cdl.get_object(index, group_index, panel)
429-
return json_to_dataset(param_data)
430-
431-
def get_object_from_uuid(
432-
self, oid: str, panel: str | None = None
433-
) -> SignalObj | ImageObj:
434-
"""Get object (signal/image) from uuid
435-
436-
Args:
437-
oid (str): object uuid
438-
panel (str | None): panel name (valid values: "signal", "image").
439-
440-
Returns:
441-
Union[SignalObj, ImageObj]: object
442-
443-
Raises:
444-
ValueError: if object not found
445-
ValueError: if panel not found
446-
"""
447-
param_data = self._cdl.get_object_from_uuid(oid, panel)
403+
param_data = self._cdl.get_object(nb_id_title, panel)
448404
return json_to_dataset(param_data)
449405

450406
def get_object_shapes(
451407
self,
452-
index: int | None = None,
453-
group_index: int | None = None,
408+
nb_id_title: int | str | None = None,
454409
panel: str | None = None,
455410
) -> list:
456411
"""Get plot item shapes associated to object (signal/image).
457412
458413
Args:
459-
index: Object index in current panel. Defaults to None.
460-
group_index: Group index. Defaults to None.
461-
panel: Panel name. Defaults to None.
462-
463-
If ``index`` is not specified, returns the currently selected object.
464-
If ``group_index`` is not specified, return an object from the current group.
465-
If ``panel`` is not specified, return an object from the current panel.
414+
nb_id_title: Object number, or object id, or object title.
415+
Defaults to None (current object).
416+
panel: Panel name. Defaults to None (current panel).
466417
467418
Returns:
468419
List of plot item shapes
469420
"""
470-
items_json = self._cdl.get_object_shapes(index, group_index, panel)
421+
items_json = self._cdl.get_object_shapes(nb_id_title, panel)
471422
return json_to_items(items_json)
472423

473424
def add_annotations_from_items(

0 commit comments

Comments
 (0)