Skip to content

[core][python] Add asynchronous prediction REST APIs - #11012

Draft
XiaoHongbo-Hope wants to merge 1 commit into
apache:masterfrom
XiaoHongbo-Hope:codex/prediction-job-api
Draft

XiaoHongbo-Hope wants to merge 1 commit into
apache:masterfrom
XiaoHongbo-Hope:codex/prediction-job-api

Conversation

@XiaoHongbo-Hope

@XiaoHongbo-Hope XiaoHongbo-Hope commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Purpose

Add provider-neutral asynchronous predictions for registered Models. A public ModelProvider SPI and the published ReferenceModelProvider provide an executable local workflow without embedding model logic in the REST test server.

API

  • table.predict() submits a prediction and returns PredictionWait.
  • result(timeout) polls until the deadline. The deadline is checked between REST requests and does not cancel the server-side prediction.
  • REST exposes Catalog-scoped submit, list, get, and cancel operations under /v1/{prefix}/predictions.
  • Submission records the source snapshot and resolves the registered Model. Execution reads that snapshot and fails if it is unavailable.
  • SDKs generate idempotencyToken by default; callers may supply one for retries. x-request-id remains a tracing identifier.
  • Time travel uses Paimon options scan.snapshot-id or scan.tag-name.
  • output is optional. The default managed table contains source identity columns, response, and error.

Strict request cancellation and an end-to-end HTTP deadline are generic client concerns and are out of scope.

Lifecycle

  • state: PENDING, RUNNING, TERMINATING, or TERMINATED.
  • terminationDetails contains the result code and optional message.
  • startTime and endTime describe execution time.
  • Cancellation is asynchronous and may return TERMINATING.

Industry references

Reference Adopted design
Databricks Runs Asynchronous resource lifecycle, execution timestamps, termination details, cancellation, and caller-reusable idempotency tokens
Databricks AI Function Task Task instructions and managed result columns such as response and error
Databricks Delta time travel Reproducible execution against a selected source version
BigQuery and Snowflake Idempotent request retry patterns
SageMaker Batch Transform Asynchronous batch prediction resource

Paimon-specific choices are the Catalog-scoped resource, structured Model identifier, table source, and snapshot/tag options.

Reference integration

paimon-api publishes the ModelProvider SPI. paimon-core publishes a discoverable reference provider (provider=reference, model=sample). The REST reference executor resolves the registered Model, validates it through the provider, reads the recorded source snapshot, invokes the provider for every input row, and writes a managed Paimon result table.

The integration verifies:

  • SPI discovery and registered-model validation;
  • submission returns the recorded snapshot;
  • data committed after submission is excluded from execution;
  • results are written to a managed Paimon table and read back through REST Catalog;
  • cancellation reaches TERMINATED/CANCELED without publishing an output table.

Tests

  • Model provider discovery and invocation: 2 passed.
  • Mock REST Catalog prediction tests, including executable reference integration and registered-model validation: 6 passed.
  • Java Checkstyle, Spotless, and git diff --check passed.

@XiaoHongbo-Hope
XiaoHongbo-Hope force-pushed the codex/prediction-job-api branch 5 times, most recently from 062f66b to ba1769d Compare November 16, 2026 08:54
@XiaoHongbo-Hope
XiaoHongbo-Hope marked this pull request as ready for review November 18, 2026 09:12
@XiaoHongbo-Hope XiaoHongbo-Hope changed the title [core][python] Add asynchronous table prediction APIs [core][python] Add asynchronous prediction REST APIs Nov 18, 2026
@JingsongLi

Copy link
Copy Markdown
Contributor

Thanks for putting together the Java and Python prediction contracts. I ran the client and REST-contract tests from this head. They exercise request encoding and mocked lifecycle responses. The proposed workflow depends on a provider to submit and execute an actual job, read the pinned snapshot, publish the result table, and handle cancellation. This change leaves that provider work outside its scope, so the current patch does not give a Paimon user a deployable prediction workflow.

I'm closing this version. Please bring it back with a linked provider implementation or an executable reference integration that demonstrates submission through result readback, including the snapshot and cancellation behavior.

@JingsongLi JingsongLi closed this Nov 19, 2026
@XiaoHongbo-Hope
XiaoHongbo-Hope marked this pull request as draft November 19, 2026 07:18
@XiaoHongbo-Hope
XiaoHongbo-Hope marked this pull request as ready for review November 19, 2026 13:34
@XiaoHongbo-Hope
XiaoHongbo-Hope marked this pull request as draft November 19, 2026 13:37
@XiaoHongbo-Hope
XiaoHongbo-Hope marked this pull request as ready for review November 20, 2026 07:48
@JingsongLi

Copy link
Copy Markdown
Contributor

The new reference integration covers the snapshot and cancellation checks from the previous review. I ran the real Paimon source-to-result test as part of 308 passing JVM tests, and 27 Python tests passed.

The execution handler is packaged only with the MockWebServer tests. It checks that the model identifier exists, then writes the submitted input fields back as JSON. The published artifacts provide the REST clients and contract, and this PR links no provider that can execute a registered model. That leaves the production prediction workflow incomplete.

I’m closing this iteration. Please reopen with a deployable provider or a linked provider change that runs a registered model through submission, snapshot-bound execution, result readback, and cancellation.

@JingsongLi JingsongLi closed this Nov 20, 2026
@XiaoHongbo-Hope
XiaoHongbo-Hope marked this pull request as draft November 22, 2026 09:16
@XiaoHongbo-Hope
XiaoHongbo-Hope force-pushed the codex/prediction-job-api branch 3 times, most recently from 799eeaf to 86ff51b Compare November 26, 2026 03:00
@XiaoHongbo-Hope

Copy link
Copy Markdown
Contributor Author

The new reference integration covers the snapshot and cancellation checks from the previous review. I ran the real Paimon source-to-result test as part of 308 passing JVM tests, and 27 Python tests passed.

The execution handler is packaged only with the MockWebServer tests. It checks that the model identifier exists, then writes the submitted input fields back as JSON. The published artifacts provide the REST clients and contract, and this PR links no provider that can execute a registered model. That leaves the production prediction workflow incomplete.

I’m closing this iteration. Please reopen with a deployable provider or a linked provider change that runs a registered model through submission, snapshot-bound execution, result readback, and cancellation.

Should we just define a provider SPI or also include a concrete implementation?

Add prediction lifecycle APIs for REST Catalog clients and a ModelProvider SPI with a runnable reference integration.
@XiaoHongbo-Hope
XiaoHongbo-Hope force-pushed the codex/prediction-job-api branch from 86ff51b to c265112 Compare December 3, 2026 07:42
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