|
6 | 6 | from pymilvus.client.embedding_list import EmbeddingList |
7 | 7 | from pymilvus.client.search_iterator import SearchIteratorV2 |
8 | 8 | from pymilvus.client.types import ( |
| 9 | + CompactionPlans, |
9 | 10 | ExceptionsMessage, |
| 11 | + LoadedSegmentInfo, |
10 | 12 | LoadState, |
11 | 13 | OmitZeroDict, |
12 | 14 | ReplicaInfo, |
13 | 15 | ResourceGroupConfig, |
| 16 | + SegmentInfo, |
14 | 17 | ) |
15 | 18 | from pymilvus.client.utils import convert_struct_fields_to_user_format, get_params, is_vector_type |
16 | 19 | from pymilvus.exceptions import ( |
|
21 | 24 | PrimaryKeyException, |
22 | 25 | ServerVersionIncompatibleException, |
23 | 26 | ) |
24 | | -from pymilvus.orm import utility |
25 | 27 | from pymilvus.orm.collection import CollectionSchema, FieldSchema, Function, FunctionScore |
26 | 28 | from pymilvus.orm.connections import connections |
27 | 29 | from pymilvus.orm.constants import FIELDS, METRIC_TYPE, TYPE, UNLIMITED |
@@ -67,7 +69,7 @@ def __init__( |
67 | 69 | self._using = create_connection( |
68 | 70 | uri, token, db_name, user=user, password=password, timeout=timeout, **kwargs |
69 | 71 | ) |
70 | | - self.is_self_hosted = bool(utility.get_server_type(using=self._using) == "milvus") |
| 72 | + self.is_self_hosted = bool(self.get_server_type() == "milvus") |
71 | 73 |
|
72 | 74 | def create_collection( |
73 | 75 | self, |
@@ -219,7 +221,7 @@ def insert( |
219 | 221 | # Insert into the collection. |
220 | 222 | try: |
221 | 223 | res = conn.insert_rows( |
222 | | - collection_name, data, partition_name=partition_name, timeout=timeout |
| 224 | + collection_name, data, partition_name=partition_name, timeout=timeout, **kwargs |
223 | 225 | ) |
224 | 226 | except Exception as ex: |
225 | 227 | raise ex from ex |
@@ -1808,3 +1810,117 @@ def update_replicate_configuration( |
1808 | 1810 | timeout=timeout, |
1809 | 1811 | **kwargs, |
1810 | 1812 | ) |
| 1813 | + |
| 1814 | + def flush_all(self, timeout: Optional[float] = None, **kwargs) -> None: |
| 1815 | + """Flush all collections. |
| 1816 | +
|
| 1817 | + Args: |
| 1818 | + timeout (Optional[float]): An optional duration of time in seconds to allow for the RPC. |
| 1819 | + **kwargs: Additional arguments. |
| 1820 | + """ |
| 1821 | + self._get_connection().flush_all(timeout=timeout, **kwargs) |
| 1822 | + |
| 1823 | + def get_flush_all_state(self, timeout: Optional[float] = None, **kwargs) -> bool: |
| 1824 | + """Get the flush all state. |
| 1825 | +
|
| 1826 | + Args: |
| 1827 | + timeout (Optional[float]): An optional duration of time in seconds to allow for the RPC. |
| 1828 | + **kwargs: Additional arguments. |
| 1829 | +
|
| 1830 | + Returns: |
| 1831 | + bool: True if flush all operation is completed, False otherwise. |
| 1832 | + """ |
| 1833 | + return self._get_connection().get_flush_all_state(timeout=timeout, **kwargs) |
| 1834 | + |
| 1835 | + def list_loaded_segments( |
| 1836 | + self, |
| 1837 | + collection_name: str, |
| 1838 | + timeout: Optional[float] = None, |
| 1839 | + **kwargs, |
| 1840 | + ) -> List[LoadedSegmentInfo]: |
| 1841 | + """List loaded segments for a collection. |
| 1842 | +
|
| 1843 | + Args: |
| 1844 | + collection_name (str): The name of the collection. |
| 1845 | + timeout (Optional[float]): An optional duration of time in seconds to allow for the RPC. |
| 1846 | + **kwargs: Additional arguments. |
| 1847 | +
|
| 1848 | + Returns: |
| 1849 | + List[LoadedSegmentInfo]: A list of loaded segment information. |
| 1850 | + """ |
| 1851 | + infos = self._get_connection().get_query_segment_info( |
| 1852 | + collection_name, timeout=timeout, **kwargs |
| 1853 | + ) |
| 1854 | + return [ |
| 1855 | + LoadedSegmentInfo( |
| 1856 | + info.segmentID, |
| 1857 | + info.collectionID, |
| 1858 | + collection_name, |
| 1859 | + info.num_rows, |
| 1860 | + info.is_sorted, |
| 1861 | + info.state, |
| 1862 | + info.level, |
| 1863 | + info.storage_version, |
| 1864 | + info.mem_size, |
| 1865 | + ) |
| 1866 | + for info in infos |
| 1867 | + ] |
| 1868 | + |
| 1869 | + def list_persistent_segments( |
| 1870 | + self, |
| 1871 | + collection_name: str, |
| 1872 | + timeout: Optional[float] = None, |
| 1873 | + **kwargs, |
| 1874 | + ) -> List[SegmentInfo]: |
| 1875 | + """List persistent segments for a collection. |
| 1876 | +
|
| 1877 | + Args: |
| 1878 | + collection_name (str): The name of the collection. |
| 1879 | + timeout (Optional[float]): An optional duration of time in seconds to allow for the RPC. |
| 1880 | + **kwargs: Additional arguments. |
| 1881 | +
|
| 1882 | + Returns: |
| 1883 | + List[SegmentInfo]: A list of persistent segment information. |
| 1884 | + """ |
| 1885 | + infos = self._get_connection().get_persistent_segment_infos( |
| 1886 | + collection_name, timeout=timeout, **kwargs |
| 1887 | + ) |
| 1888 | + return [ |
| 1889 | + SegmentInfo( |
| 1890 | + info.segmentID, |
| 1891 | + info.collectionID, |
| 1892 | + collection_name, |
| 1893 | + info.num_rows, |
| 1894 | + info.is_sorted, |
| 1895 | + info.state, |
| 1896 | + info.level, |
| 1897 | + info.storage_version, |
| 1898 | + ) |
| 1899 | + for info in infos |
| 1900 | + ] |
| 1901 | + |
| 1902 | + def get_server_type(self): |
| 1903 | + """Get the server type. |
| 1904 | +
|
| 1905 | + Returns: |
| 1906 | + str: The server type (e.g., "milvus", "zilliz"). |
| 1907 | + """ |
| 1908 | + return self._get_connection().get_server_type() |
| 1909 | + |
| 1910 | + def get_compaction_plans( |
| 1911 | + self, |
| 1912 | + job_id: int, |
| 1913 | + timeout: Optional[float] = None, |
| 1914 | + **kwargs, |
| 1915 | + ) -> CompactionPlans: |
| 1916 | + """Get compaction plans for a specific job. |
| 1917 | +
|
| 1918 | + Args: |
| 1919 | + job_id (int): The ID of the compaction job. |
| 1920 | + timeout (Optional[float]): An optional duration of time in seconds to allow for the RPC. |
| 1921 | + **kwargs: Additional arguments. |
| 1922 | +
|
| 1923 | + Returns: |
| 1924 | + CompactionPlans: The compaction plans for the specified job. |
| 1925 | + """ |
| 1926 | + return self._get_connection().get_compaction_plans(job_id, timeout=timeout, **kwargs) |
0 commit comments