From 371850f36cde844be46a1677c9fa178f925aa9ce Mon Sep 17 00:00:00 2001 From: g-despot <66276597+g-despot@users.noreply.github.com> Date: Sun, 23 Mar 2025 11:34:49 +0100 Subject: [PATCH 1/2] Remove Py V3 docs --- .../configuration/replication-consistency.mdx | 9 - _includes/code/connections/oidc-connect.mdx | 8 - .../code/embedded.instantiate.custom.mdx | 9 - _includes/code/embedded.instantiate.mdx | 9 - .../code/embedded.instantiate.module.mdx | 9 - _includes/code/graphql.aggregate.groupby.mdx | 20 - .../code/graphql.aggregate.nearObject.mdx | 22 - _includes/code/graphql.aggregate.nearText.mdx | 21 - .../code/graphql.aggregate.nearVector.mdx | 21 - _includes/code/graphql.aggregate.simple.mdx | 19 - _includes/code/graphql.explore.vector.mdx | 27 - _includes/code/graphql.filters.after.mdx | 16 - .../graphql.filters.bm25.filter.example.mdx | 21 - _includes/code/graphql.filters.bm25.mdx | 23 - _includes/code/graphql.filters.group.mdx | 28 - .../graphql.filters.hybrid.filter.example.mdx | 20 - _includes/code/graphql.filters.hybrid.mdx | 15 - .../graphql.filters.hybrid.properties.mdx | 21 - .../code/graphql.filters.hybrid.vector.mdx | 13 - _includes/code/graphql.filters.limit.mdx | 13 - _includes/code/graphql.filters.nearObject.mdx | 25 - .../code/graphql.filters.nearText.2obj.mdx | 27 - _includes/code/graphql.filters.nearText.mdx | 32 - _includes/code/graphql.filters.nearVector.mdx | 23 - _includes/code/graphql.filters.offset.mdx | 20 - .../graphql.filters.where.beacon.count.mdx | 24 - .../code/graphql.filters.where.beacon.mdx | 24 - .../graphql.filters.where.geocoordinates.mdx | 38 - _includes/code/graphql.filters.where.id.mdx | 25 - _includes/code/graphql.filters.where.like.mdx | 24 - .../code/graphql.filters.where.operands.mdx | 31 - .../code/graphql.filters.where.simple.mdx | 24 - .../code/graphql.filters.where.timestamps.mdx | 25 - _includes/code/graphql.get.beacon.mdx | 10 - _includes/code/graphql.get.consistency.mdx | 20 - _includes/code/graphql.get.multitenancy.mdx | 10 - _includes/code/graphql.get.simple.mdx | 10 - .../graphql.underscoreproperties.distance.mdx | 24 - ...phql.underscoreproperties.semanticpath.mdx | 36 - .../howto/manage-data.create.with.geo.mdx | 19 - .../manage-data.read.check.existence.mdx | 11 - .../code/howto/manage-data.shards.inspect.mdx | 10 - .../code/howto/manage-data.shards.update.mdx | 14 - _includes/code/meta.mdx | 13 - _includes/code/nodes.mdx | 13 - _includes/code/qna-transformers.ask.mdx | 31 - _includes/code/quickstart.byov.schema.mdx | 9 - ...uickstart.import.questions-and-vectors.mdx | 9 - _includes/code/quickstart/connect.partial.mdx | 13 - _includes/code/quickstart/import.mdx | 9 - _includes/code/quickstart/neartext.mdx | 11 - .../code/schema.things.create.replication.mdx | 9 - .../code/schema.things.properties.add.mdx | 14 - _includes/code/tutorial.schema.create.mdx | 46 - .../code/tutorial.schema.index-settings.mdx | 61 -- .../code/tutorial.schema.multi-tenancy.mdx | 50 - .../tutorial.schema.properties.options.mdx | 47 - _includes/code/wcs.authentication.api.key.mdx | 14 - ...hentication.api.key.with.inference.key.mdx | 19 - _includes/code/wcs.without.authentication.mdx | 11 - _includes/code/wellknown.live.mdx | 12 - .../code/wellknown.openid-configuration.mdx | 12 - _includes/code/wellknown.ready.mdx | 12 - _includes/how.to.get.object.count.mdx | 11 - _includes/schema-delete-class.mdx | 9 - .../api/graphql/additional-operators.md | 32 - .../weaviate/client-libraries/python/index.md | 10 - .../client-libraries/python/python_v3.md | 915 ------------------ .../python/v3_v4_migration.md | 277 ------ docs/weaviate/configuration/backups.md | 45 - .../compression/bq-compression.md | 17 - .../compression/pq-compression.md | 33 - .../compression/sq-compression.md | 17 - docs/weaviate/connections/connect-cloud.mdx | 17 - .../weaviate/connections/connect-embedded.mdx | 9 - docs/weaviate/connections/connect-local.mdx | 33 - docs/weaviate/manage-data/collections.mdx | 177 ---- docs/weaviate/manage-data/create.mdx | 58 -- .../weaviate/manage-data/cross-references.mdx | 97 -- docs/weaviate/manage-data/delete.mdx | 40 - docs/weaviate/manage-data/import.mdx | 57 -- docs/weaviate/manage-data/migrate.mdx | 97 -- docs/weaviate/manage-data/multi-tenancy.md | 57 -- .../weaviate/manage-data/read-all-objects.mdx | 25 - docs/weaviate/manage-data/read.mdx | 25 - docs/weaviate/manage-data/update.mdx | 33 - docs/weaviate/search/aggregate.md | 64 -- docs/weaviate/search/basics.md | 87 -- docs/weaviate/search/bm25.md | 64 -- docs/weaviate/search/filters.md | 104 -- docs/weaviate/search/generative.md | 32 - docs/weaviate/search/hybrid.md | 97 -- docs/weaviate/search/image.md | 16 - docs/weaviate/search/rerank.md | 24 - docs/weaviate/search/similarity.md | 80 -- .../starter-guides/custom-vectors.mdx | 15 - docs/weaviate/starter-guides/generative.md | 104 -- sidebars.js | 2 - tools/remove_py3.py | 128 +++ 99 files changed, 128 insertions(+), 4045 deletions(-) delete mode 100644 docs/weaviate/client-libraries/python/python_v3.md delete mode 100644 docs/weaviate/client-libraries/python/v3_v4_migration.md create mode 100644 tools/remove_py3.py diff --git a/_includes/code/configuration/replication-consistency.mdx b/_includes/code/configuration/replication-consistency.mdx index 8209c476..f189528f 100644 --- a/_includes/code/configuration/replication-consistency.mdx +++ b/_includes/code/configuration/replication-consistency.mdx @@ -1,7 +1,6 @@ import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; import PyCode from '!!raw-loader!/_includes/code/howto/manage-data.collections.py'; -import PyCodeV3 from '!!raw-loader!/_includes/code/howto/manage-data.collections-v3.py'; import TSCode from '!!raw-loader!/_includes/code/howto/manage-data.collections.ts'; import TSCodeLegacy from '!!raw-loader!/_includes/code/howto/manage-data.collections-v2.ts'; import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; @@ -17,14 +16,6 @@ import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBl /> - - - - - - - - - @@ -14,14 +13,6 @@ import TsCodeV2 from '!!raw-loader!/_includes/code/install/embedded-v2.ts'; language="py" /> - - - - - - - - - -```python -import weaviate - -client = weaviate.Client("http://localhost:8080") - -response = ( - client.query - .aggregate("Article") - .with_group_by_filter(["inPublication"]) - .with_meta_count() - .with_fields("meta { count } wordCount { mean } groupedBy { path value }") - .do() -) - -print(response) -``` - diff --git a/_includes/code/graphql.aggregate.nearObject.mdx b/_includes/code/graphql.aggregate.nearObject.mdx index 5de5f0aa..248ac3e4 100644 --- a/_includes/code/graphql.aggregate.nearObject.mdx +++ b/_includes/code/graphql.aggregate.nearObject.mdx @@ -12,28 +12,6 @@ import PyCode from '!!raw-loader!/_includes/code/graphql.aggregate.simple.py'; endMarker="END GraphQLnearObjectAggregate" language="py" /> - - - -```python -import weaviate - -client = weaviate.Client("http://localhost:8080") - -result = ( - client.query - .aggregate("Article") - .with_meta_count() - .with_fields("wordCount { count maximum mean median minimum mode sum type } inPublication { pointingTo type }") - # prior to v1.14, use certainty instead of distance - .with_near_object({"id": "00037775-1432-35e5-bc59-443baaef7d80", "distance": 0.6}) - .with_object_limit(200) - .do() -) - -print(result) -``` - diff --git a/_includes/code/graphql.aggregate.nearText.mdx b/_includes/code/graphql.aggregate.nearText.mdx index 46bddb69..5b1490b0 100644 --- a/_includes/code/graphql.aggregate.nearText.mdx +++ b/_includes/code/graphql.aggregate.nearText.mdx @@ -12,27 +12,6 @@ import PyCode from '!!raw-loader!/_includes/code/graphql.aggregate.simple.py'; endMarker="END GraphQLnearTextAggregate" language="py" /> - - - -```python -import weaviate - -client = weaviate.Client("http://localhost:8080") - -result = ( - client.query - .aggregate("Article") - .with_meta_count() - .with_fields("wordCount {count maximum mean median minimum mode sum type} inPublication {pointingTo type}") - .with_near_text({"concepts": ["apple iphone"], "distance": 0.7}) # prior to v1.14 use "certainty" instead of "distance" - .with_object_limit(200) # at least one of "objectLimit", - .do() # and/or "distance" must be set -) # when using near media filters - -print(result) -``` - diff --git a/_includes/code/graphql.aggregate.nearVector.mdx b/_includes/code/graphql.aggregate.nearVector.mdx index 2ddb2d91..7c8ab6e6 100644 --- a/_includes/code/graphql.aggregate.nearVector.mdx +++ b/_includes/code/graphql.aggregate.nearVector.mdx @@ -12,27 +12,6 @@ import PyCode from '!!raw-loader!/_includes/code/graphql.aggregate.simple.py'; endMarker="END GraphQLnearVectorAggregate" language="py" /> - - - -```python -import weaviate - -client = weaviate.Client("http://localhost:8080") - -result = ( - client.query - .aggregate("Article") - .with_meta_count() - .with_fields("wordCount {count maximum mean median minimum mode sum type}") - .with_near_vector({"vector": [0.1, 0.2, -0.3], "certainty": 0.7}) - .with_object_limit(100) - .do() -) - -print(result) -``` - diff --git a/_includes/code/graphql.aggregate.simple.mdx b/_includes/code/graphql.aggregate.simple.mdx index e5eb8c2d..e23852cd 100644 --- a/_includes/code/graphql.aggregate.simple.mdx +++ b/_includes/code/graphql.aggregate.simple.mdx @@ -12,25 +12,6 @@ import PyCode from '!!raw-loader!/_includes/code/graphql.aggregate.simple.py'; endMarker="END GraphQLAggregateSimple" language="py" /> - - - -```python -import weaviate - -client = weaviate.Client("http://localhost:8080") - -response = ( - client.query - .aggregate("Article") - .with_meta_count() - .with_fields("wordCount {count maximum mean median minimum mode sum type}") - .do() -) - -print(response) -``` - diff --git a/_includes/code/graphql.explore.vector.mdx b/_includes/code/graphql.explore.vector.mdx index 760bc6ab..a1ac1246 100644 --- a/_includes/code/graphql.explore.vector.mdx +++ b/_includes/code/graphql.explore.vector.mdx @@ -2,33 +2,6 @@ import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; - - -```python -import weaviate - -client = weaviate.Client("http://localhost:8080") - -explore_articles_query = """ - { - Explore ( - nearVector: { - vector: [-0.36840257,0.13973749,-0.28994447,-0.18607682,0.20019795,0.15541431,-0.42353877,0.30262852,0.2724561,0.07069917,0.4877447,0.038771532,0.64523,-0.15907241,-0.3413626,-0.026682584,-0.63310874,-0.33411884,0.082939014,0.30305764,0.045918174,-0.21439327,-0.5005205,0.6210859,-0.2729049,-0.51221114,0.09680918,0.094923325,-0.15688285,-0.07325482,0.6588305,0.0523736,-0.14173415,-0.27428055,0.25526586,0.057506185,-0.3103442,0.028601522,0.124522656,0.66984487,0.12160647,-0.5090515,-0.540393,-0.39546522,-0.2201204,0.34625968,-0.21068871,0.21132985,0.048714135,0.09043683,0.3176081,-0.056684002,-0.12117501,-0.6591976,-0.26731065,0.42615625,0.33333477,-0.3240578,-0.18771006,0.2328068,-0.17239179,-0.33583146,-0.6556605,-0.10608161,-0.5135395,-0.25123677,-0.23004892,0.7036331,0.04456794,0.41253626,0.27872285,-0.28226635,0.11927197,-0.4677766,0.4343466,-0.17538455,0.10621233,0.95815116,0.23587844,-0.006406698,-0.10512518,-1.1125883,-0.37921682,0.040789194,0.676718,0.3369762,0.040712647,0.580487,0.20063736,-0.021220192,-0.09071747,-0.0023735985,0.30007777,-0.039925132,0.4035474,-0.2518212,-0.17846306,0.12371392,-0.0703354,-0.3752431,-0.652917,0.5952828,1.3426708,-0.08167235,-0.38515738,0.058423538,-0.08100355,-0.192886,0.3745164,-0.23291737,0.33326542,-0.6019264,-0.42822492,-0.6524583,-0.15210791,-0.5073593,0.022548754,-0.058033653,-0.47369233,-0.30890635,0.6338296,0.0017854869,0.1954949,0.99348027,-0.26558784,-0.058124136,1.149388,0.02915948,0.013422121,0.25484946,-0.030017598,-0.23879935,0.053123385,-0.36463016,-0.0024245526,0.1202083,-0.45966506,-0.34140104,-0.08484162,-0.03537422,-0.2817959,0.25044164,-0.5060605,0.1252808,-0.032539487,0.110069446,-0.20679846,-0.46421885,-0.4141739,0.26994973,-0.070687145,0.16862138,-0.20162229,0.22199251,-0.2771402,0.23653336,0.16585203,-0.08286354,-0.15343396,0.23893964,-0.7453282,-0.16549355,-0.1947069,0.46136436,0.22064126,0.28654936,-0.038697664,0.037633028,-0.80988157,0.5094175,-0.0920082,0.25405347,-0.64169943,0.43366328,-0.2999211,-0.4090591,0.11957859,0.00803617,-0.0433745,0.12818244,0.28464508,-0.31760025,0.16558012,-0.33553946,-0.3943465,0.59569097,-0.6524206,0.3683173,-0.60456693,0.2046492,0.46010277,0.24695799,0.2946015,0.11376746,-0.027988048,0.03749422,-0.16577742,0.23407385,-0.0231737,-0.023245076,0.08752677,0.2299883,0.35467404,0.046193745,-0.39828986,0.21079691,0.38396686,-0.0018698421,0.16047359,-0.057517264,-0.203534,0.23438136,-0.84250915,0.22371331,0.0058325706,0.30733636,0.19518353,-0.108008966,0.6509316,0.070131645,-0.24023099,0.28779706,0.2326336,0.07004021,-0.45955566,0.20426086,-0.37472793,-0.049604423,0.4537271,0.6133582,-1.0527759,-0.5472505,0.15193434,0.5296606,-0.11560251,0.07279209,0.40557706,0.2505283,0.24490519,0.017602902,-0.004647707,0.16608049,0.12576887,0.118216865,0.4403996,0.39552462,-0.22196701,-0.061155193,0.03693534,-0.4022908,0.3842317,-0.0831345,0.01930883,0.3446575,-0.2167439,-0.23994556,-0.09370326,-0.3671856,0.044011243,0.017895095,-0.019855855,-0.16416992,0.17858285,0.31287143,0.38368022,-0.006513525,0.45780763,-0.23027879,0.108570844,-0.4449492,-0.035763215,0.03818417,0.040017277,-0.17022872,-0.2622464,0.65610534,0.16720143,0.2515769,-0.23535803,0.62484455,0.16771325,-0.62404263,0.19176348,-0.72786695,0.18485649,-0.30914405,-0.3230534,-0.24064465,0.28841522,0.39792386,0.15618932,0.03928854,0.18277727,-0.101632096,0.1868196,-0.33366352,0.086561844,0.48557812,-0.6198209,-0.07978742] - } - ) { - beacon - certainty // only supported if distance==cosine - distance // always supported - className - } - } -""" - -query_result = client.query.raw(explore_articles_query) -print(query_result) -``` - - ```js diff --git a/_includes/code/graphql.filters.after.mdx b/_includes/code/graphql.filters.after.mdx index 3e56e565..a2b731d9 100644 --- a/_includes/code/graphql.filters.after.mdx +++ b/_includes/code/graphql.filters.after.mdx @@ -12,22 +12,6 @@ import PyCode from '!!raw-loader!/_includes/code/graphql.additional.py'; language="py" /> - - - -```py -response = ( - client.query.get("Article", ["title"]) - .with_additional(["id"]) - .with_limit(5) - .with_after("002d5cb3-298b-380d-addb-2e026b76c8ed") - .do() -) - -print(response) -``` - - ```js diff --git a/_includes/code/graphql.filters.bm25.filter.example.mdx b/_includes/code/graphql.filters.bm25.filter.example.mdx index 56b862eb..216023ea 100644 --- a/_includes/code/graphql.filters.bm25.filter.example.mdx +++ b/_includes/code/graphql.filters.bm25.filter.example.mdx @@ -12,27 +12,6 @@ import PyCode from '!!raw-loader!/_includes/code/graphql.search-operators.py'; endMarker="END GraphQLBM25WithFilter" language="py" /> - - - -```python -# highlight-start -where_filter = { - "path": ["wordCount"], - "operator": "LessThan", - "valueInt": "1000" -} -# highlight-end - -query_result = ( - client.query - .get("Article", ["title", "summary"]) - .with_where(where_filter) - .with_bm25(query="how to fish") - .do() -) -``` - diff --git a/_includes/code/graphql.filters.bm25.mdx b/_includes/code/graphql.filters.bm25.mdx index 4849d5fd..5f340956 100644 --- a/_includes/code/graphql.filters.bm25.mdx +++ b/_includes/code/graphql.filters.bm25.mdx @@ -12,29 +12,6 @@ import PyCode from '!!raw-loader!/_includes/code/graphql.search-operators.py'; endMarker="END GraphQLBM25Basic" language="py" /> - - - -```python -import weaviate - -client = weaviate.Client("http://localhost:8080") - -bm25 = { - "query": "fox", - "properties": ["title"], # by default, all properties are searched -} - -result = ( - client.query - .get("Article", ["title", "_additional {score} "]) - .with_bm25(**bm25) - .do() -) - -print(result) -``` - diff --git a/_includes/code/graphql.filters.group.mdx b/_includes/code/graphql.filters.group.mdx index 552b7852..793e748f 100644 --- a/_includes/code/graphql.filters.group.mdx +++ b/_includes/code/graphql.filters.group.mdx @@ -12,34 +12,6 @@ import PyCode from '!!raw-loader!/_includes/code/graphql.additional.py'; language="py" /> - - - -```python -import weaviate - -client = weaviate.Client("http://localhost:8080") - -get_articles_group = """ - { - Get { - Publication( - group:{ - type: merge, - force:0.05 - } - ) { - name - } - } - } -""" - -query_result = client.query.raw(get_articles_group) -print(query_result) -``` - - ```js diff --git a/_includes/code/graphql.filters.hybrid.filter.example.mdx b/_includes/code/graphql.filters.hybrid.filter.example.mdx index f69b5424..c2cfffdc 100644 --- a/_includes/code/graphql.filters.hybrid.filter.example.mdx +++ b/_includes/code/graphql.filters.hybrid.filter.example.mdx @@ -12,26 +12,6 @@ import PyCode from '!!raw-loader!/_includes/code/graphql.search-operators.py'; endMarker="END GraphQLHybridWithFilter" language="py" /> - - - -```python -# highlight-start -where_filter = { - "path": ["wordCount"], - "operator": "LessThan", - "valueInt": "1000" -} -# highlight-end -query_result = ( - client.query - .get("Article", ["title", "summary"]) - .with_where(where_filter) - .with_hybrid(query= "How to catch an Alaskan Pollock",alpha=0.5) - .do() -) -``` - diff --git a/_includes/code/graphql.filters.hybrid.mdx b/_includes/code/graphql.filters.hybrid.mdx index 0b577837..eb84fca8 100644 --- a/_includes/code/graphql.filters.hybrid.mdx +++ b/_includes/code/graphql.filters.hybrid.mdx @@ -12,21 +12,6 @@ import PyCode from '!!raw-loader!/_includes/code/graphql.search-operators.py'; endMarker="END GraphQLHybridSearch" language="py" /> - - - -```python - -result = ( - client.query - .get("Article", ["title", "summary"]) - .with_additional(["score", "explainScore"]) - .with_hybrid("Fisherman that catches salmon", alpha=0.5) - .do() - ) - -``` - diff --git a/_includes/code/graphql.filters.hybrid.properties.mdx b/_includes/code/graphql.filters.hybrid.properties.mdx index 670c3456..a1826d12 100644 --- a/_includes/code/graphql.filters.hybrid.properties.mdx +++ b/_includes/code/graphql.filters.hybrid.properties.mdx @@ -14,27 +14,6 @@ import PyCode from '!!raw-loader!/_includes/code/graphql.search-operators.py'; endMarker="END GraphQLHybridWithPropertiesSpecified" language="py" /> - - - -```python -result = ( - client.query - .get("JeopardyQuestion", ["question", "answer"]) - .with_additional(["score"]) - .with_hybrid( - "Venus", - alpha=0.25, # closer to pure keyword search -# highlight-start - properties=["question"] # changing to "answer" will yield a different result set -# highlight-end - ) - .with_limit(3)do() -) - -print(json.dumps(result, indent=4)) -``` - diff --git a/_includes/code/graphql.filters.hybrid.vector.mdx b/_includes/code/graphql.filters.hybrid.vector.mdx index 088d6c23..ccb9f446 100644 --- a/_includes/code/graphql.filters.hybrid.vector.mdx +++ b/_includes/code/graphql.filters.hybrid.vector.mdx @@ -12,19 +12,6 @@ import PyCode from '!!raw-loader!/_includes/code/graphql.search-operators.py'; endMarker="END GraphQLHybridWithVector" language="py" /> - - - -```python -result = ( - client.query - .get("Article", ["title", "summary"]) - .with_additional(["score"]) - .with_hybrid("Fisherman that catches salmon", alpha=0.5, vector=[1, 2, 3]) - .do() - ) -``` - diff --git a/_includes/code/graphql.filters.limit.mdx b/_includes/code/graphql.filters.limit.mdx index 0da03403..6cafc7ed 100644 --- a/_includes/code/graphql.filters.limit.mdx +++ b/_includes/code/graphql.filters.limit.mdx @@ -12,19 +12,6 @@ import PyCode from '!!raw-loader!/_includes/code/graphql.additional.py'; language="py" /> - - - -```python -import weaviate - -client = weaviate.Client("http://localhost:8080") - -result = client.query.get("Article", ["title"]).with_limit(5).do() -print(result) -``` - - ```js diff --git a/_includes/code/graphql.filters.nearObject.mdx b/_includes/code/graphql.filters.nearObject.mdx index 132f897a..0f335d11 100644 --- a/_includes/code/graphql.filters.nearObject.mdx +++ b/_includes/code/graphql.filters.nearObject.mdx @@ -12,31 +12,6 @@ import PyCode from '!!raw-loader!/_includes/code/graphql.search-operators.py'; endMarker="END GraphQLnearObject" language="py" /> - - - -```python -import weaviate - -client = weaviate.Client("http://localhost:8080") - -nearObject = { - "id": "32d5a368-ace8-3bb7-ade7-9f7ff03eddb6", # or {"beacon": "weaviate://localhost/32d5a368-ace8-3bb7-ade7-9f7ff03eddb6"} - "distance": 0.6, -} - -result = ( - client.query - .get("Publication", "name") - .with_additional("distance") # "certainty" only supported if distance==cosine - .with_near_object(nearObject) - .with_limit(5) - .do() -) - -print(result) -``` - diff --git a/_includes/code/graphql.filters.nearText.2obj.mdx b/_includes/code/graphql.filters.nearText.2obj.mdx index f2c8206b..475a3c42 100644 --- a/_includes/code/graphql.filters.nearText.2obj.mdx +++ b/_includes/code/graphql.filters.nearText.2obj.mdx @@ -12,33 +12,6 @@ import PyCode from '!!raw-loader!/_includes/code/graphql.search-operators.py'; endMarker="END GraphQLnearText2" language="py" /> - - - -```python -import weaviate - -client = weaviate.Client("http://localhost:8080") - -nearText = { - "concepts": ["travelling in Asia"], - "certainty": 0.7, - "moveTo": { - "objects": [{"id": "c4209549-7981-3699-9648-61a78c2124b9"}], - "force": 0.85 - } -} - -result = ( - client.query - .get("Article", ["title", "summary", "_additional { certainty }"]) - .with_near_text(nearText) - .do() -) - -print(result) -``` - diff --git a/_includes/code/graphql.filters.nearText.mdx b/_includes/code/graphql.filters.nearText.mdx index 739df562..eafbed30 100644 --- a/_includes/code/graphql.filters.nearText.mdx +++ b/_includes/code/graphql.filters.nearText.mdx @@ -9,38 +9,6 @@ import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBl text={PyCode} language="py" /> - - - -```python -import weaviate - -client = weaviate.Client("http://localhost:8080") - -nearText = { - "concepts": ["fashion"], - "distance": 0.6, # prior to v1.14 use "certainty" instead of "distance" - "moveAwayFrom": { - "concepts": ["finance"], - "force": 0.45 - }, - "moveTo": { - "concepts": ["haute couture"], - "force": 0.85 - } -} - -result = ( - client.query - .get("Publication", "name") - .with_additional(["certainty OR distance"]) # note that certainty is only supported if distance==cosine - .with_near_text(nearText) - .do() -) - -print(result) -``` - diff --git a/_includes/code/graphql.filters.nearVector.mdx b/_includes/code/graphql.filters.nearVector.mdx index 50fee454..86d5c91a 100644 --- a/_includes/code/graphql.filters.nearVector.mdx +++ b/_includes/code/graphql.filters.nearVector.mdx @@ -12,29 +12,6 @@ import PyCode from '!!raw-loader!/_includes/code/graphql.search-operators.py'; endMarker="END GraphQLnearVector" language="py" /> - - - -```python -import weaviate - -client = weaviate.Client("http://localhost:8080") - -nearVector = { - "vector": [0.1, -0.15, 0.3.. ] # Replace with a compatible vector -} - -result = ( - client.query - .get("Publication", "name") - .with_additional("distance") - .with_near_vector(nearVector) - .do() -) - -print(result) -``` - diff --git a/_includes/code/graphql.filters.offset.mdx b/_includes/code/graphql.filters.offset.mdx index 293e2f46..9e0d3ee3 100644 --- a/_includes/code/graphql.filters.offset.mdx +++ b/_includes/code/graphql.filters.offset.mdx @@ -12,26 +12,6 @@ import PyCode from '!!raw-loader!/_includes/code/graphql.additional.py'; language="py" /> - - - -```python -import weaviate - -client = weaviate.Client("http://localhost:8080") - -result = ( - client.query - .get("Article", "title") - .with_limit(5) - .with_offset(2) - .do() -) - -print(result) -``` - - ```js diff --git a/_includes/code/graphql.filters.where.beacon.count.mdx b/_includes/code/graphql.filters.where.beacon.count.mdx index 397cd084..eb1b73fa 100644 --- a/_includes/code/graphql.filters.where.beacon.count.mdx +++ b/_includes/code/graphql.filters.where.beacon.count.mdx @@ -12,30 +12,6 @@ import PyCode from '!!raw-loader!/_includes/code/graphql.filters.py'; endMarker="END FilterByCountOfReferences" language="py" /> - - - -```python -import weaviate - -client = weaviate.Client("http://localhost:8080") - -where_filter = { - "valueInt": 2, - "operator": "GreaterThanEqual", - "path": ["writesFor"] -} - -response = ( - client.query - .get("Author", ["name", "writesFor {... on Publication { name }}"]) - .with_where(where_filter) - .do() -) - -print(response) -``` - diff --git a/_includes/code/graphql.filters.where.beacon.mdx b/_includes/code/graphql.filters.where.beacon.mdx index 1b32cf42..ad07cc9c 100644 --- a/_includes/code/graphql.filters.where.beacon.mdx +++ b/_includes/code/graphql.filters.where.beacon.mdx @@ -12,30 +12,6 @@ import PyCode from '!!raw-loader!/_includes/code/graphql.filters.py'; endMarker="END FilterByReference" language="py" /> - - - -```python -import weaviate - -client = weaviate.Client("http://localhost:8080") - -where_filter = { - "path": ["inPublication", "Publication", "name"], - "operator": "Equal", - "valueText": "New Yorker" -} - -query_result = ( - client.query - .get("Article", ["title", "inPublication{... on Publication{name}}"]) - .with_where(where_filter) - .do() -) - -print(query_result) -``` - diff --git a/_includes/code/graphql.filters.where.geocoordinates.mdx b/_includes/code/graphql.filters.where.geocoordinates.mdx index b4340d40..79810742 100644 --- a/_includes/code/graphql.filters.where.geocoordinates.mdx +++ b/_includes/code/graphql.filters.where.geocoordinates.mdx @@ -12,44 +12,6 @@ import PyCode from '!!raw-loader!/_includes/code/graphql.filters.py'; endMarker="END FilterByGeoCoordinates" language="py" /> - - - -```python -import weaviate - -client = weaviate.Client("http://localhost:8080") - -get_articles_where = """ - { - Get { - Publication(where: { - operator: WithinGeoRange, - valueGeoRange: { - geoCoordinates: { - latitude: 51.51, # latitude - longitude: -0.09 # longitude - }, - distance: { - max: 2000 # distance in meters - } - }, - path: ["headquartersGeoLocation"] # property needs to be of geoLocation type. - }) { - name - headquartersGeoLocation { - latitude - longitude - } - } - } - } -""" - -query_result = client.query.raw(get_articles_where) -print(query_result) -``` - diff --git a/_includes/code/graphql.filters.where.id.mdx b/_includes/code/graphql.filters.where.id.mdx index 45e82db9..578321ed 100644 --- a/_includes/code/graphql.filters.where.id.mdx +++ b/_includes/code/graphql.filters.where.id.mdx @@ -12,31 +12,6 @@ import PyCode from '!!raw-loader!/_includes/code/graphql.filters.py'; endMarker="END FilterById" language="py" /> - - - -```python -import weaviate -import json - -client = weaviate.Client("http://localhost:8080") - -where_filter = { - "path": ["id"], - "operator": "Equal", - "valueText": "00037775-1432-35e5-bc59-443baaef7d80" -} - -response = ( - client.query - .get("Article", "title") - .with_where(where_filter) - .do() -) - -print(json.dumps(response, indent=2)) -``` - diff --git a/_includes/code/graphql.filters.where.like.mdx b/_includes/code/graphql.filters.where.like.mdx index 6e0b13e3..116492f2 100644 --- a/_includes/code/graphql.filters.where.like.mdx +++ b/_includes/code/graphql.filters.where.like.mdx @@ -12,30 +12,6 @@ import PyCode from '!!raw-loader!/_includes/code/graphql.filters.py'; endMarker="END FilterWithLike" language="py" /> - - - -```python -import weaviate - -client = weaviate.Client("http://localhost:8080") - -where_filter = { - "path": ["name"], - "operator": "Like", - "valueText": "New *" -} - -query_result = ( - client.query - .get("Publication", "name") - .with_where(where_filter) - .do() -) - -print(query_result) -``` - diff --git a/_includes/code/graphql.filters.where.operands.mdx b/_includes/code/graphql.filters.where.operands.mdx index b884a92e..d643f40d 100644 --- a/_includes/code/graphql.filters.where.operands.mdx +++ b/_includes/code/graphql.filters.where.operands.mdx @@ -12,37 +12,6 @@ import PyCode from '!!raw-loader!/_includes/code/graphql.filters.py'; endMarker="END MultipleConditionsFilter" language="py" /> - - - -```python -import weaviate - -client = weaviate.Client("http://localhost:8080") - -where_filter = { - "operator": "And", - "operands": [{ - "path": ["wordCount"], - "operator": "GreaterThan", - "valueInt": 1000 - }, { - "path": ["title"], - "operator": "Like", - "valueText": "*economy*", - }] -} - -response = ( - client.query - .get("Article", "title") - .with_where(where_filter) - .do() -) - -print(response) -``` - diff --git a/_includes/code/graphql.filters.where.simple.mdx b/_includes/code/graphql.filters.where.simple.mdx index 6bd424e1..a1c3200f 100644 --- a/_includes/code/graphql.filters.where.simple.mdx +++ b/_includes/code/graphql.filters.where.simple.mdx @@ -12,30 +12,6 @@ import PyCode from '!!raw-loader!/_includes/code/graphql.filters.py'; endMarker="END SingleConditionFilter" language="py" /> - - - -```python -import weaviate - -client = weaviate.Client("http://localhost:8080") - -where_filter = { - "path": ["wordCount"], - "operator": "GreaterThan", - "valueInt": 1000 -} - -query_result = ( - client.query - .get("Article", "title") - .with_where(where_filter) - .do() -) - -print(query_result) -``` - diff --git a/_includes/code/graphql.filters.where.timestamps.mdx b/_includes/code/graphql.filters.where.timestamps.mdx index a1f2409f..aa98ee1d 100644 --- a/_includes/code/graphql.filters.where.timestamps.mdx +++ b/_includes/code/graphql.filters.where.timestamps.mdx @@ -12,31 +12,6 @@ import PyCode from '!!raw-loader!/_includes/code/graphql.filters.py'; endMarker="END FilterByTimestamps" language="py" /> - - - -```python -import weaviate - -client = weaviate.Client("http://localhost:8080") - -where_filter = { - "path": ["_creationTimeUnix"], - "operator": "GreaterThan", - # "valueDate": "2022-03-18T20:26:34.586-05:00", # Can use either `valueDate` with a `RFC3339` datetime or `valueText` as Unix epoch milliseconds - "valueText": "1647653359063" -} - -response = ( - client.query - .get("Article", "title") - .with_where(where_filter) - .do() -) - -print(response) -``` - diff --git a/_includes/code/graphql.get.beacon.mdx b/_includes/code/graphql.get.beacon.mdx index 565fa454..98cabc22 100644 --- a/_includes/code/graphql.get.beacon.mdx +++ b/_includes/code/graphql.get.beacon.mdx @@ -15,16 +15,6 @@ import PyCodeV3 from '!!raw-loader!/_includes/code/graphql.get.beacon.v3.py'; language="py" /> - - - - - diff --git a/_includes/code/graphql.get.consistency.mdx b/_includes/code/graphql.get.consistency.mdx index 3834b61f..231ae01e 100644 --- a/_includes/code/graphql.get.consistency.mdx +++ b/_includes/code/graphql.get.consistency.mdx @@ -3,7 +3,6 @@ import TabItem from '@theme/TabItem'; import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; import PyCode from '!!raw-loader!/_includes/code/graphql.get.simple.py'; -import PyCodeV3 from '!!raw-loader!/_includes/code/graphql.get.simple.v3.py'; @@ -13,25 +12,6 @@ import PyCodeV3 from '!!raw-loader!/_includes/code/graphql.get.simple.v3.py'; endMarker="END ConsistencyExample" language="py" /> - - - -```python -import weaviate -from weaviate.data.replication import ConsistencyLevel - -client = weaviate.Client("http://localhost:8080") - -resp = ( - client.query.get("Article", ["name"]) - .with_additional("isConsistent") - .with_consistency_level(ConsistencyLevel.QUORUM) - .do() -) - -print(f"resp: {resp}") -``` - diff --git a/_includes/code/graphql.get.multitenancy.mdx b/_includes/code/graphql.get.multitenancy.mdx index d1d13454..a1509029 100644 --- a/_includes/code/graphql.get.multitenancy.mdx +++ b/_includes/code/graphql.get.multitenancy.mdx @@ -2,7 +2,6 @@ import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; import PyCode from '!!raw-loader!/_includes/code/howto/manage-data.multi-tenancy.py'; -import PyCodeV3 from '!!raw-loader!/_includes/code/howto/manage-data.multi-tenancy-v3.py'; import TSCode from '!!raw-loader!/_includes/code/howto/manage-data.multi-tenancy.ts'; import JavaCode from '!!raw-loader!/_includes/code/howto/java/src/test/java/io/weaviate/docs/manage-data.multi-tenancy.java'; import GoCode from '!!raw-loader!/_includes/code/howto/go/docs/manage-data.multi-tenancy_test.go'; @@ -17,15 +16,6 @@ import GoCode from '!!raw-loader!/_includes/code/howto/go/docs/manage-data.multi /> - - - - - - - - - diff --git a/_includes/code/graphql.underscoreproperties.distance.mdx b/_includes/code/graphql.underscoreproperties.distance.mdx index 93251b0f..ed0b8f23 100644 --- a/_includes/code/graphql.underscoreproperties.distance.mdx +++ b/_includes/code/graphql.underscoreproperties.distance.mdx @@ -13,30 +13,6 @@ import PyCode from '!!raw-loader!/_includes/code/graphql.metadata.py'; language="py" /> - - - -```python -import weaviate - -client = weaviate.Client("http://localhost:8080") - -near_text_filter = { - "concepts": ["fashion"] -} - -query_result = ( - client.query - .get("Article", "title") - .with_additional(["id", "distance"]) - .with_near_text(near_text_filter) - .do() -) - -print(query_result) -``` - - ```js diff --git a/_includes/code/graphql.underscoreproperties.semanticpath.mdx b/_includes/code/graphql.underscoreproperties.semanticpath.mdx index 73a740cf..7f1be79c 100644 --- a/_includes/code/graphql.underscoreproperties.semanticpath.mdx +++ b/_includes/code/graphql.underscoreproperties.semanticpath.mdx @@ -12,42 +12,6 @@ import PyCode from '!!raw-loader!/_includes/code/graphql.search-operators.py'; endMarker="END GraphQLSemanticPath" language="py" /> - - - -```python -import weaviate - -client = weaviate.Client("http://localhost:8080") - -near_text_operator = { - "concepts": ["fashion"], - "distance": 0.6, #prior to v1.14 use certainty: 0.7 - "moveAwayFrom": { - "concepts": ["finance"], - "force": 0.45 - }, - "moveTo": { - "concepts": ["haute couture"], - "force": 0.85 - } -} - -additional_props = { - "semanticPath": "path {distanceToNext distanceToPrevious distanceToQuery distanceToResult}" -} - -query_result = ( - client.query - .get("Publication", "name") - .with_additional(additional_props) - .with_near_text(near_text_operator) - .do() -) - -print(query_result) -``` - diff --git a/_includes/code/howto/manage-data.create.with.geo.mdx b/_includes/code/howto/manage-data.create.with.geo.mdx index 7e3da49d..cca05c12 100644 --- a/_includes/code/howto/manage-data.create.with.geo.mdx +++ b/_includes/code/howto/manage-data.create.with.geo.mdx @@ -15,25 +15,6 @@ import PyCode from '!!raw-loader!/_includes/code/howto/manage-data.create.py'; /> - - -```python -data_obj = { - "name": "Elsevier", - "headquartersGeoLocation": { - "latitude": 52.3932696, - "longitude": 4.8374263 - } -} - -data_uuid = client.data_object.create( - data_obj, - "Publication", - uuid="df48b9f6-ba48-470c-bf6a-57657cb07390", # optional, if not provided, one is going to be generated -) -``` - - ```js diff --git a/_includes/code/howto/manage-data.read.check.existence.mdx b/_includes/code/howto/manage-data.read.check.existence.mdx index 8cfbd50a..a1721cc3 100644 --- a/_includes/code/howto/manage-data.read.check.existence.mdx +++ b/_includes/code/howto/manage-data.read.check.existence.mdx @@ -15,17 +15,6 @@ import PyCode from '!!raw-loader!/_includes/code/howto/manage-data.create.py'; /> - - -```python -exists = client.data_object.exists( - "36ddd591-2dee-4e7e-a3cc-eb86d30a4303", - class_name="Author", -) -print(exists) -``` - - diff --git a/_includes/code/howto/manage-data.shards.inspect.mdx b/_includes/code/howto/manage-data.shards.inspect.mdx index e47cdb08..71a9a484 100644 --- a/_includes/code/howto/manage-data.shards.inspect.mdx +++ b/_includes/code/howto/manage-data.shards.inspect.mdx @@ -15,16 +15,6 @@ import JavaCode from '!!raw-loader!/_includes/code/howto/java/src/test/java/io/w /> - - -```python -# highlight-start -article_shards = client.schema.get_class_shards("Article") -# highlight-end -print(article_shards) -``` - - ```js diff --git a/_includes/code/howto/manage-data.shards.update.mdx b/_includes/code/howto/manage-data.shards.update.mdx index 96ebc818..438cdfbe 100644 --- a/_includes/code/howto/manage-data.shards.update.mdx +++ b/_includes/code/howto/manage-data.shards.update.mdx @@ -16,20 +16,6 @@ import JavaCode from '!!raw-loader!/_includes/code/howto/java/src/test/java/io/w /> - - -```python -# highlight-start -article_shards = client.schema.update_class_shard( - "Article", - status="READY", - shard_name="shard-1234" -) -# highlight-end -print(article_shards) -``` - - ```js diff --git a/_includes/code/meta.mdx b/_includes/code/meta.mdx index 486ca7d9..43fca65c 100644 --- a/_includes/code/meta.mdx +++ b/_includes/code/meta.mdx @@ -14,19 +14,6 @@ import PyCode from '!!raw-loader!/_includes/code/rest.meta.py'; language="py" /> - - - -```python -import weaviate - -client = weaviate.Client("http://localhost:8080") - -meta_info = client.get_meta() -print(meta_info) -``` - - ```js diff --git a/_includes/code/nodes.mdx b/_includes/code/nodes.mdx index ca26afc0..a946a8c3 100644 --- a/_includes/code/nodes.mdx +++ b/_includes/code/nodes.mdx @@ -14,19 +14,6 @@ import PyCode from '!!raw-loader!/_includes/code/rest.nodes.py'; language="py" /> - - - -```python -import weaviate - -client = weaviate.Client("http://localhost:8080") - -nodes_status = client.cluster.get_nodes_status() -print(nodes_status) -``` - - ```js diff --git a/_includes/code/qna-transformers.ask.mdx b/_includes/code/qna-transformers.ask.mdx index b2aa2e94..f6693587 100644 --- a/_includes/code/qna-transformers.ask.mdx +++ b/_includes/code/qna-transformers.ask.mdx @@ -12,37 +12,6 @@ import PyCode from '!!raw-loader!/_includes/code/graphql.search-operators.py'; endMarker="END GraphQLQnAExample" language="py" /> - - - -```python -import weaviate -import os - -client = weaviate.Client( - "https://edu-demo.weaviate.network", - auth_client_secret=weaviate.auth.AuthApiKey("learn-weaviate"), - additional_headers={ - "X-OpenAI-Api-Key": os.environ["OPENAI_API_KEY"] # Replace with your OPENAI API key - } -) - -ask = { - "question": "Who is the king of the Netherlands?", - "properties": ["summary"] -} - -result = ( - client.query - .get("Article", ["title", "_additional {answer {hasAnswer property result startPosition endPosition} }"]) - .with_ask(ask) - .with_limit(1) - .do() -) - -print(result) -``` - diff --git a/_includes/code/quickstart.byov.schema.mdx b/_includes/code/quickstart.byov.schema.mdx index 3d5582d8..afbef68a 100644 --- a/_includes/code/quickstart.byov.schema.mdx +++ b/_includes/code/quickstart.byov.schema.mdx @@ -4,7 +4,6 @@ import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; import ByovAllPyCode from '!!raw-loader!/_includes/code/quickstart.byov.all.py'; -import ByovAllPy3Code from '!!raw-loader!/_includes/code/quickstart.byov.all_v3.py'; import ByovAllTsCode from '!!raw-loader!/_includes/code/quickstart.byov.all.ts'; import ByovAllTsCodeLegacy from '!!raw-loader!/_includes/code/quickstart.byov.all.legacy.ts'; import ByovAllShCode from '!!raw-loader!/_includes/code/quickstart.byov.all.sh'; @@ -18,14 +17,6 @@ import ByovAllShCode from '!!raw-loader!/_includes/code/quickstart.byov.all.sh'; language="py" /> - - - - - - - - -```python -import weaviate -import json - -client = weaviate.Client( - url = "https://WEAVIATE_INSTANCE_URL", # Replace with your Weaviate endpoint - auth_client_secret=weaviate.auth.AuthApiKey(api_key="YOUR-WEAVIATE-API-KEY"), # Replace with your Weaviate instance API key -) -``` - diff --git a/_includes/code/quickstart/import.mdx b/_includes/code/quickstart/import.mdx index c1192506..78a6494c 100644 --- a/_includes/code/quickstart/import.mdx +++ b/_includes/code/quickstart/import.mdx @@ -2,7 +2,6 @@ import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; import EndToEndPyCode from '!!raw-loader!/_includes/code/quickstart/endtoend.py'; -import EndToEndPy3Code from '!!raw-loader!/_includes/code/quickstart/endtoend.py3.py'; import EndToEndTSCode from '!!raw-loader!/_includes/code/quickstart/endtoend.ts'; import EndToEndTSCodeLegacy from '!!raw-loader!/_includes/code/quickstart/endtoend-v2.ts'; import GoImportObjects from '!!raw-loader!/_includes/code/quickstart/go-add-objects.go'; @@ -16,14 +15,6 @@ import GoImportObjects from '!!raw-loader!/_includes/code/quickstart/go-add-obje language="py" /> - - - - - - - - diff --git a/_includes/code/schema.things.create.replication.mdx b/_includes/code/schema.things.create.replication.mdx index e665958f..ac47aa6f 100644 --- a/_includes/code/schema.things.create.replication.mdx +++ b/_includes/code/schema.things.create.replication.mdx @@ -1,7 +1,6 @@ import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; import PyCode from '!!raw-loader!/_includes/code/howto/manage-data.collections.py'; -import PyCodeV3 from '!!raw-loader!/_includes/code/howto/manage-data.collections-v3.py'; import TSCode from '!!raw-loader!/_includes/code/howto/manage-data.collections.ts'; import TSCodeLegacy from '!!raw-loader!/_includes/code/howto/manage-data.collections-v2.ts'; import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; @@ -17,14 +16,6 @@ import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBl /> - - - - - -```python -add_prop = { - "dataType": [ - "boolean" - ], - "name": "onHomepage" -} - -client.schema.property.create("Article", add_prop) -``` - - ```js diff --git a/_includes/code/tutorial.schema.create.mdx b/_includes/code/tutorial.schema.create.mdx index 8ae43c59..4b1d3cc0 100644 --- a/_includes/code/tutorial.schema.create.mdx +++ b/_includes/code/tutorial.schema.create.mdx @@ -13,52 +13,6 @@ import PyCode from '!!raw-loader!/_includes/code/starter-guides/schema.py'; language="py" /> - - - -```python -import weaviate -import json - -client = weaviate.Client("https://WEAVIATE_INSTANCE_URL/") # Replace with your Weaviate endpoint - -# we will create the class "Question" -class_obj = { - "class": "Question", - "description": "Information from a Jeopardy! question", # description of the class - "properties": [ - { - "name": "question", - "dataType": ["text"], - "description": "The question", - }, - { - "name": "answer", - "dataType": ["text"], - "description": "The answer", - }, - { - "name": "category", - "dataType": ["text"], - "description": "The question category", - }, - ], - "vectorizer": "text2vec-openai", - "moduleConfig": { - "generative-openai": {} # Set `generative-openai` as the generative module - } -} - -# add the schema -client.schema.create_class(class_obj) - -# get the schema -schema = client.schema.get() - -# print the schema -print(json.dumps(schema, indent=4)) -``` - diff --git a/_includes/code/tutorial.schema.index-settings.mdx b/_includes/code/tutorial.schema.index-settings.mdx index bf746735..54cdae71 100644 --- a/_includes/code/tutorial.schema.index-settings.mdx +++ b/_includes/code/tutorial.schema.index-settings.mdx @@ -13,67 +13,6 @@ import PyCode from '!!raw-loader!/_includes/code/starter-guides/schema.py'; language="py" /> - - - -```python -import weaviate -import json - -client = weaviate.Client("https://WEAVIATE_INSTANCE_URL/") # Replace with your Weaviate endpoint - -# we will create the class "Question" -class_obj = { - "class": "Question", - "description": "Information from a Jeopardy! question", # description of the class - "vectorizer": "text2vec-openai", - "moduleConfig": { - "generative-openai": {} # Set `generative-openai` as the generative module - }, - "properties": [ - { - "name": "question", - "dataType": ["text"], - "description": "The question", - "moduleConfig": { - "text2vec-openai": { # this must match the vectorizer used - "vectorizePropertyName": True, - "tokenization": "lowercase" - } - } - }, - { - "name": "answer", - "dataType": ["text"], - "description": "The answer", - "moduleConfig": { - "text2vec-openai": { # this must match the vectorizer used - "vectorizePropertyName": False, - "tokenization": "whitespace" - } - } - }, - ], - # highlight-start - # Configure the vector index - "vectorIndexType": "hnsw", # Or "flat" or "dynamic" - "vectorIndexConfig": { - "distance": "cosine", - "bq": { - "enabled": True, - }, - }, - # Configure the inverted index - "indexTimestamps": True, - "indexNullState": True, - "indexPropertyLength": True, - # highlight-end -} - -# add the schema -client.schema.create_class(class_obj) -``` - diff --git a/_includes/code/tutorial.schema.multi-tenancy.mdx b/_includes/code/tutorial.schema.multi-tenancy.mdx index 730d9cd1..0956b2ab 100644 --- a/_includes/code/tutorial.schema.multi-tenancy.mdx +++ b/_includes/code/tutorial.schema.multi-tenancy.mdx @@ -13,56 +13,6 @@ import PyCode from '!!raw-loader!/_includes/code/starter-guides/schema.py'; language="py" /> - - - -```python -import weaviate -import json - -client = weaviate.Client("https://WEAVIATE_INSTANCE_URL/") # Replace with your Weaviate endpoint - -# we will create the class "Question" -class_obj = { - "class": "Question", - "description": "Information from a Jeopardy! question", # description of the class - "vectorizer": "text2vec-openai", - "moduleConfig": { - "generative-openai": {} # Set `generative-openai` as the generative module - }, - "properties": [ - { - "name": "question", - "dataType": ["text"], - "description": "The question", - "moduleConfig": { - "text2vec-openai": { # this must match the vectorizer used - "vectorizePropertyName": True, - "tokenization": "lowercase" - } - } - }, - { - "name": "answer", - "dataType": ["text"], - "description": "The answer", - "moduleConfig": { - "text2vec-openai": { # this must match the vectorizer used - "vectorizePropertyName": False, - "tokenization": "whitespace" - } - } - }, - ], - # highlight-start - "multiTenancyConfig": {"enabled": True}, # Enable multi-tenancy - # highlight-end -} - -# add the schema -client.schema.create_class(class_obj) -``` - diff --git a/_includes/code/tutorial.schema.properties.options.mdx b/_includes/code/tutorial.schema.properties.options.mdx index 06053c80..1d6078a9 100644 --- a/_includes/code/tutorial.schema.properties.options.mdx +++ b/_includes/code/tutorial.schema.properties.options.mdx @@ -13,53 +13,6 @@ import PyCode from '!!raw-loader!/_includes/code/starter-guides/schema.py'; language="py" /> - - - -```python -import weaviate -import json - -client = weaviate.Client("https://WEAVIATE_INSTANCE_URL/") # Replace with your Weaviate endpoint - -# we will create the class "Question" -class_obj = { - "class": "Question", - "description": "Information from a Jeopardy! question", # description of the class - "vectorizer": "text2vec-openai", - "moduleConfig": { - "generative-openai": {} # Set `generative-openai` as the generative module - }, - "properties": [ - { - "name": "question", - "dataType": ["text"], - "description": "The question", - "moduleConfig": { - "text2vec-openai": { # this must match the vectorizer used - "vectorizePropertyName": True, - "tokenization": "lowercase" - } - } - }, - { - "name": "answer", - "dataType": ["text"], - "description": "The answer", - "moduleConfig": { - "text2vec-openai": { # this must match the vectorizer used - "vectorizePropertyName": False, - "tokenization": "whitespace" - } - } - }, - ], -} - -# add the schema -client.schema.create_class(class_obj) -``` - diff --git a/_includes/code/wcs.authentication.api.key.mdx b/_includes/code/wcs.authentication.api.key.mdx index 799246f6..8a42655c 100644 --- a/_includes/code/wcs.authentication.api.key.mdx +++ b/_includes/code/wcs.authentication.api.key.mdx @@ -23,20 +23,6 @@ import PyCode from '!!raw-loader!/_includes/code/tutorials/connect.py'; language="py" /> - - - -```python -import weaviate -import os - -# Instantiate the client with the auth config -client = weaviate.Client( - url="https://WEAVIATE_INSTANCE_URL", # Replace with your Weaviate endpoint - auth_client_secret=weaviate.auth.AuthApiKey(api_key=weaviate_key), # Replace with your Weaviate instance API key -) -``` - diff --git a/_includes/code/wcs.authentication.api.key.with.inference.key.mdx b/_includes/code/wcs.authentication.api.key.with.inference.key.mdx index 0c25d1d5..134cbb08 100644 --- a/_includes/code/wcs.authentication.api.key.with.inference.key.mdx +++ b/_includes/code/wcs.authentication.api.key.with.inference.key.mdx @@ -12,25 +12,6 @@ import PyCode from '!!raw-loader!/_includes/code/tutorials/connect.py'; endMarker="# END AuthThirdPartyAPIKey" language="py" /> - - - -```python -import weaviate -import os - -cohere_key = os.getenv("COHERE_API_KEY") # Recommended: save to an environment variable - -# Instantiate the client with the auth config -client = weaviate.Client( - url="https://WEAVIATE_INSTANCE_URL", # Replace with your Weaviate endpoint - auth_client_secret=weaviate.auth.AuthApiKey(api_key=weaviate_key), # Replace with your Weaviate instance API key - additional_headers={ - "X-Cohere-Api-Key": cohere_key, - }, -) -``` - diff --git a/_includes/code/wcs.without.authentication.mdx b/_includes/code/wcs.without.authentication.mdx index 66a71285..49f4ba12 100644 --- a/_includes/code/wcs.without.authentication.mdx +++ b/_includes/code/wcs.without.authentication.mdx @@ -12,17 +12,6 @@ import PyCode from '!!raw-loader!/_includes/code/tutorials/connect.py'; language="py" /> - - -```python -import weaviate - -client = weaviate.Client( - url="https://WEAVIATE_INSTANCE_URL", # Replace with your Weaviate endpoint -) -``` - - diff --git a/_includes/code/wellknown.live.mdx b/_includes/code/wellknown.live.mdx index 0e5327da..79a28247 100644 --- a/_includes/code/wellknown.live.mdx +++ b/_includes/code/wellknown.live.mdx @@ -15,18 +15,6 @@ import PyCode from '!!raw-loader!/_includes/code/rest.well-known.py'; /> - - -```python -import weaviate - -client = weaviate.Client("http://localhost:8080") - -is_live = client.is_live() -print(is_live) -``` - - ```js diff --git a/_includes/code/wellknown.openid-configuration.mdx b/_includes/code/wellknown.openid-configuration.mdx index 188619ea..92d97406 100644 --- a/_includes/code/wellknown.openid-configuration.mdx +++ b/_includes/code/wellknown.openid-configuration.mdx @@ -15,18 +15,6 @@ import PyCode from '!!raw-loader!/_includes/code/rest.well-known.py'; /> - - -```python -import weaviate - -client = weaviate.Client("http://localhost:8080") - -open_id_configuration = client.get_open_id_configuration() -print(open_id_configuration) -``` - - ```js diff --git a/_includes/code/wellknown.ready.mdx b/_includes/code/wellknown.ready.mdx index 96d7851c..1bbb9ff5 100644 --- a/_includes/code/wellknown.ready.mdx +++ b/_includes/code/wellknown.ready.mdx @@ -15,18 +15,6 @@ import PyCode from '!!raw-loader!/_includes/code/rest.well-known.py'; /> - - -```python -import weaviate - -client = weaviate.Client("http://localhost:8080") - -is_ready = client.is_ready() -print(is_ready) # returns True if Weaviate is ready -``` - - ```js diff --git a/_includes/how.to.get.object.count.mdx b/_includes/how.to.get.object.count.mdx index 26075e1b..27d2fe27 100644 --- a/_includes/how.to.get.object.count.mdx +++ b/_includes/how.to.get.object.count.mdx @@ -12,17 +12,6 @@ import PyCode from '!!raw-loader!/_includes/code/graphql.aggregate.simple.py'; endMarker="END GraphQLMetaCount" language="py" /> - - - -```python -import weaviate - -client = weaviate.Client("https://WEAVIATE_INSTANCE_URL") # Replace WEAVIATE_INSTANCE_URL with your instance URL - -client.query.aggregate().with_meta_count().do() -``` - diff --git a/_includes/schema-delete-class.mdx b/_includes/schema-delete-class.mdx index 1bc67994..8f175453 100644 --- a/_includes/schema-delete-class.mdx +++ b/_includes/schema-delete-class.mdx @@ -32,15 +32,6 @@ This code deletes a collection and its objects. /> - - -```python -# delete class "Article" - THIS WILL DELETE ALL DATA IN THIS CLASS -client.schema.delete_class("Article") # Replace with your class name -``` - - - ```ts diff --git a/docs/weaviate/api/graphql/additional-operators.md b/docs/weaviate/api/graphql/additional-operators.md index 6361b859..ee33e1ae 100644 --- a/docs/weaviate/api/graphql/additional-operators.md +++ b/docs/weaviate/api/graphql/additional-operators.md @@ -171,14 +171,6 @@ Sample client code: /> - - - - - - - - - - - - -## Migration guides - -:::tip Migrating from `v3` to `v4` -If you are migrating from the `v3` client to the `v4`, see this [dedicated guide](./v3_v4_migration.md). -::: - ### Beta releases
diff --git a/docs/weaviate/client-libraries/python/python_v3.md b/docs/weaviate/client-libraries/python/python_v3.md deleted file mode 100644 index 4131bc4d..00000000 --- a/docs/weaviate/client-libraries/python/python_v3.md +++ /dev/null @@ -1,915 +0,0 @@ ---- -title: "Legacy (v3) API (DEPRECATED)" -sidebar_position: 80 -image: og/docs/client-libraries.jpg -# tags: ['python', 'client library'] ---- - -:::caution `v3` client is deprecated -This document relates to the legacy `v3` client and API. -
- -From `v4.10.0`, the [Weaviate Python client installations](https://pypi.org/project/weaviate-client/) no longer include the `v3` API (i.e. the `weaviate.Client` class). This separation helps us to provide the best developer experience for you and provide support for the latest Weaviate features. -
- -The `v3` client will continue to get critical security updates and bugfixes for the foreseeable future, but it will not support any new features. -
- -**What does this mean for me?** -
- -To take advantage of the latest developments on the Weaviate Database, we recommend migrating your codebase to use the [`v4` client API](./index.md). -
- -Our documentation includes [a migration guide here](./v3_v4_migration.md), and many code examples include both `v3` and `v4` syntax. We will be adding more dedicated resources for you to ease the migration experience. -
- -If you have an existing codebase and Weaviate Database that you expect to remain static, we recommend pinning the version in your requirements file (e.g. `requirements.txt`), like so: - -```bash - weaviate-client>=3.26.7,<4.0.0 -``` - -We appreciate that code migration can be cumbersome, but we feel strongly that the end experience and feature set will make your time worthwhile. -
- -If you have specific requests for migration documentation or resources, please reach out through [our GitHub repository](https://github.com/weaviate/docs/issues). -::: - -## Installation and setup - -### Requirements - -The `v3` client is not to be used with with the gRPC API that was introduced in Weaviate `1.22`. You can still use Weaviate `1.22` and newer with the `v3` client, however it will not take advantage of improvements made with the gRPC API. For the gRPC API, use the `v4` client. - -### Installation - -The `v3` Python library is available on [PyPI.org](https://pypi.org/project/weaviate-client/). The package can be installed using [pip](https://pypi.org/project/pip/). The client is developed and tested for Python 3.7 and higher. - -```bash -pip install "weaviate-client==3.*" -``` - -### Set-up - -Now you can use the client in your Python scripts as follows: - -```python -import weaviate - -client = weaviate.Client("https://WEAVIATE_INSTANCE_URL") # Replace WEAVIATE_INSTANCE_URL with your instance URL. - -assert client.is_ready() # Will return True if the client is connected & the server is ready to accept requests -``` - -Or, with additional arguments such as those below: - -```python -import weaviate - -client = weaviate.Client( - url="https://WEAVIATE_INSTANCE_URL", # URL of your Weaviate instance - auth_client_secret=auth_config, # (Optional) If the Weaviate instance requires authentication - timeout_config=(5, 15), # (Optional) Set connection timeout & read timeout time in seconds - additional_headers={ # (Optional) Any additional headers; e.g. keys for API inference services - "X-Cohere-Api-Key": "YOUR-COHERE-API-KEY", # Replace with your Cohere key - "X-HuggingFace-Api-Key": "YOUR-HUGGINGFACE-API-KEY", # Replace with your Hugging Face key - "X-OpenAI-Api-Key": "YOUR-OPENAI-API-KEY", # Replace with your OpenAI key - } -) - -assert client.is_ready() # Will return True if the client is connected & the server is ready to accept requests -``` - -## Authentication - -import ClientAuthIntro from '/docs/weaviate/client-libraries/_components/client.auth.introduction.mdx' - - - -### WCD authentication - -import ClientAuthWCD from '/docs/weaviate/client-libraries/_components/client.auth.wcs.mdx' - - - -### API key authentication - -:::info Added in Weaviate Python client version `3.14.0`. -::: - -import ClientAuthApiKey from '/docs/weaviate/client-libraries/_components/client.auth.api.key.mdx' - - - -```python -import weaviate - -auth_config = weaviate.auth.AuthApiKey(api_key="YOUR-WEAVIATE-API-KEY") # Replace with your Weaviate instance API key - -# Instantiate the client with the auth config -client = weaviate.Client( - url="https://WEAVIATE_INSTANCE_URL", # Replace with your Weaviate endpoint - auth_client_secret=auth_config -) -``` - -### OIDC authentication - -import ClientAuthOIDCIntro from '/docs/weaviate/client-libraries/_components/client.auth.oidc.introduction.mdx' - - - -#### Resource Owner Password Flow - -import ClientAuthFlowResourceOwnerPassword from '/docs/weaviate/client-libraries/_components/client.auth.flow.resource.owner.password.mdx' - - - -```python -import weaviate - -resource_owner_config = weaviate.AuthClientPassword( - username = "user", - password = "pass", - scope = "offline_access" # optional, depends on the configuration of your identity provider (not required with WCD) - ) - -# Initiate the client with the auth config -client = weaviate.Client("http://localhost:8080", auth_client_secret=resource_owner_config) -``` - -#### Client Credentials flow - -import ClientAuthFlowClientCredentials from '/docs/weaviate/client-libraries/_components/client.auth.flow.client.credentials.mdx' - - - -```python -import weaviate - -client_credentials_config = weaviate.AuthClientCredentials( - client_secret = "client_secret", - scope = "scope1 scope2" # optional, depends on the configuration of your identity provider (not required with WCD) - ) - -# Initiate the client with the auth config -client = weaviate.Client("https://localhost:8080", auth_client_secret=client_credentials_config) -``` - -#### Refresh Token flow - -import ClientAuthBearerToken from '/docs/weaviate/client-libraries/_components/client.auth.bearer.token.mdx' - - - -```python -import weaviate - -bearer_config = weaviate.AuthBearerToken( - access_token="some token" - expires_in=300 # in seconds, by default 60s - refresh_token="other token" # Optional -) - -# Initiate the client with the auth config -client = weaviate.Client("https://localhost:8080", auth_client_secret=bearer_config) -``` - -## Custom headers - -You can pass custom headers to the client, which are added at initialization: - -```python -client = weaviate.Client( - url="https://localhost:8080", - additional_headers={"HeaderKey": "HeaderValue"}, -) -``` - -## Neural Search Frameworks - -There is a variety of neural search frameworks that use Weaviate under the hood to store, search through, and retrieve vectors. - -- deepset's [haystack](https://www.deepset.ai/weaviate-vector-search-engine-integration) -- Jina's [DocArray](https://github.com/docarray/docarray) - -# References documentation - -On this Weaviate documentation website, you will find how to use the Python client for all [RESTful endpoints](/docs/weaviate/api/rest) and [GraphQL functions](../../api/graphql/index.md). For each reference, a code block is included with an example of how to use the function with the Python (and other) clients. The Python client, however, has additional functionalities, which are covered in the full client documentation on [weaviate-python-client.readthedocs.io](https://weaviate-python-client.readthedocs.io/en/stable/). Some of these additional functions are highlighted here below. - -### Example: client.schema.create(schema) -Instead of adding classes one by one using the RESTful `v1/schema` endpoint, you can upload a full schema in JSON format at once using the Python client. Use the function `client.schema.create(schema)` as follows: - -```python -import weaviate - -client = weaviate.Client("http://localhost:8080") - -schema = { - "classes": [{ - "class": "Publication", - "description": "A publication with an online source", - "properties": [ - { - "dataType": [ - "text" - ], - "description": "Name of the publication", - "name": "name" - }, - { - "dataType": [ - "Article" - ], - "description": "The articles this publication has", - "name": "hasArticles" - }, - { - "dataType": [ - "geoCoordinates" - ], - "description": "Geo location of the HQ", - "name": "headquartersGeoLocation" - } - ] - }, { - "class": "Article", - "description": "A written text, for example a news article or blog post", - "properties": [ - { - "dataType": [ - "text" - ], - "description": "Title of the article", - "name": "title" - }, - { - "dataType": [ - "text" - ], - "description": "The content of the article", - "name": "content" - } - ] - }, { - "class": "Author", - "description": "The writer of an article", - "properties": [ - { - "dataType": [ - "text" - ], - "description": "Name of the author", - "name": "name" - }, - { - "dataType": [ - "Article" - ], - "description": "Articles this author wrote", - "name": "wroteArticles" - }, - { - "dataType": [ - "Publication" - ], - "description": "The publication this author writes for", - "name": "writesFor" - } - ] - }] -} - -client.schema.create(schema) -``` - -## Batching - -Batching is a way of importing/creating `objects` and `references` in bulk using a single API request to the Weaviate server. With Python this can be done using 3 different methods: - -1. ***Auto-batching*** -2. ***Dynamic-batching*** -3. ***Manual-batching*** - -Generally, we recommend use of `client.batch` in a context manager, which will automatically flush the batch when exiting. This is the easiest way to use the batching functionality. - -The following parameters have the greatest impact on the batch import speed: - -| Parameter | Type | Recommended
value | Purpose | -| :- | :- | :- |:- | -| `batch_size` | integer | 50 - 200 | Initial batch size -| `num_workers` | integer | 1 - 2 | Maximum number of parallel workers -| `dynamic` | boolean | True | If true, dynamically adjust the `batch_size`
based on the number of items in the batch - -### Multi-threading batch import - -:::info Added in Weaviate Python client version `3.9.0`. -::: - -Multi-threading Batch import works with both `Auto-batching` and `Dynamic-batching`. - -To use it, set the number of workers (threads) using the `.configure(...)` (same as `.__call__(...)`) by setting the argument `num_workers` in the batch configuration. See also [Batch configuration](#batch-configuration) below. - -:::warning -Multithreading is disabled by default (num_workers=1). Use with care to not overload your Weaviate instance. -::: - -**Example** - -```python -client.batch( # or client.batch.configure( - batch_size=100, - dynamic=True, - num_workers=4, -) -``` - -### Auto-batching - -This method allows the Python client to handle all the `object` and `reference` import/creation. This means that you do NOT have to explicitly import/create objects and cross-references. All you need to do is add everything you want imported/created to the `Batch`, and the `Batch` is going to take care of creating the objects and cross-references among them. To enable auto-batching we need to configure `batch_size` to be a positive integer (by default `None`) (see [Batch configuration](#batch-configuration) below for more information). The `Batch` is going to import/create objects, then create cross-references, if the number of objects + number of references == `batch_size`. See example below: - -```python -import weaviate -from weaviate.util import generate_uuid5 -client = weaviate.Client("http://localhost:8080") - -# create schema -schema = { - "classes": [ - { - "class": "Author", - "properties": [ - { - "name": "name", - "dataType": ["text"] - }, - { - "name": "wroteBooks", - "dataType": ["Book"] - } - ] - }, - { - "class": "Book", - "properties": [ - { - "name": "title", - "dataType": ["text"] - }, - { - "name": "ofAuthor", - "dataType": ["Author"] - } - ] - } - ] -} - -client.schema.create(schema) - -author = { - "name": "Jane Doe", -} -book_1 = { - "title": "Jane's Book 1" -} -book_2 = { - "title": "Jane's Book 2" -} - -client.batch.configure( - batch_size=5, # int value for batch_size enables auto-batching, see Batch configuration section below -) - -with client.batch as batch: - # add author - uuid_author = generate_uuid5(author, "Author") - batch.add_data_object( - data_object=author, - class_name="Author", - uuid=uuid_author, - ) - # add book_1 - uuid_book_1 = generate_uuid5(book_1, "Book") - batch.add_data_object( - data_object=book_1, - class_name="Book", - uuid=uuid_book_1, - ) - # add references author ---> book_1 - batch.add_reference( - from_object_uuid=uuid_author, - from_object_class_name="Author", - from_property_name="wroteBooks", - to_object_uuid=uuid_book_1, - to_object_class_name="Book", - ) - # add references author <--- book_1 - batch.add_reference( - from_object_uuid=uuid_book_1, - from_object_class_name="Book", - from_property_name="ofAuthor", - to_object_uuid=uuid_author, - to_object_class_name="Author", - ) - # add book_2 - uuid_book_2 = generate_uuid5(book_2, "Book") - batch.add_data_object( - data_object=book_2, - class_name="Book", - uuid=uuid_book_2, - ) - # add references author ---> book_2 - batch.add_reference( - from_object_uuid=uuid_author, - from_object_class_name="Author", - from_property_name="wroteBooks", - to_object_uuid=uuid_book_2, - to_object_class_name="Book", - ) - # add references author <--- book_2 - batch.add_reference( - from_object_uuid=uuid_book_2, - from_object_class_name="Book", - from_property_name="ofAuthor", - to_object_uuid=uuid_author, - to_object_class_name="Author", - ) - -# NOTE: When exiting context manager the method `batch.flush()` is called -# done, everything is imported/created -``` - -### Dynamic-batching - -This method allows the Python client to handle all object and cross-reference import/creations in a dynamic manner. This means that the user does NOT have to explicitly import/create objects and cross-reference (same as with [Auto-batching](#auto-batching). To enable dynamic-batching we need to configure `batch_size` to be a positive integer (by default `None`) AND set `dynamic` to `True` (by default `False`) (see [Batch-configuration](#batch-configuration) below for more information). For this method the `Batch` is going to compute the `recommended_num_objects` and `recommended_num_references` after the first `Batch` creation, where the `batch_size` is used for `recommended_num_objects` and `recommended_num_references` as the initial value. The `Batch` is going to import/create objects then references, if current number of objects reached `recommended_num_objects` OR current number of reference reached `recommended_num_references`. See example below: - - -```python -import weaviate -from weaviate.util import generate_uuid5 -client = weaviate.Client("http://localhost:8080") - -# create schema -schema = { - "classes": [ - { - "class": "Author", - "properties": [ - { - "name": "name", - "dataType": ["text"] - }, - { - "name": "wroteBooks", - "dataType": ["Book"] - } - ] - }, - { - "class": "Book", - "properties": [ - { - "name": "title", - "dataType": ["text"] - }, - { - "name": "ofAuthor", - "dataType": ["Author"] - } - ] - } - ] -} - -client.schema.create(schema) - -author = { - "name": "Jane Doe", -} -book_1 = { - "title": "Jane's Book 1" -} -book_2 = { - "title": "Jane's Book 2" -} - -client.batch.configure( - batch_size=5, # int value for batch_size enables auto-batching, see Batch configuration section below - dynamic=True, # makes it dynamic -) - -with client.batch as batch: - # add author - uuid_author = generate_uuid5(author, "Author") - batch.add_data_object( - data_object=author, - class_name="Author", - uuid=uuid_author, - ) - # add book_1 - uuid_book_1 = generate_uuid5(book_1, "Book") - batch.add_data_object( - data_object=book_1, - class_name="Book", - uuid=uuid_book_1, - ) - # add references author ---> book_1 - batch.add_reference( - from_object_uuid=uuid_author, - from_object_class_name="Author", - from_property_name="wroteBooks", - to_object_uuid=uuid_book_1, - to_object_class_name="Book", - ) - # add references author <--- book_1 - batch.add_reference( - from_object_uuid=uuid_book_1, - from_object_class_name="Book", - from_property_name="ofAuthor", - to_object_uuid=uuid_author, - to_object_class_name="Author", - ) - # add book_2 - uuid_book_2 = generate_uuid5(book_2, "Book") - batch.add_data_object( - data_object=book_2, - class_name="Book", - uuid=uuid_book_2, - ) - # add references author ---> book_2 - batch.add_reference( - from_object_uuid=uuid_author, - from_object_class_name="Author", - from_property_name="wroteBooks", - to_object_uuid=uuid_book_2, - to_object_class_name="Book", - ) - # add references author <--- book_2 - batch.add_reference( - from_object_uuid=uuid_book_2, - from_object_class_name="Book", - from_property_name="ofAuthor", - to_object_uuid=uuid_author, - to_object_class_name="Author", - ) -# NOTE: When exiting context manager the method `batch.flush()` is called -# done, everything is imported/created -``` - -### Manual-batching - -This method gives the user total control over the `Batch`, meaning the `Batch` is NOT going to perform any import/creation implicitly but will leave it to the user's discretion. See example below: - - -```python -import weaviate -from weaviate.util import generate_uuid5 -client = weaviate.Client("http://localhost:8080") - -# create schema -schema = { - "classes": [ - { - "class": "Author", - "properties": [ - { - "name": "name", - "dataType": ["text"] - }, - { - "name": "wroteBooks", - "dataType": ["Book"] - } - ] - }, - { - "class": "Book", - "properties": [ - { - "name": "title", - "dataType": ["text"] - }, - { - "name": "ofAuthor", - "dataType": ["Author"] - } - ] - } - ] -} - -client.schema.create(schema) - -author = { - "name": "Jane Doe", -} -book_1 = { - "title": "Jane's Book 1" -} -book_2 = { - "title": "Jane's Book 2" -} - -client.batch.configure( - batch_size=None, # None disable any automatic functionality -) - -with client.batch as batch: - # add author - uuid_author = generate_uuid5(author, "Author") - batch.add_data_object( - data_object=author, - class_name="Author", - uuid=uuid_author, - ) - # add book_1 - uuid_book_1 = generate_uuid5(book_1, "Book") - batch.add_data_object( - data_object=book_1, - class_name="Book", - uuid=uuid_book_1, - ) - result = batch.create_objects() # <----- implicit object creation - - # add references author ---> book_1 - batch.add_reference( - from_object_uuid=uuid_author, - from_object_class_name="Author", - from_property_name="wroteBooks", - to_object_uuid=uuid_book_1, - to_object_class_name="Book", - ) - # add references author <--- book_1 - batch.add_reference( - from_object_uuid=uuid_book_1, - from_object_class_name="Book", - from_property_name="ofAuthor", - to_object_uuid=uuid_author, - to_object_class_name="Author", - ) - result = batch.create_references() # <----- implicit reference creation - - - # add book_2 - uuid_book_2 = generate_uuid5(book_2, "Book") - batch.add_data_object( - data_object=book_2, - class_name="Book", - uuid=uuid_book_2, - ) - result = batch.create_objects() # <----- implicit object creation - - # add references author ---> book_2 - batch.add_reference( - from_object_uuid=uuid_author, - from_object_class_name="Author", - from_property_name="wroteBooks", - to_object_uuid=uuid_book_2, - to_object_class_name="Book", - ) - # add references author <--- book_2 - batch.add_reference( - from_object_uuid=uuid_book_2, - from_object_class_name="Book", - from_property_name="ofAuthor", - to_object_uuid=uuid_author, - to_object_class_name="Author", - ) - result = batch.create_references() # <----- implicit reference creation - -# NOTE: When exiting context manager the method `batch.flush()` is called -# done, everything is imported/created -``` - -### Batch configuration -The `Batch` object can be configured using the `batch.configure()` method or the `batch()` (i.e. call batch object, `__call__`) method. They are the same function. In the examples above we saw that we can configure the `batch_size` and `dynamic` parameters. Here are more available parameters: - -- `batch_size` - (`int` or `None`: default `None`): If it is `int` then auto-/dynamic-batching is enabled. For Auto-batching, if number of objects + number of references == `batch_size` then the `Batch` is going to import/create current objects then references (see [Auto-batching](#auto-batching) for more info). For Dynamic-batching it is used as the initial value for `recommended_num_objects` and `recommended_num_references` (see [Dynamic batching](#dynamic-batching) for more info). A value of `None` means it is Manual-batching—no automatic object/reference import/creation. -- `dynamic` - (`bool`, default: `False`): Enables/disables Dynamic-batching. Does not have any effect if `batch_size` is `None`. -- `creation_time` - (`int` or `float`, default: `10`): It is the interval of time in which the batch import/create should be done. It used to compute `recommended_num_objects` and `recommended_num_references`, consequently has an impact for Dynamic-batching. -- `callback` (Optional[Callable[[dict], None]], default `weaviate.util.check_batch_result`): It is a callback function on the results of the `batch.create_objects()` and `batch.create_references()`. It is used for error handling for Auto-/Dynamic-batching. Has no effect if `batch_size` is `None`. -- `timeout_retries` - (`int`, default `3`): Number of attempts to import/create a batch before resulting in `TimeoutError`. -- `connection_error_retries` - (`int`, default `3`): Number of attempts to import/create a batch before resulting in `ConnectionError`. **NOTE:** Added in `weaviate-client 3.9.0`. -- `num_workers` - (`int`, default `1`): The maximal number of concurrent threads to run batch import. Only used for non-MANUAL batching. i.e. is used only with AUTO or DYNAMIC batching. ***Use with care to not overload your Weaviate instance.*** **NOTE:** Added in `weaviate-client 3.9.0`. - -NOTE: You have to specify all the configurations that you want at each call of this method, otherwise some setting are going to be replaced by default values. -```python -client.batch( - batch_size=100, - dynamic=False, - creation_time=5, - timeout_retries=3, - connection_error_retries=5, - callback=None, - num_workers=1, -) -``` - -### Tips & Tricks - -* There is no limit to how many objects/references one could add to a batch before committing/creating it. However a too large batch can lead to a TimeOut error, which means that Weaviate could not process and create all the objects from the batch in the specified time (the timeout configuration can be set like [this](https://weaviate-python-client.readthedocs.io/en/latest/weaviate.html#weaviate.Client) or [this](https://weaviate-python-client.readthedocs.io/en/latest/weaviate.html#weaviate.Client.timeout_config)). Note that setting a timeout configuration higher that 60s would require some changes to the docker-compose.yml/helm chart file. -* The `batch` class in the Python Client can be used in three ways: - * Case 1: Everything should be done by the user, i.e. the user should add the objects/object-references and create them whenever the user wants. To create one of the data type use these methods of this class: `create_objects`, `create_references` and `flush`. This case has the Batch instance's batch_size set to None (see docs for the `configure` or `__call__` method). Can be used in a context manager, see below. - * Case 2: Batch auto-creates when full. This can be achieved by setting the Batch instance's batch_size set to a positive integer (see docs for the `configure` or `__call__` method). The batch_size in this case corresponds to the sum of added objects and references. This case does not require the user to create the batch/s, but it can be done. Also to create non-full batches (last batches) that do not meet the requirement to be auto-created use the `flush` method. Can be used in a context manager, see below. - * Case 3: Similar to Case II but uses dynamic batching, i.e. auto-creates either objects or references when one of them reached the `recommended_num_objects` or `recommended_num_references` respectively. See docs for the `configure` or `__call__` method for how to enable it. - * **Context-manager support**: Can be use with the with statement. When it exists the context-manager it calls the flush method for you. Can be combined with `configure` or `__call__` method, in order to set it to the desired Case. - -### Error Handling - -Creating objects in `Batch` is faster then creating each object/reference individually but it comes at the cost of skipping some validation steps. Skipping some validation steps at object/reference level can result in some objects that failed to create or some references that could not be added. In this case the `Batch` does not fail but individual objects/references might and we can make sure that everything was imported/created without errors by checking the returned value of the `batch.create_objects()` and `batch.create_references()`. Here are examples how to catch and handle errors on individual `Batch` objects/references. - -Lets define a function that checks for such errors and prints them: -```python -def check_batch_result(results: dict): - """ - Check batch results for errors. - - Parameters - ---------- - results : dict - The Weaviate batch creation return value. - """ - - if results is not None: - for result in results: - if "result" in result and "errors" in result["result"]: - if "error" in result["result"]["errors"]: - print(result["result"]) -``` - -Now we can use this function to print the error messages at item (object/reference) level. Lets look how we can do it using Auto-/Dynamic-batching where we never implicitly call the `create` methods: - -```python -client.batch( - batch_size=100, - dynamic=True, - creation_time=5, - timeout_retries=3, - connection_error_retries=3, - callback=check_batch_result, -) - -# done, easy as that -``` - -For Manual-batching we can call the function on the returned value: -```python -# on objects -result = client.batch.create_object() -check_batch_result(result) - -# on references -result = client.batch.create_references() -check_batch_result(result) -``` - - -
- Example code - -The following Python code can be used to handle errors on individual data objects in the batch. - -```python -import weaviate - -client = weaviate.Client("http://localhost:8080") - -def check_batch_result(results: dict): - """ - Check batch results for errors. - - Parameters - ---------- - results : dict - The Weaviate batch creation return value, i.e. returned value of the client.batch.create_objects(). - """ - if results is not None: - for result in results: - if 'result' in result and 'errors' in result['result']: - if 'error' in result['result']['errors']: - print("We got an error!", result) - -object_to_add = { - "name": "Jane Doe", - "writesFor": [{ - "beacon": "weaviate://localhost/f81bfe5e-16ba-4615-a516-46c2ae2e5a80" - }] -} - -client.batch.configure( - # `batch_size` takes an `int` value to enable auto-batching - # (`None` is used for manual batching) - batch_size=100, - # dynamically update the `batch_size` based on import speed - dynamic=False, - # `timeout_retries` takes an `int` value to retry on time outs - timeout_retries=3, - # checks for batch-item creation errors - # this is the default in weaviate-client >= 3.6.0 - callback=check_batch_result, - consistency_level=weaviate.data.replication.ConsistencyLevel.ALL, # default QUORUM -) - -with client.batch as batch: - batch.add_data_object(object_to_add, "Author", "36ddd591-2dee-4e7e-a3cc-eb86d30a4303", vector=[1,2]) - # lets force an error, adding a second object with unmatching vector dimensions - batch.add_data_object(object_to_add, "Author", "cb7d0da4-ceaa-42d0-a483-282f545deed7", vector=[1,2,3]) -``` - -This can also be applied to adding references in batch. Note that sending batches, especially references, skips some validations at the object and reference level. Adding this validation on single data objects like above makes it less likely for errors to go undiscovered. - -
- - -## Design - -### GraphQL query builder pattern - -For complex GraphQL queries (e.g. with filters), the client uses a builder pattern to form the queries. An example is the following query with multiple filters: - -```python -import weaviate -client = weaviate.Client("http://localhost:8080") - -where_filter = { - "path": ["wordCount"], - "operator": "GreaterThan", - "valueInt": 1000 -} - -near_text_filter = { - "concepts": ["fashion"], - "certainty": 0.7, - "moveAwayFrom": { - "concepts": ["finance"], - "force": 0.45 - }, - "moveTo": { - "concepts": ["haute couture"], - "force": 0.85 - } -} - -query_result = client.query\ - .get("Article", ["title"])\ - .with_where(where_filter)\ - .with_near_text(near_text_filter)\ - .with_limit(50)\ - .do() - -print(query_result) -``` - -Note that you need to use the `.do()` method to execute the query. - -:::tip -You can use `.build()` to inspect the resulting GraphQL query -::: - -```python -query_result = client.query\ - .get("Article", ["title"])\ - .with_where(where_filter)\ - .with_near_text(near_text_filter)\ - .with_limit(50) - -query_result.build() - ->>> '{Get{Article(where: {path: ["wordCount"] operator: GreaterThan valueInt: 1000} limit: 50 nearText: {concepts: ["fashion"] certainty: 0.7 moveTo: {force: 0.85 concepts: ["haute couture"]} moveAwayFrom: {force: 0.45 concepts: ["finance"]}} ){title}}}' - -``` - -## Best practices and notes - -### Thread-safety - -While the Python client is fundamentally designed to be thread-safe, it's important to note that due to its dependency on the `requests` library, complete thread safety isn't guaranteed. - -This is an area that we are looking to improve in the future. - -:::warning Thread safety -The batching algorithm in our client is not thread-safe. Keep this in mind to help ensure smoother, more predictable operations when using our Python client in multi-threaded environments. -::: - -If you are performing batching in a multi-threaded scenario, ensure that only one of the threads is performing the batching workflow at any given time. No two threads can use the same `client.batch` object at one time. - -## Releases - -Go to the [GitHub releases page](https://github.com/weaviate/weaviate-python-client/releases) to see the history of the Python client library releases. - -
- Click here for a table of Weaviate and corresponding client versions - -import ReleaseHistory from '/_includes/release-history.md'; - - - -
- -## Questions and feedback - -import DocsFeedback from '/_includes/docs-feedback.mdx'; - - diff --git a/docs/weaviate/client-libraries/python/v3_v4_migration.md b/docs/weaviate/client-libraries/python/v3_v4_migration.md deleted file mode 100644 index 004a302a..00000000 --- a/docs/weaviate/client-libraries/python/v3_v4_migration.md +++ /dev/null @@ -1,277 +0,0 @@ ---- -title: Migrate from v3 to v4 -sidebar_position: 50 -image: og/docs/client-libraries.jpg -# tags: ['python', 'client library'] ---- - -import Tabs from '@theme/Tabs'; -import TabItem from '@theme/TabItem'; -import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; -import PythonCode from '!!raw-loader!/_includes/code/client-libraries/python_v4.py'; - -:::note Python client version -The current Python client version is `v||site.python_client_version||` -::: - -The `v4` Weaviate Python client API is a complete rewrite, aimed at an improved overall user experience. It is therefore also very different to the `v3` API, and will require re-learning of changed patterns in the way you interact with Weaviate. - -While this may introduce some overhead, we believe the `v4` API is a significant improvement to your developer experience. For instance, using the `v4` client will allow you to take full advantage faster speeds through the gRPC API, and additional static analysis for IDE assistance through strong typing. - -Due to the extensive API surface changes, this guide does not cover every change. Instead, this guide is designed to help you understand the major changes and how to migrate your code at a high level. - -For code examples, refer to the documentation throughout the site, [starting with these suggested sections](#how-to-migrate-your-code). - -## Installation - -To go from `v3` to `v4`, you must - -1. Upgrade the client library: - - ```bash - pip install -U weaviate-client - ``` - -2. Upgrade Weaviate to a compatible version. Each minor Python client version is closely tied to a minor Weaviate version. - - For example, Weaviate `v1.27.x` were developed together with `v4.9.x` of the Python client. - - Generally, we recommend you use the latest versions of Weaviate and the client. You can find the version compatibility matrix in the [release notes](../../release-notes/index.md#weaviate-core-and-client-releases) - -3. Make sure a port for gRPC is open to Weaviate. - - The default port is 50051. - -
- docker-compose.yml example - - If you are running Weaviate with Docker, you can map the default port (`50051`) by adding the following to your `docker-compose.yml` file: - - ```yaml - ports: - - 8080:8080 - - 50051:50051 - ``` - -
- -## Instantiate a client - -The `v4` client is instantiated by the `WeaviateClient` object. The `WeaviateClient` object is the main entry point for all API operations. - -You can instantiate the `WeaviateClient` object directly. However, in most cases it is easier to use a connection helper function such as `connect_to_local` or `connect_to_weaviate_cloud`. - - - - - - -To configure connection timeout values, see [Timeout values](/docs/weaviate/client-libraries/python#timeout-values). - - - - - - - - - - - - - - - - - - - -The `v3` API style `Client` object is [still available](./index.md#legacy-v3-api), and will be deprecated in the future. - -## Major changes - -The `v4` client API is very different from the `v3` API. Major user-facing changes in the `v4` client include: - -- Extensive use of helper classes -- Interaction with collections -- Removal of builder patterns - -### Helper classes - -The `v4` client makes extensive use of helper classes. These classes provide strong typing and thus static type checking. It also makes coding easier through your IDE's auto-completion feature. - -When you are coding, check the auto-complete frequently. It provides useful guidance for API changes and client options. - -import QuickStartCode from '!!raw-loader!/_includes/code/graphql.filters.nearText.generic.py'; - - - - - - - - - - - - - - -The `wvc` namespace exposes commonly used classes in the `v4` API. The namespace is divided further into [submodules based on their primary purpose](./index.md#helper-classes). - - - -### Interact with collections - -When you connect to a Weaviate Database, the v4 API returns a `WeaviateClient` object, while the v3 API returns a `Client` object. - -The `v3` API's interactions were built around the `client` object (an instance of `Client`). This includes server interactions for CRUD and search operations. - -In the `v4` API, the main starting points for your interaction with Weaviate follow a different paradigm. - -Server-level interactions such as checking readiness (`client.is_ready()`) or getting node statuses (`client.cluster.nodes()`) still remain with `client` (now an instance of `WeaviateClient`). - -CRUD and search operations are now performed against a `Collection` object to reflect that these operations target a particular collection. - -This example below shows a function with a `Collection` typing hint). - - - -The collection object includes its name as an attribute. Accordingly, operations such as a `near_text` query can be performed without specifying the collection name. The `v4` collection object has a more focussed namespace in comparison to the breadth of operations available with the `v3` client object. This simplifies your code and reduces the potential for errors. - -import ManageDataCode from '!!raw-loader!/_includes/code/howto/manage-data.read.py'; -import ManageDataCodeV3 from '!!raw-loader!/_includes/code/howto/manage-data.read-v3.py'; - - - - - - - - - - - -### Terminology changes (e.g. class -> collection) - -Some of the terms within the Weaviate ecosystem are changing, and the client has changed accordingly: - -- A Weaviate "Class" is now called a "Collection". A collection stores a set of data objects together with their vector embeddings. -- A "Schema" is now called a "Collection Configuration", a set of settings that define collection name, vectorizers, index configurations, property definitions, and so on. - -Due to the architectural changes as well as changes to the terminology, most of the API has been changed. Expect to find differences in the way you interact with Weaviate. - -For example, `client.collections.list_all()` is the replacement for `client.schema.get()`. - -[Manage data](../../manage-data/index.md) has more details and additional sample code for working with data, such as [working with collections](../../manage-data/collections.mdx). See [searches](../../search/index.md) for further details on various queries and filters. - -### Collection creation from JSON - -You can still create a collection from a JSON definition. This may be a useful way to migrate your existing data, for example. You could [fetch an existing definition](../../manage-data/collections.mdx#read-a-single-collection-definition) and then use it to create a new collection. - - - -### Removal of builder patterns - -The builder patterns for constructing queries have been removed. Builder patterns could be confusing, and led to runtime errors that could not be picked up with static analysis. - -Instead, construct queries in the `v4` API using specific methods and its parameters. - -import SearchSimilarityCode from '!!raw-loader!/_includes/code/howto/search.similarity.py'; -import SearchSimilarityCodeV3 from '!!raw-loader!/_includes/code/howto/search.similarity-v3.py'; - - - - - - - - - - - -Additionally, many arguments are now constructed using helper classes (e.g. `MetadataQuery` or `Filter`) which makes it easier to use and reduces errors through IDE assistance and static analysis. - -## How to migrate your code - -The migration will likely involve significant changes to your codebase. Review the [Python client library documentation](./index.md) to get started, including instantiation details and various submodules. - -Then, take a look at the how-to guides for [Managing data](../../manage-data/index.md) and [Queries](../../search/index.md). - -In particular, check out the pages for: - -- [Client instantiation](./index.md#instantiate-a-client), -- [Manage collections](../../manage-data/collections.mdx), -- [Batch import](../../manage-data/import.mdx) -- [Cross-reference](../../manage-data/cross-references.mdx) -- [Basic search](../../search/basics.md) -- [Similarity search](../../search/similarity.md) -- [Filters](../../search/filters.md) - -## Questions and feedback - -import DocsFeedback from '/_includes/docs-feedback.mdx'; - - diff --git a/docs/weaviate/configuration/backups.md b/docs/weaviate/configuration/backups.md index 9c8a8506..107e7bfc 100644 --- a/docs/weaviate/configuration/backups.md +++ b/docs/weaviate/configuration/backups.md @@ -9,7 +9,6 @@ import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; import PyCode from '!!raw-loader!/_includes/code/howto/configure.backups.py'; -import PyCodeV3 from '!!raw-loader!/_includes/code/howto/configure.backups-v3.py'; import TSCodeBackup from '!!raw-loader!/_includes/code/howto/configure.backups.backup.ts'; import TSCodeRestore from '!!raw-loader!/_includes/code/howto/configure.backups.restore.ts'; import TSCodeStatus from '!!raw-loader!/_includes/code/howto/configure.backups.status.ts'; @@ -62,15 +61,6 @@ Restart Weaviate to apply the new configuration. Then, you are ready to start a /> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -73,14 +64,6 @@ To tune SQ, set these `vectorIndexConfig` parameters. /> - - - ## Multiple vector embeddings (named vectors) diff --git a/docs/weaviate/connections/connect-cloud.mdx b/docs/weaviate/connections/connect-cloud.mdx index 05f3dc18..196eafe6 100644 --- a/docs/weaviate/connections/connect-cloud.mdx +++ b/docs/weaviate/connections/connect-cloud.mdx @@ -9,7 +9,6 @@ import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; -import PyCodeV3 from '!!raw-loader!/_includes/code/connections/connect-python-v3.py'; import PyCodeV4 from '!!raw-loader!/_includes/code/connections/connect-python-v4.py'; import TsCodeV3 from '!!raw-loader!/_includes/code/connections/connect-ts-v3.ts'; import TsCodeV2 from '!!raw-loader!/_includes/code/connections/connect-ts-v2.ts'; @@ -40,14 +39,6 @@ To connect, use the Weaviate URL and the Weaviate API key for your WCD instance language="py" /> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - import XrefPyCode from '!!raw-loader!/_includes/code/howto/manage-data.cross-refs.py'; -import XrefPyCodeV3 from '!!raw-loader!/_includes/code/howto/manage-data.cross-refs-v3.py'; import XrefTSCode from '!!raw-loader!/_includes/code/howto/manage-data.cross-refs'; import XrefTSCodeLegacy from '!!raw-loader!/_includes/code/howto/manage-data.cross-refs-v2'; @@ -363,14 +321,6 @@ You can create an object with cross-references to other objects. /> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

- The migrate_data_from_weaviate_to_weaviate function is called to migrate the data. -

-

- -
- - - - - - - -

- The migrate_data_from_weaviate_to_weaviate function is called to migrate the data. -

-

- -
- - - - -

- The migrate_data_from_weaviate_to_weaviate function is called to migrate the data. -

-

- -
- - - - - - - -

- The migrate_data_from_weaviate_to_weaviate function is called to migrate the data. -

-

- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -219,14 +203,6 @@ You can group and nest filters. /> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -130,14 +122,6 @@ You can search by a base64 representation of an image: /> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
pip install -U weaviate-client ```
- - -```bash -pip install "weaviate-client==3.*" -``` - ```bash @@ -169,14 +162,6 @@ This [`nearVector`](/docs/weaviate/search/similarity#search-with-a-vector) query language="py" /> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ' + ) + + # We'll build the new content line by line + result_lines = [] + skip_mode = False + nesting_level = 0 + + # Process the file line by line + lines = file_content.split("\n") + for line in lines: + # Check if we're starting a Python Client v3 TabItem + if not skip_mode and start_pattern.search(line): + skip_mode = True + nesting_level = 1 + # Check if there's a closing tag on the same line + if "" in line: + nesting_level -= 1 + if nesting_level == 0: + skip_mode = False + continue + + # If we're in skip mode, check for nested tags + if skip_mode: + # Count opening tags (handle nested TabItems) + nesting_level += line.count("") + + # If nesting level is back to 0, we're done skipping + if nesting_level <= 0: + skip_mode = False + continue + + # If we're not skipping, add the line to the result + result_lines.append(line) + + return "\n".join(result_lines) + + +def process_directory(directory_path, file_extensions, dry_run=True): + """ + Process all files with given extensions in a directory and its subdirectories. + """ + directory = Path(directory_path) + files_processed = 0 + files_modified = 0 + + for ext in file_extensions: + for file_path in directory.glob(f"**/*{ext}"): + files_processed += 1 + + # Read the file content + with open(file_path, "r", encoding="utf-8") as file: + try: + content = file.read() + except UnicodeDecodeError: + print(f"Error reading {file_path}: UnicodeDecodeError") + continue + + # Process the content + new_content = remove_py3_tab_items(content) + + # If content was modified + if new_content != content: + files_modified += 1 + print(f"Modified: {file_path}") + + # Write the changes if not in dry-run mode + if not dry_run: + with open(file_path, "w", encoding="utf-8") as file: + file.write(new_content) + + return files_processed, files_modified + + +def main(): + parser = argparse.ArgumentParser( + description="Remove Python Client v3 TabItem blocks from files." + ) + parser.add_argument("directory", help="Directory to process") + parser.add_argument( + "--ext", + nargs="+", + default=[".md", ".mdx"], + help="File extensions to process (default: .md .mdx)", + ) + parser.add_argument( + "--apply", + action="store_true", + help="Apply changes (without this flag, runs in dry-run mode)", + ) + + args = parser.parse_args() + + print(f"Processing files in {args.directory}") + print(f"File extensions: {', '.join(args.ext)}") + print( + f"Mode: {'Apply Changes' if args.apply else 'Dry Run (no changes will be made)'}" + ) + + files_processed, files_modified = process_directory( + args.directory, args.ext, dry_run=not args.apply + ) + + print(f"\nSummary:") + print(f"Files processed: {files_processed}") + print(f"Files that would be modified: {files_modified}") + + if not args.apply and files_modified > 0: + print("\nRun with --apply to make the changes.") + + +if __name__ == "__main__": + main() From c43a05c6f49a9e3f6dca01f39bd6e995d1e030ab Mon Sep 17 00:00:00 2001 From: g-despot <66276597+g-despot@users.noreply.github.com> Date: Sun, 23 Mar 2025 14:36:04 +0100 Subject: [PATCH 2/2] Rename explicit v4 mentions --- .../configuration/replication-consistency.mdx | 2 +- _includes/code/connections/oidc-connect.mdx | 2 +- _includes/code/connections/timeouts-cloud.mdx | 2 +- .../code/connections/timeouts-custom.mdx | 2 +- _includes/code/connections/timeouts-local.mdx | 2 +- .../code/embedded.instantiate.custom.mdx | 2 +- _includes/code/embedded.instantiate.mdx | 2 +- .../code/embedded.instantiate.module.mdx | 2 +- _includes/code/graphql.aggregate.groupby.mdx | 2 +- .../code/graphql.aggregate.nearObject.mdx | 2 +- _includes/code/graphql.aggregate.nearText.mdx | 2 +- .../code/graphql.aggregate.nearVector.mdx | 2 +- _includes/code/graphql.aggregate.simple.mdx | 2 +- _includes/code/graphql.filters.after.mdx | 2 +- .../graphql.filters.bm25.filter.example.mdx | 2 +- _includes/code/graphql.filters.bm25.mdx | 2 +- _includes/code/graphql.filters.group.mdx | 2 +- .../graphql.filters.hybrid.filter.example.mdx | 2 +- _includes/code/graphql.filters.hybrid.mdx | 2 +- .../graphql.filters.hybrid.properties.mdx | 2 +- .../code/graphql.filters.hybrid.vector.mdx | 2 +- _includes/code/graphql.filters.limit.mdx | 2 +- _includes/code/graphql.filters.nearObject.mdx | 2 +- .../code/graphql.filters.nearText.2obj.mdx | 2 +- _includes/code/graphql.filters.nearText.mdx | 2 +- _includes/code/graphql.filters.nearVector.mdx | 2 +- _includes/code/graphql.filters.offset.mdx | 2 +- .../graphql.filters.where.beacon.count.mdx | 2 +- .../code/graphql.filters.where.beacon.mdx | 2 +- .../graphql.filters.where.geocoordinates.mdx | 2 +- _includes/code/graphql.filters.where.id.mdx | 2 +- _includes/code/graphql.filters.where.like.mdx | 2 +- .../code/graphql.filters.where.operands.mdx | 2 +- .../code/graphql.filters.where.simple.mdx | 2 +- .../code/graphql.filters.where.timestamps.mdx | 2 +- _includes/code/graphql.get.beacon.mdx | 2 +- _includes/code/graphql.get.consistency.mdx | 2 +- _includes/code/graphql.get.groupby.mdx | 2 +- _includes/code/graphql.get.multitenancy.mdx | 2 +- _includes/code/graphql.get.simple.mdx | 2 +- .../graphql.underscoreproperties.distance.mdx | 2 +- ...phql.underscoreproperties.semanticpath.mdx | 2 +- .../howto/manage-data.create.with.geo.mdx | 2 +- .../manage-data.read.check.existence.mdx | 2 +- .../code/howto/manage-data.shards.inspect.mdx | 2 +- .../code/howto/manage-data.shards.update.mdx | 2 +- _includes/code/meta.mdx | 2 +- _includes/code/nodes.mdx | 2 +- _includes/code/qna-transformers.ask.mdx | 2 +- _includes/code/quickstart.byov.schema.mdx | 2 +- ...uickstart.import.questions-and-vectors.mdx | 2 +- _includes/code/quickstart/connect.partial.mdx | 2 +- _includes/code/quickstart/import.mdx | 2 +- _includes/code/quickstart/neartext.mdx | 2 +- .../code/replication.get.object.by.id.mdx | 2 +- .../code/schema.things.create.replication.mdx | 2 +- .../code/schema.things.properties.add.mdx | 2 +- _includes/code/tutorial.schema.create.mdx | 2 +- .../code/tutorial.schema.index-settings.mdx | 2 +- .../code/tutorial.schema.multi-tenancy.mdx | 2 +- .../tutorial.schema.properties.options.mdx | 2 +- _includes/code/wcs.authentication.api.key.mdx | 2 +- ...hentication.api.key.with.inference.key.mdx | 2 +- _includes/code/wcs.without.authentication.mdx | 2 +- _includes/code/wellknown.live.mdx | 2 +- .../code/wellknown.openid-configuration.mdx | 2 +- _includes/code/wellknown.ready.mdx | 2 +- _includes/how.to.get.object.count.mdx | 2 +- _includes/schema-delete-class.mdx | 2 +- .../_core-1-24-include.mdx | 1 - docs/agents/query/tutorial-ecommerce.mdx | 24 +++++----- .../tutorial-enrich-dataset.mdx | 22 ++++----- docs/cloud/manage-clusters/connect.mdx | 4 +- .../api/graphql/additional-operators.md | 8 ++-- .../weaviate/client-libraries/python/index.md | 9 +--- docs/weaviate/config-refs/datatypes.md | 32 ++++++------- docs/weaviate/configuration/backups.md | 12 ++--- .../compression/bq-compression.md | 4 +- .../compression/pq-compression.md | 8 ++-- .../compression/sq-compression.md | 4 +- .../configuration/rbac/manage-roles-users.mdx | 38 +++++++-------- docs/weaviate/connections/connect-cloud.mdx | 4 +- docs/weaviate/connections/connect-custom.mdx | 2 +- .../weaviate/connections/connect-embedded.mdx | 2 +- docs/weaviate/connections/connect-local.mdx | 8 ++-- docs/weaviate/manage-data/collections.mdx | 46 +++++++++---------- docs/weaviate/manage-data/create.mdx | 14 +++--- .../weaviate/manage-data/cross-references.mdx | 24 +++++----- docs/weaviate/manage-data/delete.mdx | 10 ++-- docs/weaviate/manage-data/import.mdx | 21 ++++----- docs/weaviate/manage-data/migrate.mdx | 20 ++++---- docs/weaviate/manage-data/multi-tenancy.md | 24 +++++----- .../weaviate/manage-data/read-all-objects.mdx | 6 +-- docs/weaviate/manage-data/read.mdx | 6 +-- docs/weaviate/manage-data/tenant-states.mdx | 8 ++-- docs/weaviate/manage-data/update.mdx | 8 ++-- docs/weaviate/search/aggregate.md | 16 +++---- docs/weaviate/search/basics.md | 18 ++++---- docs/weaviate/search/bm25.md | 18 ++++---- docs/weaviate/search/filters.md | 28 +++++------ docs/weaviate/search/generative.md | 8 ++-- docs/weaviate/search/hybrid.md | 28 +++++------ docs/weaviate/search/image.md | 4 +- docs/weaviate/search/multi-vector.md | 14 +++--- docs/weaviate/search/rerank.md | 6 +-- docs/weaviate/search/similarity.md | 20 ++++---- .../starter-guides/custom-vectors.mdx | 4 +- docs/weaviate/starter-guides/generative.md | 26 +++++------ .../tutorials/multi-vector-embeddings.md | 32 ++++++------- docs/weaviate/tutorials/rbac.mdx | 18 ++++---- 110 files changed, 369 insertions(+), 378 deletions(-) diff --git a/_includes/code/configuration/replication-consistency.mdx b/_includes/code/configuration/replication-consistency.mdx index f189528f..1f442987 100644 --- a/_includes/code/configuration/replication-consistency.mdx +++ b/_includes/code/configuration/replication-consistency.mdx @@ -7,7 +7,7 @@ import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBl - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + ```python import weaviate, os diff --git a/_includes/code/quickstart/import.mdx b/_includes/code/quickstart/import.mdx index 78a6494c..b0183957 100644 --- a/_includes/code/quickstart/import.mdx +++ b/_includes/code/quickstart/import.mdx @@ -7,7 +7,7 @@ import EndToEndTSCodeLegacy from '!!raw-loader!/_includes/code/quickstart/endtoe import GoImportObjects from '!!raw-loader!/_includes/code/quickstart/go-add-objects.go'; - + */} - + - + - + - + - + - + - + - + - + Use an API key to connect to Weaviate Cloud. - + - + - + - + - + - + */} - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + To review the current `pq` configuration, you can retrieve it as shown below. - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + validate it against the collection definition. - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + The Python client uses gRPC by default. See the client page for additional batch import [configuration options](/docs/weaviate/client-libraries/python#batch-imports). @@ -173,7 +173,7 @@ Weaviate generates an UUID for each object. Object IDs must be unique. If you se - `generateUuid5` (TypeScript) - + - + - + - + Stream JSON files example code - + Stream CSV files example code - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + The `v4` Python client API provides filtering by `any_of`, or `all_of`, as well as using `&` or `|` operators.
@@ -194,7 +194,7 @@ The output is like this: You can group and nest filters. - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + If your query image is stored in a file, you can use the client library to search by its filename. - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + The v4 client requires Weaviate 1.23.7 or higher.

```bash @@ -154,7 +154,7 @@ When you create a query vector, use the same vectorizer that you use to create t This [`nearVector`](/docs/weaviate/search/similarity#search-with-a-vector) query supplies a query vector. The query vector is an embedding of the query string, "biology". - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - +