Skip to content

Add a Python generator example for data.ingest - #484

Merged
g-despot merged 3 commits into
mainfrom
docs/python-ingest-generator
Jul 29, 2026
Merged

Add a Python generator example for data.ingest#484
g-despot merged 3 commits into
mainfrom
docs/python-ingest-generator

Conversation

@g-despot

@g-despot g-despot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Adds a Python generator example for data.ingest. #478 shipped the TypeScript one only, so Python readers were never told ingest accepts any iterable and can stream without holding the dataset in memory.

  • import.mdx — generator example in the Server-side batching tab, alongside the in-memory list form
  • notes-best-practices.mdx — the ingest paragraph no longer assumes an in-memory list; moved into its own section, and ### Error handling now covers BatchObjectReturn
  • manage-data.import.py, python_v4.py — new CI-executed snippets, run against Weaviate 1.38.0

The examples check result.errors, not result.has_errors. That is deliberate: has_errors stays False on the ingest path (weaviate/weaviate-python-client#2107). Please don't simplify it.

Merge this before the quickstart ingest PR, which links to #error-handling on the best practices page.

g-despot and others added 3 commits July 29, 2026 13:21
The batch import page taught the iterable/generator form of the one-shot
ingest call to TypeScript readers only, even though the Python client
accepts any iterable too. Add the Python counterpart so both clients
document the same capability.

* New CI-executed snippet reads a JSONL file line by line and yields
  property dicts straight into the ingest call, so the file never has to
  fit in memory. Blank lines are skipped explicitly instead of relying on
  a null check that raises on them.
* The snippet sits in the server-side batching tab, next to the streaming
  context, and links to the in-memory list section for the eager form.
* "Stream data from large files" now names Python alongside TypeScript
  for the lazy-iterable option.

Verified against Weaviate 1.38.0 with the CI-pinned client: 5 uuids
returned, empty errors dict, all 5 titles persisted.
The page's only mention of the one-shot ingest call opened with "If your
objects are already in an in-memory list", which is wrong by omission: the
parameter is an iterable, so a generator works just as well. The page had
no mention of generators anywhere.

Rewrite that paragraph to cover both the eager and the lazy case, add a
short generator snippet, and link to the batch import page for the version
that reads a file line by line. Ingest is deliberately not added to the
batch sizing table: it is a second entry point to server-side batching,
not a fifth sizing mode.

Snippet verified against Weaviate 1.38.0 with the CI-pinned client:
2 uuids returned, empty errors dict, both titles persisted.
- import.mdx: name `data.ingest()` inside the Python tab, and drop the
  Python-only method name from the shared "Stream data from large files"
  prose, linking to the server-side batching section instead.
- notes-best-practices.mdx: promote the one-shot ingest material out of
  "Batch sizing" into its own "One-shot ingest" section, so it no longer
  splits "#### Usage" from the batching-method table it refers to.
- notes-best-practices.mdx: document the `BatchObjectReturn` that
  `data.ingest()` returns under "Error handling", which previously covered
  only the batching-context API.
- Snippet cleanups: use `collections.use()`, and trim two code comments
  that overclaimed or duplicated the surrounding prose.

@orca-security-eu orca-security-eu Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Orca Security Scan Summary

Status Check Issues by priority
Passed Passed Infrastructure as Code high 0   medium 0   low 0   info 0 View in Orca
Passed Passed SAST high 0   medium 0   low 0   info 0 View in Orca
Passed Passed Secrets high 0   medium 0   low 0   info 0 View in Orca
Passed Passed Vulnerabilities high 0   medium 0   low 0   info 0 View in Orca

@g-despot
g-despot marked this pull request as ready for review July 29, 2026 12:49
@g-despot
g-despot requested a review from Copilot July 29, 2026 12:49

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the Weaviate documentation and CI-executed Python snippets to demonstrate that collection.data.ingest() accepts any iterable (including generators), enabling streaming imports without holding the full dataset in memory.

Changes:

  • Adds a Python generator-based data.ingest() example to the batch import docs alongside the existing streaming-context example.
  • Refactors the Python best practices page to introduce a dedicated “One-shot ingest” section and clarifies ingest-specific error handling via BatchObjectReturn.
  • Adds/updates CI-executed Python snippets (manage-data.import.py, python_v4.py) to cover generator-based ingest and validate behavior against Weaviate 1.38.0.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
docs/weaviate/manage-objects/import.mdx Documents generator-based data.ingest() usage in the server-side batching section and updates large-file streaming guidance.
docs/weaviate/client-libraries/python/notes-best-practices.mdx Adds a “One-shot ingest” section and updates error-handling guidance for ingest’s BatchObjectReturn.
_includes/code/howto/manage-data.import.py Adds a generator-based ingest snippet with CI assertions and aligns collection access with collections.use().
_includes/code/client-libraries/python_v4.py Adds a generator-based ingest snippet (with assertions) for the Python v4 client examples.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@g-despot
g-despot merged commit 2f87752 into main Jul 29, 2026
14 checks passed
@g-despot
g-despot deleted the docs/python-ingest-generator branch July 29, 2026 13:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants