Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/audit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ jobs:
sdk: stable
- uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version: "1.26.5"
go-version: "1.26.6"
- name: Install OSV Scanner
run: go install github.com/google/osv-scanner/v2/cmd/osv-scanner@${{ env.OSV_SCANNER_VERSION }}
- name: Audit Dart templates
Expand All @@ -167,7 +167,7 @@ jobs:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version: "1.26.5"
go-version: "1.26.6"
cache: false
- name: Install govulncheck
run: go install golang.org/x/vuln/cmd/govulncheck@v1.1.4
Expand Down Expand Up @@ -247,7 +247,7 @@ jobs:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version: "1.26.5"
go-version: "1.26.6"
- name: Install OSV Scanner
run: go install github.com/google/osv-scanner/v2/cmd/osv-scanner@${{ env.OSV_SCANNER_VERSION }}
- name: Audit Maven coordinates in deps.gradle
Expand Down
2 changes: 1 addition & 1 deletion python-ml/starter/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
appwrite
appwrite==23.0.0
numpy
4 changes: 2 additions & 2 deletions python-ml/starter/src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ def main(context):
Client()
.set_endpoint(os.environ["APPWRITE_FUNCTION_API_ENDPOINT"])
.set_project(os.environ["APPWRITE_FUNCTION_PROJECT_ID"])
.set_key(context.req.headers["x-appwrite-key"])
.set_key(context.req.headers.get("x-appwrite-key", ""))
)
users = Users(client)

try:
response = users.list()
# Log messages and errors to the Appwrite Console
# These logs won't be seen by your end users
context.log("Total users: " + str(response["total"]))
context.log("Total users: " + str(response.total))
except AppwriteException as err:
context.error("Could not list users: " + repr(err))

Expand Down
2 changes: 1 addition & 1 deletion python/starter/requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
appwrite
appwrite==23.0.0
4 changes: 2 additions & 2 deletions python/starter/src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ def main(context):
Client()
.set_endpoint(os.environ["APPWRITE_FUNCTION_API_ENDPOINT"])
.set_project(os.environ["APPWRITE_FUNCTION_PROJECT_ID"])
.set_key(context.req.headers["x-appwrite-key"])
.set_key(context.req.headers.get("x-appwrite-key", ""))
)
users = Users(client)

try:
response = users.list()
# Log messages and errors to the Appwrite Console
# These logs won't be seen by your end users
context.log("Total users: " + str(response["total"]))
context.log("Total users: " + str(response.total))
except AppwriteException as err:
context.error("Could not list users: " + repr(err))

Expand Down
2 changes: 1 addition & 1 deletion python/storage-cleaner/requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
appwrite
appwrite==23.0.0
8 changes: 4 additions & 4 deletions python/storage-cleaner/src/appwrite_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,22 +46,22 @@ def clean_bucket(self, bucket_id: str):
raise RuntimeError(
f"Failed to list files from bucket {bucket_id}: {str(e)}"
) from e
files = response.get("files", [])
files = response.files

if not files:
break

batch_failed = False
with ThreadPoolExecutor() as executor:
future_to_file = {
executor.submit(self.storage.delete_file, bucket_id, f.get("$id")): f
executor.submit(self.storage.delete_file, bucket_id, f.id): f
for f in files
if f.get("$id")
if f.id
}

for future in as_completed(future_to_file):
file_info = future_to_file[future]
file_id = file_info.get("$id")
file_id = file_info.id
try:
future.result()
deleted_files_count += 1
Expand Down
2 changes: 1 addition & 1 deletion python/sync_with_algolia/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
appwrite
appwrite==23.0.0
algoliasearch
12 changes: 8 additions & 4 deletions python/sync_with_algolia/src/main.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os
from algoliasearch.search_client import SearchClient
from appwrite.client import Client
from appwrite.models import Document
from appwrite.services.databases import Databases
from appwrite.query import Query
from .utils import get_static_file, throw_if_missing, interpolate
Expand Down Expand Up @@ -55,16 +56,19 @@ def main(context):
queries,
)

if len(response.documents) > 0:
cursor = response.documents[len(response.documents) - 1]["$id"]
documents: list[Document] = response.documents

if len(documents) > 0:
cursor = documents[-1].id
else:
context.log("No more documents found.")
cursor = None
break

context.log(f"Syncing chunk of {len(response.documents)} documents...")
context.log(f"Syncing chunk of {len(documents)} documents...")
documents_with_object_ids = [
{"objectID": document["$id"], **document} for document in response.documents
{"objectID": document.id, "$id": document.id, **document.data}
for document in documents
]
index.save_objects(documents_with_object_ids)

Expand Down
2 changes: 1 addition & 1 deletion python/sync_with_meilisearch/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
appwrite
appwrite==23.0.0
meilisearch
10 changes: 7 additions & 3 deletions python/sync_with_meilisearch/src/main.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import os
from appwrite.client import Client
from appwrite.models import Document
from appwrite.services.databases import Databases
from meilisearch import Client as MeiliClient
from .utils import get_static_file, interpolate, throw_if_missing
Expand Down Expand Up @@ -47,17 +48,20 @@ def main(context):
queries
)

documents = response['documents']
documents: list[Document] = response.documents

if len(documents) > 0:
cursor = documents[-1]['$id']
cursor = documents[-1].id
else:
context.log('No more documents found.')
cursor = None
break

context.log(f'Syncing chunk of {len(documents)} documents...')
index.add_documents(documents, {'primaryKey': '$id'})
index.add_documents(
[{"$id": document.id, **document.data} for document in documents],
{'primaryKey': '$id'},
)

context.log('Sync finished.')

Expand Down
2 changes: 1 addition & 1 deletion python/sync_with_qdrant/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
appwrite
appwrite==23.0.0
qdrant-client
openai
9 changes: 5 additions & 4 deletions python/sync_with_qdrant/src/appwrite.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import os
from appwrite.client import Client
from appwrite.models import Document
from appwrite.services.databases import Databases
from appwrite.query import Query

def get_all_documents(api_key):
def get_all_documents(api_key) -> list[Document]:
client = Client()
client.set_endpoint(os.environ.get("APPWRITE_FUNCTION_API_ENDPOINT"))
client.set_project(os.environ["APPWRITE_FUNCTION_PROJECT_ID"])
Expand All @@ -12,7 +13,7 @@ def get_all_documents(api_key):
databases = Databases(client)

cursor = None
cumulative = []
cumulative: list[Document] = []

while True:
queries = [Query.limit(1000)]
Expand All @@ -25,10 +26,10 @@ def get_all_documents(api_key):
queries,
)

documents = response["documents"]
documents: list[Document] = response.documents

if len(documents) > 0:
cursor = documents[-1]["$id"]
cursor = documents[-1].id
else:
break
cumulative.extend(documents)
Expand Down
5 changes: 3 additions & 2 deletions python/sync_with_qdrant/src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,13 @@ def main(context):
documents = get_all_documents(context.req.headers['x-appwrite-key'])
points = []
for index, document in enumerate(documents):
payload = {"$id": document.id, **document.data}
response = openai.embeddings.create(
input=json.dumps(document), model="text-embedding-3-small"
input=json.dumps(payload), model="text-embedding-3-small"
)

point = models.PointStruct(
id=index, vector=response.data[0].embedding, payload=dict(document)
id=index, vector=response.data[0].embedding, payload=payload
)
points.append(point)

Expand Down
Loading