File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -99,6 +99,36 @@ The `Store` class supports the following options:
9999Use ` Store.for_download() ` as a convenient shorthand for storing results
100100as a single Parquet file with a presigned URL.
101101
102+ ### Execution progress
103+
104+ You can monitor the progress of running queries by registering a
105+ progress handler on the connection. This follows the
106+ [ ` sqlite3.Connection.set_progress_handler() ` ] ( https://docs.python.org/3/library/sqlite3.html#sqlite3.Connection.set_progress_handler )
107+ pattern.
108+
109+ ``` python
110+ from wherobots.db import connect, ProgressInfo
111+ from wherobots.db.region import Region
112+ from wherobots.db.runtime import Runtime
113+
114+ def on_progress (info : ProgressInfo) -> None :
115+ print (f " { info.tasks_completed} / { info.tasks_total} tasks "
116+ f " ( { info.tasks_active} active) " )
117+
118+ with connect(
119+ api_key = ' ...' ,
120+ runtime = Runtime.TINY ,
121+ region = Region.AWS_US_WEST_2 ) as conn:
122+ conn.set_progress_handler(on_progress)
123+ curr = conn.cursor()
124+ curr.execute(" SELECT ..." )
125+ results = curr.fetchall()
126+ ```
127+
128+ The handler receives a ` ProgressInfo ` named tuple with ` execution_id ` ,
129+ ` tasks_total ` , ` tasks_completed ` , and ` tasks_active ` fields. Pass
130+ ` None ` to ` set_progress_handler() ` to disable progress reporting.
131+
102132### Runtime and region selection
103133
104134You can chose the Wherobots runtime you want to use using the ` runtime `
You can’t perform that action at this time.
0 commit comments