Skip to content

Commit 7cb7e76

Browse files
committed
use uv for script reproducibility
1 parent c6b94fa commit 7cb7e76

1 file changed

Lines changed: 39 additions & 0 deletions

File tree

packages/bigframes/specs/bigframes-bigquery-generator.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,40 @@ through all the same yaml files and checks that the functions have been included
1616
in the `bigframes.bigquery` module, as the `__init__.py` file requires manual
1717
updates.
1818

19+
## Running the generator
20+
21+
Since the dependencies for the script differ from that of bigframes
22+
and its test suite, use the self-contained Python script technique described at
23+
https://docs.astral.sh/uv/guides/scripts/
24+
to automatically manage dependencies using `uv`. Therefore, the header of the
25+
script will look something like:
26+
27+
```python
28+
#!/usr/bin/env -S uv run --script
29+
#
30+
# /// script
31+
# dependencies = [
32+
# "jinja2",
33+
# "pyyaml",
34+
# ]
35+
# ///
36+
#
37+
# Copyright 2026 Google LLC
38+
#
39+
# Licensed under the Apache License, Version 2.0 (the "License");
40+
# ...
41+
```
42+
43+
To run the script:
44+
45+
```bash
46+
cd packages/bigframes
47+
uv run scripts/generate_bigframes_bigquery.py
48+
```
49+
50+
To improve reproducibility, we also check in the uv lock file generated by
51+
running `uv lock --script scripts/generate_bigframes_bigquery.py`.
52+
1953
## Generated code organization
2054

2155
The `generate_bigframes_bigquery.py` script generates submodules of
@@ -31,6 +65,11 @@ to the `bigframes.bigquery._operations.builtins.bit` submodule.
3165
Each generated module has all functions defined in the YAML file converted to
3266
the equivalent Python definition, including keyword arguments and docstrings.
3367

68+
### Code generation
69+
70+
The code will be templated using the jinja2 template engine. This allows
71+
proposed changes to the templated code to be reviewed more easily.
72+
3473
### Handling optional arguments
3574

3675
When the user calls a Python function without specifying the optional

0 commit comments

Comments
 (0)