Imports
imports
Service class for handling data imports into Kaleidoscope workspace.
This module provides the ImportsService class, which facilitates pushing data records
into the Kaleidoscope system. It supports flexible data import operations, allowing
organization by experiments, programs, and data sources.
Classes:
| Name | Description |
|---|---|
ImportsService |
Service for handling data imports into the Kaleidoscope workspace, providing methods to push records organized by source, experiment, program, record views, and set names. |
Example
key_fields = ["id", "timestamp"]
records = [
{"id": "001", "timestamp": "2024-01-01", "value": 42.5, "status": "active"},
{"id": "002", "timestamp": "2024-01-02", "value": 38.7, "status": "pending"}
]
# Push data to a specific source and experiment
import_id = client.imports.push_data(
key_field_names=key_fields,
data=records,
source_id="data_source_123",
operation_id="exp_456",
set_name="january_batch"
)
ImportResult
ImportRecord
ImportsService
ImportsService(client: KaleidoscopeClient)
Service class for handling data imports into Kaleidoscope workspace.
This service provides functionality to push data records into the workspace, with support for organizing data by sources, experiments, programs, and record views.
Methods:
| Name | Description |
|---|---|
push_data |
Import data into the workspace using field names. |
push_data_by_field_id |
Import data into the workspace using field UUIDs instead of field names. |
get_imports |
Retrieve imports in the workspace. |
get_import |
Retrieve a specific import by ID. |
Source code in kalbio/imports.py
69 70 | |
push_data
push_data(key_field_names: list[str], data: list[dict[str, Any]], source_id: str | None = None, operation_id: str | None = None, program_id: str | None = None, record_view_id: str | None = None, add_fields_to_record_view_ids: list[str] | None = None, set_name: str | None = None, record_view_ids: list[str] | None = None) -> str | None
Import data into the workspace using field names.
Sends a list of records, each represented as a dictionary of field names and values, to the Kaleidoscope workspace.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key_field_names
|
list[str]
|
List of field names that serve as keys for the records. |
required |
data
|
list[dict[str, Any]]
|
List of records to import, each as a dictionary mapping field names to values. |
required |
source_id
|
str
|
Identifier for the data source. If provided, data is imported under this source. |
None
|
operation_id
|
str
|
Identifier for the operation/experiment. If provided, data is imported into this specific operation. |
None
|
program_id
|
str
|
Identifier for the program. If provided, data is imported under this program. |
None
|
record_view_id
|
str
|
UUID of the record view on the operation
to import the data into. Use |
None
|
add_fields_to_record_view_ids
|
list[str]
|
UUIDs of additional
record views that any newly-created fields from this import should be
added to. Distinct from |
None
|
set_name
|
str
|
Name of the set to which the imported data belongs. |
None
|
record_view_ids
|
list[str]
|
Deprecated. The server only accepts
a singular |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
str |
str | None
|
The import ID for the created import, or None if the request failed. |
Example
# Import into a specific record view on an operation
activity = client.activities.get_activity_by_id("op_uuid")
view = activity.record_views[0]
client.imports.push_data(
key_field_names=["id"],
data=[{"id": "S-001", "yield": 42.5}],
operation_id=activity.id,
record_view_id=view.id,
)
Source code in kalbio/imports.py
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 | |
push_data_by_field_id
push_data_by_field_id(key_field_ids: list[str], data: list[dict[str, Any]], operation_id: str | None = None, program_id: str | None = None, record_view_ids: list[str] | None = None, set_name: str | None = None) -> str | None
Import data into the workspace using field UUIDs instead of field names.
Sends a list of records where keys are field UUIDs rather than field names.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key_field_ids
|
list[str]
|
List of field UUIDs that serve as keys for the records. |
required |
data
|
list[dict[str, Any]]
|
List of records to import, each as a dictionary mapping field UUIDs to values. |
required |
operation_id
|
str
|
Identifier for the experiment. |
None
|
program_id
|
str
|
Identifier for the program. |
None
|
record_view_ids
|
list[str]
|
List of record view IDs to associate with the imported data. |
None
|
set_name
|
str
|
Name of the set to which the imported data belongs. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
str |
str | None
|
The import ID for the created import, or None if the request failed. |
Source code in kalbio/imports.py
161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 | |
get_imports
get_imports(is_complete: bool | None = None, page: int | None = None, page_size: int | None = None) -> list[ImportRecord]
Retrieve imports in the workspace.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
is_complete
|
bool
|
Filter by completion status. |
None
|
page
|
int
|
Page number for pagination. |
None
|
page_size
|
int
|
Number of items per page. |
None
|
Returns:
| Type | Description |
|---|---|
list[ImportRecord]
|
List[ImportRecord]: A list of import records. |
Source code in kalbio/imports.py
206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 | |
get_import
get_import(import_id: str) -> ImportRecord | None
Retrieve a specific import by ID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
import_id
|
str
|
The UUID of the import to retrieve. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
ImportRecord |
ImportRecord | None
|
The import record, or None if not found. |
Source code in kalbio/imports.py
235 236 237 238 239 240 241 242 243 244 245 246 247 | |