diff --git a/docs/web-tests/py/test_quickstart.py b/docs/web-tests/py/test_quickstart.py index ac8396db0..60d8852ec 100644 --- a/docs/web-tests/py/test_quickstart.py +++ b/docs/web-tests/py/test_quickstart.py @@ -344,10 +344,11 @@ def flatten_stats(table): # --8<-- [end:quickstart_flatten_stats] -def test_quickstart_derived_feature(db_path_factory): - db = lancedb.connect(db_path_factory("derived_feature")) - table = create_frames(db) +def test_quickstart_derived_feature_on_a_deployment(deployment): + # Functions need LanceDB Enterprise: LanceDB Embedded has no Function catalog. + table = create_frames(deployment) flatten_stats(table) + db = deployment.db # --8<-- [start:quickstart_add_feature] from lancedb import col, function @@ -369,7 +370,8 @@ def test_quickstart_derived_feature(db_path_factory): ) } ) - table.refresh_column("quality_score") + job = table.refresh_column_async("quality_score") + job.wait() # --8<-- [end:quickstart_add_feature] # --8<-- [start:quickstart_query_feature] @@ -379,38 +381,8 @@ def test_quickstart_derived_feature(db_path_factory): print(features) # --8<-- [end:quickstart_query_feature] assert quality_scores(table) == EXPECTED_QUALITY_SCORES - - -def test_quickstart_derived_feature_on_a_deployment(deployment): - table = create_frames(deployment) - flatten_stats(table) - - from lancedb import col, function - - @function - def quality_score( - motion: float, sharpness: float, exposure: float, framing: float - ) -> float: - return (motion + sharpness + exposure + framing) / 4.0 - - version = deployment.db.create_function_async(quality_score).wait() - table.add_columns( - { - "quality_score": version( - motion=col("motion"), - sharpness=col("sharpness"), - exposure=col("exposure"), - framing=col("framing"), - ) - } - ) - - # --8<-- [start:quickstart_add_feature_enterprise] - job = table.refresh_column_async("quality_score") - job.wait() - # --8<-- [end:quickstart_add_feature_enterprise] - assert quality_scores(table) == EXPECTED_QUALITY_SCORES - with pytest.raises(Exception): + # The blocking form raises on Enterprise, which is why the snippet uses a job. + with pytest.raises(NotImplementedError, match="refresh_column_async"): table.refresh_column("quality_score") diff --git a/docs/web/curation/create-function.mdx b/docs/web/curation/create-function.mdx index 2f822ae10..01f9a43e3 100644 --- a/docs/web/curation/create-function.mdx +++ b/docs/web/curation/create-function.mdx @@ -543,7 +543,10 @@ table.add_columns( gpu_count=1, total_gpu_count=8, ) -table.refresh_column("embedding", gpu_class="h100", gpu_count=4, total_gpu_count=8) +job = table.refresh_column_async( + "embedding", gpu_class="h100", gpu_count=4, total_gpu_count=8 +) +job.wait() db.create_materialized_view( "embeddings", query="SELECT embed(text) AS embedding FROM documents", diff --git a/docs/web/curation/vend-secret.mdx b/docs/web/curation/vend-secret.mdx index 7d272c265..d78447154 100644 --- a/docs/web/curation/vend-secret.mdx +++ b/docs/web/curation/vend-secret.mdx @@ -106,7 +106,8 @@ table.add_columns( ) } ) -table.refresh_column("embedding") +job = table.refresh_column_async("embedding") +job.wait() ``` A decorated class calls `__init__` once per remote instance and `__call__` @@ -135,7 +136,7 @@ cached in the Function's definition: | Step | What happens | | --- | --- | | `add_columns` with this Function version | Every bound Secret must now exist. The column pins this exact version, not a value. | -| A refresh starts -- `refresh_column`, or a materialized view's refresh | Every bound Secret must still exist, checked before any row is computed. | +| A refresh starts: `refresh_column_async`, or a materialized view's refresh | Every bound Secret must still exist, checked before any row is computed. | | The job captures each bound Secret's current value | LanceDB looks up the value once, when the job starts, and sets it as that environment variable for every row the job evaluates, including its retries. No other environment variable carries over. | This is why rotating a Secret needs no new Function version and no column diff --git a/docs/web/enterprise/auto-refresh.mdx b/docs/web/enterprise/auto-refresh.mdx index 452d543e8..f9f313c56 100644 --- a/docs/web/enterprise/auto-refresh.mdx +++ b/docs/web/enterprise/auto-refresh.mdx @@ -11,7 +11,7 @@ availability: Both a [computed column](/feature-engineering/add-computed-column) and a [materialized view](/feature-engineering/materialized-views) can refresh themselves on a schedule instead of waiting for an explicit -`refresh_column()`, `view.refresh()`, or `REFRESH` statement. Either way, +`refresh_column_async()`, `view.refresh()`, or `REFRESH` statement. Either way, `auto_refresh_enabled` turns it on and `auto_refresh_interval_seconds` sets a minimum delay before the next automatic refresh is eligible -- omit the interval to let the server decide. What that delay is measured from differs diff --git a/docs/web/feature-engineering/add-computed-column.mdx b/docs/web/feature-engineering/add-computed-column.mdx index 730d0081e..76e5e03f1 100644 --- a/docs/web/feature-engineering/add-computed-column.mdx +++ b/docs/web/feature-engineering/add-computed-column.mdx @@ -183,7 +183,7 @@ large enough that you would rather control when the work happens. Automatic refresh is on by default for each computed column, and takes effect when your Enterprise deployment enables its refresh scheduler. Until then, -call [`refresh_column`](/feature-engineering/refresh-column) yourself. Pass +call [`refresh_column_async`](/feature-engineering/refresh-column#async) yourself. Pass `auto_refresh_enabled=False` to opt a column out, or `auto_refresh_interval_seconds` to set how often it refreshes: diff --git a/docs/web/quickstart.mdx b/docs/web/quickstart.mdx index c01686c2c..22fd4bd9d 100644 --- a/docs/web/quickstart.mdx +++ b/docs/web/quickstart.mdx @@ -5,7 +5,7 @@ description: "Install LanceDB, create a table, and run your first vector search. icon: rocket --- import { PyConnect, TsConnect, RsConnect, PyConnectObjectStorage, TsConnectObjectStorage, RsConnectObjectStorage, PyConnectEnterprisePlaceholders, TsConnectEnterprisePlaceholders, RsConnectEnterprisePlaceholders } from '/snippets/connection.mdx'; -import { PyQuickstartData, PyQuickstartCreateTable, PyQuickstartAddData, PyQuickstartCurateSample, PyQuickstartCurateDedupeSetup, PyQuickstartCurateDedupe, PyQuickstartCurateDedupeQuery, PyQuickstartFlattenStats, PyQuickstartAddFeature, PyQuickstartAddFeatureEnterprise, PyQuickstartMultimodalBytes, PyQuickstartTraining, TsQuickstartData, TsQuickstartCreateTable, TsQuickstartAddData, TsQuickstartVectorSearch1, TsQuickstartMultimodalBytes, RsQuickstartDefineStruct, RsQuickstartData, RsQuickstartCreateTable, RsQuickstartAddData, RsQuickstartVectorSearch1, RsQuickstartMultimodalBytes } from '/snippets/quickstart.mdx'; +import { PyQuickstartData, PyQuickstartCreateTable, PyQuickstartAddData, PyQuickstartCurateSample, PyQuickstartCurateDedupeSetup, PyQuickstartCurateDedupe, PyQuickstartCurateDedupeQuery, PyQuickstartFlattenStats, PyQuickstartAddFeature, PyQuickstartMultimodalBytes, PyQuickstartTraining, TsQuickstartData, TsQuickstartCreateTable, TsQuickstartAddData, TsQuickstartVectorSearch1, TsQuickstartMultimodalBytes, RsQuickstartDefineStruct, RsQuickstartData, RsQuickstartCreateTable, RsQuickstartAddData, RsQuickstartVectorSearch1, RsQuickstartMultimodalBytes } from '/snippets/quickstart.mdx'; This quickstart walks you through creating a table, searching your data, and preparing it for training. By default, it uses LanceDB Embedded with a local database, so no account or API key is required. @@ -324,7 +324,9 @@ Enterprise feature. If you're using LanceDB Embedded, skip ahead to Register a UDF as a Function, then call it to fill a column computed from -those flattened fields. This fills every existing row once, immediately: +those flattened fields. On LanceDB Enterprise a refresh runs as a server job: +`refresh_column_async` starts it and returns a job handle, and `wait()` blocks +until every existing row is filled: @@ -340,13 +342,7 @@ Read it back like any other column: -`refresh_column` fills only rows added since the last refresh and recomputes rows whose inputs changed, leaving unchanged rows alone. Run the same refresh as a background job instead, so it doesn't block: - - - - {PyQuickstartAddFeatureEnterprise} - - +Run the same refresh again after adding rows. It fills only rows added since the last refresh and recomputes rows whose inputs changed, leaving unchanged rows alone. To keep working while it runs, call `wait()` later, when you need the column filled. See [Create a Function](/curation/create-function) for UDFs that call external models or services, and [Computed columns](/feature-engineering/add-computed-column) diff --git a/docs/web/snippets/quickstart.mdx b/docs/web/snippets/quickstart.mdx index a8b638085..15e999dbd 100644 --- a/docs/web/snippets/quickstart.mdx +++ b/docs/web/snippets/quickstart.mdx @@ -2,9 +2,7 @@ export const PyQuickstartAddData = "table.add(\n [\n {\n \"frame_id\": \"4\",\n \"video_id\": \"clip-2\",\n \"caption\": \"a gripper lowering a cup onto the table\",\n \"stats\": {\"motion\": 5, \"sharpness\": 4, \"exposure\": 4, \"framing\": 2},\n \"embedding\": [0.3, 0.9, 0.6, 0.8],\n }\n ]\n)\n"; -export const PyQuickstartAddFeature = "from lancedb import col, function\n\n@function\ndef quality_score(\n motion: float, sharpness: float, exposure: float, framing: float\n) -> float:\n return (motion + sharpness + exposure + framing) / 4.0\n\nversion = db.create_function_async(quality_score).wait()\ntable.add_columns(\n {\n \"quality_score\": version(\n motion=col(\"motion\"),\n sharpness=col(\"sharpness\"),\n exposure=col(\"exposure\"),\n framing=col(\"framing\"),\n )\n }\n)\ntable.refresh_column(\"quality_score\")\n"; - -export const PyQuickstartAddFeatureEnterprise = "job = table.refresh_column_async(\"quality_score\")\njob.wait()\n"; +export const PyQuickstartAddFeature = "from lancedb import col, function\n\n@function\ndef quality_score(\n motion: float, sharpness: float, exposure: float, framing: float\n) -> float:\n return (motion + sharpness + exposure + framing) / 4.0\n\nversion = db.create_function_async(quality_score).wait()\ntable.add_columns(\n {\n \"quality_score\": version(\n motion=col(\"motion\"),\n sharpness=col(\"sharpness\"),\n exposure=col(\"exposure\"),\n framing=col(\"framing\"),\n )\n }\n)\njob = table.refresh_column_async(\"quality_score\")\njob.wait()\n"; export const PyQuickstartCreateTable = "table = db.create_table(\"frames\", data=data, mode=\"overwrite\")\n";