pinecone.deprecation_warnings

  1def _build_class_migration_message(method_name: str, example: str):
  2    return f"""{method_name} is no longer a top-level attribute of the pinecone package.
  3
  4To use {method_name}, please create a client instance and call the method there instead.
  5
  6Example:
  7{example}
  8"""
  9
 10
 11def init(*args, **kwargs):
 12    example = """
 13    import os
 14    from pinecone import Pinecone, ServerlessSpec
 15
 16    pc = Pinecone(
 17        api_key=os.environ.get("PINECONE_API_KEY")
 18    )
 19
 20    # Now do stuff
 21    if 'my_index' not in pc.list_indexes().names():
 22        pc.create_index(
 23            name='my_index', 
 24            dimension=1536, 
 25            metric='euclidean',
 26            spec=ServerlessSpec(
 27                cloud='aws',
 28                region='us-west-2'
 29            )
 30        )
 31"""
 32    msg = f"""init is no longer a top-level attribute of the pinecone package.
 33
 34Please create an instance of the Pinecone class instead.
 35
 36Example:
 37{example}
 38"""
 39    raise AttributeError(msg)
 40
 41
 42def list_indexes(*args, **kwargs):
 43    example = """
 44    from pinecone import Pinecone
 45    
 46    pc = Pinecone(api_key='YOUR_API_KEY')
 47
 48    index_name = "quickstart" # or your index name
 49
 50    if index_name not in pc.list_indexes().names():
 51        # do something
 52"""
 53    raise AttributeError(_build_class_migration_message("list_indexes", example))
 54
 55
 56def describe_index(*args, **kwargs):
 57    example = """
 58    from pinecone import Pinecone
 59    
 60    pc = Pinecone(api_key='YOUR_API_KEY')
 61    pc.describe_index('my_index')
 62"""
 63    raise AttributeError(_build_class_migration_message("describe_index", example))
 64
 65
 66def create_index(*args, **kwargs):
 67    example = """
 68    from pinecone import Pinecone, ServerlessSpec
 69
 70    pc = Pinecone(api_key='YOUR_API_KEY')
 71    pc.create_index(
 72        name='my-index',
 73        dimension=1536,
 74        metric='euclidean',
 75        spec=ServerlessSpec(
 76            cloud='aws',
 77            region='us-west-2'
 78        )
 79    )
 80"""
 81    raise AttributeError(_build_class_migration_message("create_index", example))
 82
 83
 84def delete_index(*args, **kwargs):
 85    example = """
 86    from pinecone import Pinecone
 87
 88    pc = Pinecone(api_key='YOUR_API_KEY')
 89    pc.delete_index('my_index')
 90"""
 91    raise AttributeError(_build_class_migration_message("delete_index", example))
 92
 93
 94def scale_index(*args, **kwargs):
 95    example = """
 96    from pinecone import Pinecone
 97
 98    pc = Pinecone(api_key='YOUR_API_KEY')
 99    pc.configure_index('my_index', replicas=2)
100"""
101
102    msg = f"""scale_index is no longer a top-level attribute of the pinecone package.
103
104Please create a client instance and call the configure_index method instead.
105
106Example:
107{example}
108"""
109    raise AttributeError(msg)
110
111
112def create_collection(*args, **kwargs):
113    example = """
114    from pinecone import Pinecone
115    
116    pc = Pinecone(api_key='YOUR_API_KEY')
117    pc.create_collection(name='my_collection', source='my_index')
118"""
119    raise AttributeError(_build_class_migration_message("create_collection", example))
120
121
122def list_collections(*args, **kwargs):
123    example = """
124    from pinecone import Pinecone
125
126    pc = Pinecone(api_key='YOUR_API_KEY')
127    pc.list_collections()
128"""
129    raise AttributeError(_build_class_migration_message("list_collections", example))
130
131
132def delete_collection(*args, **kwargs):
133    example = """
134    from pinecone import Pinecone
135    
136    pc = Pinecone(api_key='YOUR_API_KEY')
137    pc.delete_collection('my_collection')
138"""
139    raise AttributeError(_build_class_migration_message("delete_collection", example))
140
141
142def describe_collection(*args, **kwargs):
143    example = """
144    from pinecone import Pinecone
145    
146    pc = Pinecone(api_key='YOUR_API_KEY')
147    pc.describe_collection('my_collection')
148"""
149    raise AttributeError(_build_class_migration_message("describe_collection", example))
150
151
152def configure_index(*args, **kwargs):
153    example = """
154    from pinecone import Pinecone
155    
156    pc = Pinecone(api_key='YOUR_API_KEY')
157    pc.configure_index('my_index', replicas=2)
158"""
159    raise AttributeError(_build_class_migration_message("configure_index", example))
def init(*args, **kwargs):
12def init(*args, **kwargs):
13    example = """
14    import os
15    from pinecone import Pinecone, ServerlessSpec
16
17    pc = Pinecone(
18        api_key=os.environ.get("PINECONE_API_KEY")
19    )
20
21    # Now do stuff
22    if 'my_index' not in pc.list_indexes().names():
23        pc.create_index(
24            name='my_index', 
25            dimension=1536, 
26            metric='euclidean',
27            spec=ServerlessSpec(
28                cloud='aws',
29                region='us-west-2'
30            )
31        )
32"""
33    msg = f"""init is no longer a top-level attribute of the pinecone package.
34
35Please create an instance of the Pinecone class instead.
36
37Example:
38{example}
39"""
40    raise AttributeError(msg)
def list_indexes(*args, **kwargs):
43def list_indexes(*args, **kwargs):
44    example = """
45    from pinecone import Pinecone
46    
47    pc = Pinecone(api_key='YOUR_API_KEY')
48
49    index_name = "quickstart" # or your index name
50
51    if index_name not in pc.list_indexes().names():
52        # do something
53"""
54    raise AttributeError(_build_class_migration_message("list_indexes", example))
def describe_index(*args, **kwargs):
57def describe_index(*args, **kwargs):
58    example = """
59    from pinecone import Pinecone
60    
61    pc = Pinecone(api_key='YOUR_API_KEY')
62    pc.describe_index('my_index')
63"""
64    raise AttributeError(_build_class_migration_message("describe_index", example))
def create_index(*args, **kwargs):
67def create_index(*args, **kwargs):
68    example = """
69    from pinecone import Pinecone, ServerlessSpec
70
71    pc = Pinecone(api_key='YOUR_API_KEY')
72    pc.create_index(
73        name='my-index',
74        dimension=1536,
75        metric='euclidean',
76        spec=ServerlessSpec(
77            cloud='aws',
78            region='us-west-2'
79        )
80    )
81"""
82    raise AttributeError(_build_class_migration_message("create_index", example))
def delete_index(*args, **kwargs):
85def delete_index(*args, **kwargs):
86    example = """
87    from pinecone import Pinecone
88
89    pc = Pinecone(api_key='YOUR_API_KEY')
90    pc.delete_index('my_index')
91"""
92    raise AttributeError(_build_class_migration_message("delete_index", example))
def scale_index(*args, **kwargs):
 95def scale_index(*args, **kwargs):
 96    example = """
 97    from pinecone import Pinecone
 98
 99    pc = Pinecone(api_key='YOUR_API_KEY')
100    pc.configure_index('my_index', replicas=2)
101"""
102
103    msg = f"""scale_index is no longer a top-level attribute of the pinecone package.
104
105Please create a client instance and call the configure_index method instead.
106
107Example:
108{example}
109"""
110    raise AttributeError(msg)
def create_collection(*args, **kwargs):
113def create_collection(*args, **kwargs):
114    example = """
115    from pinecone import Pinecone
116    
117    pc = Pinecone(api_key='YOUR_API_KEY')
118    pc.create_collection(name='my_collection', source='my_index')
119"""
120    raise AttributeError(_build_class_migration_message("create_collection", example))
def list_collections(*args, **kwargs):
123def list_collections(*args, **kwargs):
124    example = """
125    from pinecone import Pinecone
126
127    pc = Pinecone(api_key='YOUR_API_KEY')
128    pc.list_collections()
129"""
130    raise AttributeError(_build_class_migration_message("list_collections", example))
def delete_collection(*args, **kwargs):
133def delete_collection(*args, **kwargs):
134    example = """
135    from pinecone import Pinecone
136    
137    pc = Pinecone(api_key='YOUR_API_KEY')
138    pc.delete_collection('my_collection')
139"""
140    raise AttributeError(_build_class_migration_message("delete_collection", example))
def describe_collection(*args, **kwargs):
143def describe_collection(*args, **kwargs):
144    example = """
145    from pinecone import Pinecone
146    
147    pc = Pinecone(api_key='YOUR_API_KEY')
148    pc.describe_collection('my_collection')
149"""
150    raise AttributeError(_build_class_migration_message("describe_collection", example))
def configure_index(*args, **kwargs):
153def configure_index(*args, **kwargs):
154    example = """
155    from pinecone import Pinecone
156    
157    pc = Pinecone(api_key='YOUR_API_KEY')
158    pc.configure_index('my_index', replicas=2)
159"""
160    raise AttributeError(_build_class_migration_message("configure_index", example))