File tree 6 files changed +83
-38
lines changed
6 files changed +83
-38
lines changed Original file line number Diff line number Diff line change @@ -92,23 +92,6 @@ def _modify(
92
92
"""
93
93
pass
94
94
95
- @abstractmethod
96
- def _fork (
97
- self ,
98
- collection_id : UUID ,
99
- new_name : str
100
- ) -> CollectionModel :
101
- """[Internal] Fork the current collection under a new name. The returning collection should contain identical data to the current collection.
102
- This is an experimental API that only works for Hosted Chroma for now.
103
-
104
- Args:
105
- new_name: The name of the new collection.
106
-
107
- Returns:
108
- Collection: A new collection with the specified name and containing identical data to the current collection.
109
- """
110
- pass
111
-
112
95
@abstractmethod
113
96
def delete_collection (
114
97
self ,
@@ -478,6 +461,24 @@ def get_or_create_collection(
478
461
"""
479
462
pass
480
463
464
+ @abstractmethod
465
+ def _fork (
466
+ self ,
467
+ collection_id : UUID ,
468
+ new_name : str
469
+ ) -> Collection :
470
+ """[Internal] Fork the current collection under a new name. The returning collection should contain identical data to the current collection.
471
+ This is an experimental API that only works for Hosted Chroma for now.
472
+
473
+ Args:
474
+ new_name: The name of the new collection.
475
+
476
+ Returns:
477
+ Collection: A new collection with the specified name and containing identical data to the current collection.
478
+ """
479
+ pass
480
+
481
+
481
482
@abstractmethod
482
483
def set_tenant (self , tenant : str , database : str = DEFAULT_DATABASE ) -> None :
483
484
"""Set the tenant and database for the client. Raises an error if the tenant or
@@ -654,7 +655,6 @@ def _modify(
654
655
pass
655
656
656
657
@abstractmethod
657
- @override
658
658
def _fork (
659
659
self ,
660
660
collection_id : UUID ,
Original file line number Diff line number Diff line change @@ -86,23 +86,6 @@ async def _modify(
86
86
"""
87
87
pass
88
88
89
- @abstractmethod
90
- async def _fork (
91
- self ,
92
- collection_id : UUID ,
93
- new_name : str
94
- ) -> CollectionModel :
95
- """[Internal] Fork the current collection under a new name. The returning collection should contain identical data to the current collection.
96
- This is an experimental API that only works for Hosted Chroma for now.
97
-
98
- Args:
99
- new_name: The name of the new collection.
100
-
101
- Returns:
102
- Collection: A new collection with the specified name and containing identical data to the current collection.
103
- """
104
- pass
105
-
106
89
@abstractmethod
107
90
async def delete_collection (
108
91
self ,
@@ -472,6 +455,27 @@ async def get_or_create_collection(
472
455
"""
473
456
pass
474
457
458
+ @abstractmethod
459
+ async def _fork (
460
+ self ,
461
+ collection_id : UUID ,
462
+ new_name : str ,
463
+ embedding_function : Optional [
464
+ EmbeddingFunction [Embeddable ]
465
+ ] = ef .DefaultEmbeddingFunction (), # type: ignore
466
+ data_loader : Optional [DataLoader [Loadable ]] = None ,
467
+ ) -> AsyncCollection :
468
+ """[Internal] Fork the current collection under a new name. The returning collection should contain identical data to the current collection.
469
+ This is an experimental API that only works for Hosted Chroma for now.
470
+
471
+ Args:
472
+ new_name: The name of the new collection.
473
+
474
+ Returns:
475
+ Collection: A new collection with the specified name and containing identical data to the current collection.
476
+ """
477
+ pass
478
+
475
479
@abstractmethod
476
480
async def set_tenant (self , tenant : str , database : str = DEFAULT_DATABASE ) -> None :
477
481
"""Set the tenant and database for the client. Raises an error if the tenant or
@@ -648,7 +652,6 @@ async def _modify(
648
652
pass
649
653
650
654
@abstractmethod
651
- @override
652
655
async def _fork (
653
656
self ,
654
657
collection_id : UUID ,
Original file line number Diff line number Diff line change @@ -268,6 +268,27 @@ async def _modify(
268
268
database = self .database ,
269
269
)
270
270
271
+ @override
272
+ async def _fork (
273
+ self ,
274
+ collection_id : UUID ,
275
+ new_name : str ,
276
+ embedding_function : Optional [
277
+ EmbeddingFunction [Embeddable ]
278
+ ] = ef .DefaultEmbeddingFunction (), # type: ignore
279
+ data_loader : Optional [DataLoader [Loadable ]] = None ,
280
+ ) -> AsyncCollection :
281
+ model = await self ._server ._fork (
282
+ collection_id = collection_id ,
283
+ new_name = new_name ,
284
+ )
285
+ return AsyncCollection (
286
+ client = self ._server ,
287
+ model = model ,
288
+ embedding_function = embedding_function ,
289
+ data_loader = data_loader ,
290
+ )
291
+
271
292
@override
272
293
async def delete_collection (
273
294
self ,
Original file line number Diff line number Diff line change @@ -410,7 +410,7 @@ async def _fork(
410
410
) -> CollectionModel :
411
411
resp_json = await self ._make_request (
412
412
"post" ,
413
- f"/tenants/{ tenant } /databases/{ database } /collections/{ id } /fork" ,
413
+ f"/tenants/{ tenant } /databases/{ database } /collections/{ collection_id } /fork" ,
414
414
json = {"new_name" : new_name },
415
415
)
416
416
model = CollectionModel .from_json (resp_json )
Original file line number Diff line number Diff line change @@ -235,6 +235,27 @@ def _modify(
235
235
new_configuration = new_configuration ,
236
236
)
237
237
238
+ @override
239
+ def _fork (
240
+ self ,
241
+ collection_id : UUID ,
242
+ new_name : str ,
243
+ embedding_function : Optional [
244
+ EmbeddingFunction [Embeddable ]
245
+ ] = ef .DefaultEmbeddingFunction (), # type: ignore
246
+ data_loader : Optional [DataLoader [Loadable ]] = None ,
247
+ ) -> Collection :
248
+ model = self ._server ._fork (
249
+ collection_id = collection_id ,
250
+ new_name = new_name ,
251
+ )
252
+ return Collection (
253
+ client = self ._server ,
254
+ model = model ,
255
+ embedding_function = embedding_function ,
256
+ data_loader = data_loader ,
257
+ )
258
+
238
259
@override
239
260
def delete_collection (
240
261
self ,
Original file line number Diff line number Diff line change @@ -363,7 +363,7 @@ def _fork(
363
363
"""Forks a collection"""
364
364
resp_json = self ._make_request (
365
365
"post" ,
366
- f"/tenants/{ tenant } /databases/{ database } /collections/{ id } /fork" ,
366
+ f"/tenants/{ tenant } /databases/{ database } /collections/{ collection_id } /fork" ,
367
367
json = {"new_name" : new_name },
368
368
)
369
369
model = CollectionModel .from_json (resp_json )
You can’t perform that action at this time.
0 commit comments