Repository navigation
Conversation
…coercion, and reporter init isolation Address self-review findings on PR GoogleCloudPlatform#729: - Allow sibling 'stopped' row errors when checking retryable BigQuery insertErrors while still failing fast on permanent row errors. - Pass stable per-batch row_ids to insert_rows_json() and retry only failed indices on partial retryable errors to prevent duplicate rows. - Infer schema across the full DataFrame (all non-null values/elements, unwrapping NumPy scalars) before chunking, and retry update_table() up to 5 times on concurrent Conflict/PreconditionFailed. - Only refresh cached table schemas on NotFound or 'no such field' errors, and re-coerce pending rows when the refreshed schema changed. - Fix _coerce_scalar() / _dataframe_to_json_rows() edge cases: exact INT64 precision above 2^53, empty/offset DATETIME/TIMESTAMP/DATE strings (Python 3.10-safe), NaN/Inf sanitization in JSON, and recursive RECORD/STRUCT coercion. - Move reporter construction inside _process_results() via _build_reporters() so reporter init failures are isolated and /tmp files are always unlinked; raise in Eval() when summary_in_response is falsy and every configured reporter failed. - Expand unit tests in bqstore_test.py and eval_service_reporting_test.py.
…coercion, and reporter init isolation Address self-review findings on PR GoogleCloudPlatform#729: - Allow sibling 'stopped' row errors when checking retryable BigQuery insertErrors while still failing fast on permanent row errors. - Pass stable per-batch row_ids to insert_rows_json() and retry only failed indices on partial retryable errors to prevent duplicate rows. - Infer schema across the full DataFrame (all non-null values/elements, unwrapping NumPy scalars) before chunking, and retry update_table() up to 5 times on concurrent Conflict/PreconditionFailed. - Only refresh cached table schemas on NotFound or 'no such field' errors, and re-coerce pending rows when the refreshed schema changed. - Fix _coerce_scalar() / _dataframe_to_json_rows() edge cases: exact INT64 precision above 2^53, empty/offset DATETIME/TIMESTAMP/DATE strings (Python 3.10-safe), NaN/Inf sanitization in JSON, and recursive RECORD/STRUCT coercion. - Move reporter construction inside _process_results() via _build_reporters() so reporter init failures are isolated and /tmp files are always unlinked; raise in Eval() when summary_in_response is falsy and every configured reporter failed. - Expand unit tests in bqstore_test.py and eval_service_reporting_test.py.
8ac1f84 to
551eaa5
Compare
…coercion, and reporter init isolation Address self-review findings on PR GoogleCloudPlatform#729: - Allow sibling 'stopped' row errors when checking retryable BigQuery insertErrors while still failing fast on permanent row errors. - Pass stable per-batch row_ids to insert_rows_json() and retry only failed indices on partial retryable errors to prevent duplicate rows. - Infer schema across the full DataFrame (all non-null values/elements, unwrapping NumPy scalars) before chunking, and retry update_table() up to 5 times on concurrent Conflict/PreconditionFailed. - Only refresh cached table schemas on NotFound or 'no such field' errors, and re-coerce pending rows when the refreshed schema changed. - Fix _coerce_scalar() / _dataframe_to_json_rows() edge cases: exact INT64 precision above 2^53, empty/offset DATETIME/TIMESTAMP/DATE strings (Python 3.10-safe), NaN/Inf sanitization in JSON, and recursive RECORD/STRUCT coercion. - Move reporter construction inside _process_results() via _build_reporters() so reporter init failures are isolated and /tmp files are always unlinked; raise in Eval() when summary_in_response is falsy and every configured reporter failed. - Expand unit tests in bqstore_test.py and eval_service_reporting_test.py.
ff50625 to
9c8ffba
Compare
|
/gcbrun |
…coercion, and reporter init isolation Address self-review findings on PR GoogleCloudPlatform#729: - Allow sibling 'stopped' row errors when checking retryable BigQuery insertErrors while still failing fast on permanent row errors. - Pass stable per-batch row_ids to insert_rows_json() and retry only failed indices on partial retryable errors to prevent duplicate rows. - Infer schema across the full DataFrame (all non-null values/elements, unwrapping NumPy scalars) before chunking, and retry update_table() up to 5 times on concurrent Conflict/PreconditionFailed. - Only refresh cached table schemas on NotFound or 'no such field' errors, and re-coerce pending rows when the refreshed schema changed. - Fix _coerce_scalar() / _dataframe_to_json_rows() edge cases: exact INT64 precision above 2^53, empty/offset DATETIME/TIMESTAMP/DATE strings (Python 3.10-safe), NaN/Inf sanitization in JSON, and recursive RECORD/STRUCT coercion. - Move reporter construction inside _process_results() via _build_reporters() so reporter init failures are isolated and /tmp files are always unlinked; raise in Eval() when summary_in_response is falsy and every configured reporter failed. - Expand unit tests in bqstore_test.py and eval_service_reporting_test.py.
e97d37a to
caa456e
Compare
|
/gcbrun |
|
Thanks for this. Both problems are real: the 1,500 load-jobs-per-table daily cap is a hard ceiling for a shared dataset, and I ran the branch locally from Blocking
Should fix Request:
|
…EvalService BigQuery enforces a hard quota of 1,500 load jobs per table per day (load_job_per_table.long). BigQueryReporter.store() previously created a separate load_table_from_dataframe() load job for each of the four EvalBench tables (configs, results, scores, summary) on every evaluation, exhausting the per-table token bucket under high-concurrency CI suites. In addition, EvalService._process_results() called reporter.store() without isolating per-reporter exceptions, so a BigQuery failure aborted CSV/artifact reporters, skipped temp-file cleanup, and failed the entire completed Eval() RPC. - Switch BigQueryReporter.store() from load_table_from_dataframe() to streaming inserts via client.insert_rows_json() (0 load jobs consumed), creating missing tables on NotFound, patching new columns via update_table() to preserve schema-addition behavior, coercing DataFrame values to target BigQuery SchemaField types, splitting requests below BigQuery's 10 MB insertAll limit, and retrying transient/schema-propagation errors. - Extract _store_reports() in eval_service.py (matching evalbench.py) so a reporter failure logs the error and records summary["reporting_errors"] without discarding completed evaluation scores or leaking /tmp files. - Add unit tests in bqstore_test.py and eval_service_reporting_test.py.
…coercion, and reporter init isolation Address self-review findings on PR GoogleCloudPlatform#729: - Allow sibling 'stopped' row errors when checking retryable BigQuery insertErrors while still failing fast on permanent row errors. - Pass stable per-batch row_ids to insert_rows_json() and retry only failed indices on partial retryable errors to prevent duplicate rows. - Infer schema across the full DataFrame (all non-null values/elements, unwrapping NumPy scalars) before chunking, and retry update_table() up to 5 times on concurrent Conflict/PreconditionFailed. - Only refresh cached table schemas on NotFound or 'no such field' errors, and re-coerce pending rows when the refreshed schema changed. - Fix _coerce_scalar() / _dataframe_to_json_rows() edge cases: exact INT64 precision above 2^53, empty/offset DATETIME/TIMESTAMP/DATE strings (Python 3.10-safe), NaN/Inf sanitization in JSON, and recursive RECORD/STRUCT coercion. - Move reporter construction inside _process_results() via _build_reporters() so reporter init failures are isolated and /tmp files are always unlinked; raise in Eval() when summary_in_response is falsy and every configured reporter failed. - Expand unit tests in bqstore_test.py and eval_service_reporting_test.py.
…ndas-gbq and pandas.to_json Replace custom schema inference and pandas/NumPy/NaN/Inf sanitization helpers in bqstore.py with pandas_gbq.schema.pandas_to_bigquery.dataframe_to_bigquery_fields() and DataFrame.to_json(orient='records', date_format='iso', date_unit='us'), keeping only the minimal BigQuery insertAll alignment, byte-size batching, schema evolution, and retry/dedup logic.
Drop manual FLOAT/BOOLEAN/TIMESTAMP/RECORD/INT64-string parsing branches that BigQuery tabledata.insertAll already accepts natively, keeping only the minimal STRING, REPEATED, float-to-INTEGER, DATETIME/DATE, JSON, and empty-string normalizations.
…vice reporting paths - Resolve _MAX_STREAMING_REQUEST_BYTES at call time in _iter_streaming_batches(). - Add unit tests covering empty inputs, unsupported store types, unparseable/NaT DATETIME values, empty insertErrors guards, empty create_table schema fallback, concurrent column-addition no-op, update_table conflict retry exhaustion, mid-chunk multi-batch schema refresh, non-dict reporting_config, multi_trial_scores_tf cleanup, and generation latency summary.
caa456e to
358afd4
Compare
|
Thanks for the thorough review @prernakakkar-google! I split the PR as requested and addressed all 7 items:
Blocking
Should fix PTAL when you have a moment! |
|
Thanks for the quick turnaround Blocking The test check is red. test_store_delegates_transport_retry_and_retries_verified_schema_lag fails with the locked google-cloud-bigquery 3.40.1. Should fix
|
|
Can you update docs as well |
…or on gcbq 3.40.1, add timeout, raise on skipped oversized rows, and update docs
|
Updated in
PTAL! |
|
/gcbrun |
Summary
BigQuery enforces a hard quota of 1,500 load jobs per table per day (
load_job_per_table.long). Previously,BigQueryReportercreated a separateload_table_from_dataframe()load job for each EvalBench table (configs,results,scores,summary, andrun_stats) on every evaluation, exhausting the per-table token bucket under high-concurrency CI suites.Changes
evalbench/reporting/bqstore.py: SwitchBigQueryReporter.store()andstore_run_stats()(from feat(agent): store the run stats in BigQuery #716, routed through shared_stream()) fromload_table_from_dataframe()to streaming inserts viaclient.insert_rows_json()(0 load jobs consumed):pandas_gbq.schema.pandas_to_bigquery.dataframe_to_bigquery_fields()inside_infer_schema()(avoiding import-time coupling inreporting/__init__.py). Infers schemas across the full DataFrame before chunking, creates missing tables onNotFound, and appends new top-level columns viaupdate_table()with bounded retry on(Conflict, PreconditionFailed). Preserves feat(agent): store the run stats in BigQuery #716's_column_name()sanitization forrun_statsand keeps_SUITE_COLUMNSnumeric (FLOAT/INTEGER) insummary.DataFrame.to_json(orient="records", date_format="iso", date_unit="us")plus_coerce_json_value()forSTRING,REPEATED, empty-string →None,DATETIME/DATE, andJSONalignment. Exact whole floats (val.is_integer(), from nullable pandas integer columns widened tofloat64) convert losslessly toint; non-integral float rounding (int(round(val))) is restricted strictly to_SUMMARY_AND_SCORES_INT_COLS(metric_score,totalLatencyMs,total_results_count,correct_results_count, case-insensitive) onSTORETYPE.SUMMARYandSTORETYPE.SCORES.insertAllper-row wrapper overhead and splits batches below 8 MiB (under BigQuery's 10 MB request cap). If a single row exceeds 8 MiB, truncates its largest non-repeatedSTRINGcolumns with... [truncated for BigQuery streaming size limit]and logs a warning so the row still lands. If a row still exceeds 8 MiB (e.g., an unshrinkableJSON/RECORD/REPEATEDcolumn, which is not truncated to avoid invalid JSON), logs an error, still streams all other valid rows, and then raisesRuntimeErrorlisting the skipped row(s) so no data is silently dropped.google-cloud-bigquery: Passes_STREAMING_TRANSPORT_RETRY(DEFAULT_RETRYwrapped with an explicitSSLErrorexclusion forgoogle-cloud-bigquery==3.40.1compatibility and.with_deadline(120.0)),timeout=30.0, and stable per-rowrow_idsdirectly toinsert_rows_json(). The outer loop handles onlyNotFoundand retryable row-levelinsertErrorswith a 120 s backoff schedule (2, 4, 8, 16, 30, 30, 30s), narrows retries to failed indices (preserving sibling"stopped"handling), and only treats"no such field"as retryable schema lag after verifying every reported field path (preferring qualifiedlocation, e.g.meta.extra, and stripping array indices) exists in the refreshed server schema.evalbench/test/bqstore_test.py(24 unit tests): Merges all feat(agent): store the run stats in BigQuery #716run_stats/_SUITE_COLUMNStests with streaming coverage for schema evolution/conflict retries, transport retry predicate (includingSSLErroron3.40.1),timeout=30.0,RetryErrorpass-through, 120 s schema-lag retry budget, fail-fast permanent"no such field"(including nestedRECORDsubfields), scoped float rounding, oversized single-row truncation + post-flushRuntimeErrorfor unshrinkable rows (withpending_positionsalignment across schema refresh), serialization edge cases, and importingreporting.bqstorewithoutpandas_gbq.docs/configs/run-config.md(## 5. Reporting Configurations, includingdataset_location,chunk_size, and### BigQuery streaming notes) andAGENTS.md(### 4. BigQuery Reporting).Verification (commit
08801f8, merged withorigin/mainc2cca07)PYTHONPATH="$PWD/evalbench:$PWD" SKIP_CLOUD_TESTS=true pytest evalbench/test/bqstore_test.py evalbench/test/run_stats_test.py evalbench/test/agent_suite_stats_test.py evalbench/test/evalbench_test.py -vv(93 passed — 24 inbqstore_test.py).uv.lockversions (google-cloud-bigquery==3.40.1,google-api-core==2.30.0,pandas-gbq==0.31.0):python -m unittest discover -s evalbench/test -p bqstore_test.py -v(24/24 OK).pycodestyle evalbench/reporting/bqstore.py evalbench/test/bqstore_test.py --config=.pycodestyle(0 errors).08801f8) (against a scratch dataset, deleted immediately afterward):configs,results,scores,summary, andrun_stats; confirmed_SUITE_COLUMNSstayFLOAT/INT64,legacy_ratiobecomesSTRING,metric_scorerounds95.6 → 96,run_statscolumn names sanitize (my_scorer_v2_pass_rate,_3p_latency_max), and Looker_REPORT_QUERYreturns expected rows.RECORD): Appended 2 columns toconfigs, hit liveno such field: evolved_col_str.on attempt 1/8 and recovered after 2 s retry; missing nested subfield (location: 'meta.extra',message: 'no such field: extra.', with unrelated top-levelextracolumn present) failed fast in 2.62 s with zero sleeps.INT64(> 2⁵³, int/str, nullable100.0 → 100),FLOAT64,BOOL,DATETIME(tz-offset + naive),DATE,TIMESTAMP,JSON(NaN→null+ JSON string),RECORD,REPEATED STRING, andSTRING; confirmed fractional float1.67into a non-allowlistedINT64column is NOT rounded and rejected live by BigQuery.STRINGrow (9,500,130 → 8,388,606bytes) with marker and wrote it; skipped an unshrinkable 9.5 MBJSONrow, still wrote sibling valid row, and raisedRuntimeErrornaming the skipped row.0LOADjobs inregion-us.INFORMATION_SCHEMA.JOBS_BY_USER.Related: #753 (
EvalServicereporter isolation and temp-file cleanup)