1
+ from __future__ import annotations
1
2
import warnings
2
3
from collections .abc import Iterable
3
4
from pathlib import Path
@@ -102,15 +103,15 @@ def search_items(
102
103
103
104
def create_item (
104
105
self ,
105
- item_id : str ,
106
- item_type : str ,
107
- item_data : Optional [ dict [str , Any ]] = None ,
108
- collection_id : Optional [ str ] = None ,
106
+ item_id : str | None = None ,
107
+ item_type : str = "samples" ,
108
+ item_data : dict [str , Any ] | None = None ,
109
+ collection_id : str | None = None ,
109
110
) -> dict [str , Any ]:
110
111
"""Create an item with a given ID and item data.
111
112
112
113
Parameters:
113
- item_id: The ID of the item to create.
114
+ item_id: The ID of the item to create, if set to `None`, the server will generate one .
114
115
item_type: The type of item to create, e.g., 'samples', 'cells'.
115
116
item_data: The data for the item.
116
117
collection_id: The ID of the collection to add the item to (optional).
@@ -133,7 +134,7 @@ def create_item(
133
134
create_item_url = f"{ self .datalab_api_url } /new-sample/"
134
135
create_item_resp = self .session .post (
135
136
create_item_url ,
136
- json = new_item ,
137
+ json = { "new_sample_data" : new_item , "generate_id_automatically" : item_id is None } ,
137
138
follow_redirects = True ,
138
139
)
139
140
try :
0 commit comments