kalbio 0.2.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- kalbio/__init__.py +1 -0
- kalbio/_kaleidoscope_model.py +111 -0
- kalbio/activities.py +1202 -0
- kalbio/client.py +463 -0
- kalbio/dashboards.py +276 -0
- kalbio/entity_fields.py +474 -0
- kalbio/entity_types.py +188 -0
- kalbio/exports.py +126 -0
- kalbio/helpers.py +52 -0
- kalbio/imports.py +89 -0
- kalbio/labels.py +88 -0
- kalbio/programs.py +96 -0
- kalbio/property_fields.py +81 -0
- kalbio/record_views.py +191 -0
- kalbio/records.py +1173 -0
- kalbio/workspace.py +315 -0
- kalbio-0.2.0.dist-info/METADATA +289 -0
- kalbio-0.2.0.dist-info/RECORD +19 -0
- kalbio-0.2.0.dist-info/WHEEL +4 -0
kalbio/__init__.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.2.0"
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Kaleidoscope Base Model Module.
|
|
3
|
+
|
|
4
|
+
Internal class.
|
|
5
|
+
|
|
6
|
+
This module defines the base model class for all Kaleidoscope objects, providing
|
|
7
|
+
common functionality for serialization, comparison, and client management.
|
|
8
|
+
|
|
9
|
+
The `_KaleidoscopeBaseModel` class extends Pydantic's BaseModel to provide:
|
|
10
|
+
- Unique identification via id attribute
|
|
11
|
+
- Client instance management for API interactions
|
|
12
|
+
- Standard serialization methods (JSON, dictionary)
|
|
13
|
+
- Comparison and hashing based on id
|
|
14
|
+
- String representation methods
|
|
15
|
+
|
|
16
|
+
Classes:
|
|
17
|
+
_KaleidoscopeBaseModel: Base class for all Kaleidoscope model objects.
|
|
18
|
+
"""
|
|
19
|
+
|
|
20
|
+
from pydantic import BaseModel
|
|
21
|
+
from kalbio.client import KaleidoscopeClient
|
|
22
|
+
import json
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class _KaleidoscopeBaseModel(BaseModel):
|
|
26
|
+
"""
|
|
27
|
+
Base model class for Kaleidoscope objects.
|
|
28
|
+
This class provides common functionality for all Kaleidoscope model objects,
|
|
29
|
+
including serialization, comparison, and client management.
|
|
30
|
+
Attributes:
|
|
31
|
+
id (str): Unique identifier for the model instance.
|
|
32
|
+
_client (KaleidoscopeClient): Internal reference to the Kaleidoscope client instance.
|
|
33
|
+
Methods:
|
|
34
|
+
__eq__(other): Compare two model instances based on their type and id.
|
|
35
|
+
__hash__(): Return hash value based on the id attribute.
|
|
36
|
+
__str__(): Return string representation of the model instance.
|
|
37
|
+
__repr__(): Return string representation of the model instance.
|
|
38
|
+
to_json(): Serialize the model instance to a JSON string.
|
|
39
|
+
to_dict(): Convert the model instance to a dictionary containing the id.
|
|
40
|
+
_set_client(client): Set the KaleidoscopeClient instance for this object.
|
|
41
|
+
"""
|
|
42
|
+
|
|
43
|
+
id: str
|
|
44
|
+
_client: KaleidoscopeClient
|
|
45
|
+
|
|
46
|
+
def __eq__(self, other):
|
|
47
|
+
return isinstance(other, self.__class__) and self.id == other.id
|
|
48
|
+
|
|
49
|
+
def __hash__(self):
|
|
50
|
+
return hash(self.id)
|
|
51
|
+
|
|
52
|
+
def __str__(self):
|
|
53
|
+
return f"{type(self).__name__}:'{self.id[:8]}...'"
|
|
54
|
+
|
|
55
|
+
def __repr__(self):
|
|
56
|
+
return f"{self.__class__}({self.model_dump()})"
|
|
57
|
+
|
|
58
|
+
def to_json(self) -> str:
|
|
59
|
+
"""
|
|
60
|
+
Serializes the model to a JSON-formatted string.
|
|
61
|
+
Returns:
|
|
62
|
+
str: A JSON string representation of the model, with indentation for readability.
|
|
63
|
+
Notes:
|
|
64
|
+
- This method is a thin convenience wrapper. To customize serialization options,
|
|
65
|
+
call json.dumps(...) directly on a `dict` of the model.
|
|
66
|
+
- One way a `dict` may be optained throught the `to_dict()` method
|
|
67
|
+
"""
|
|
68
|
+
|
|
69
|
+
return json.dumps(self.model_dump(), indent=4, sort_keys=False, default=str)
|
|
70
|
+
|
|
71
|
+
def to_dict(self) -> dict:
|
|
72
|
+
"""
|
|
73
|
+
Return a dictionary representation of the model by delegating to self.model_dump().
|
|
74
|
+
Returns:
|
|
75
|
+
dict: A mapping of field names to their serialized values. The exact structure and
|
|
76
|
+
serialization behavior (e.g., handling of nested models, inclusion of defaults,
|
|
77
|
+
or custom encoders) follow the semantics of the underlying model_dump implementation.
|
|
78
|
+
Notes:
|
|
79
|
+
- This method is a thin convenience wrapper. To customize serialization options,
|
|
80
|
+
call model_dump(...) directly with the desired parameters.
|
|
81
|
+
"""
|
|
82
|
+
|
|
83
|
+
return self.model_dump()
|
|
84
|
+
|
|
85
|
+
def _set_client(self, client: KaleidoscopeClient) -> None:
|
|
86
|
+
"""
|
|
87
|
+
Set the `KaleidoscopeClient` instance for this object.
|
|
88
|
+
Also recursively sets client on all _KaleidoscopeBaseModel attributes
|
|
89
|
+
"""
|
|
90
|
+
self._client = client
|
|
91
|
+
|
|
92
|
+
# Iterate through field names and get actual values from the instance
|
|
93
|
+
for field_name in self.__class__.model_fields.keys():
|
|
94
|
+
value = getattr(self, field_name, None)
|
|
95
|
+
if value is None:
|
|
96
|
+
continue
|
|
97
|
+
|
|
98
|
+
if isinstance(value, _KaleidoscopeBaseModel):
|
|
99
|
+
value._set_client(client)
|
|
100
|
+
elif isinstance(value, list):
|
|
101
|
+
for item in value:
|
|
102
|
+
if isinstance(item, _KaleidoscopeBaseModel):
|
|
103
|
+
item._set_client(client)
|
|
104
|
+
elif isinstance(value, dict):
|
|
105
|
+
for item in value.values():
|
|
106
|
+
if isinstance(item, _KaleidoscopeBaseModel):
|
|
107
|
+
item._set_client(client)
|
|
108
|
+
elif isinstance(item, list):
|
|
109
|
+
for nested_item in item:
|
|
110
|
+
if isinstance(nested_item, _KaleidoscopeBaseModel):
|
|
111
|
+
nested_item._set_client(client)
|