Commit c706759
feat: create
* Refactor function deployment to avoid code duplication
This commit refactors the implementation of immediate deployment
for remote functions and UDFs to eliminate code duplication introduced
in a previous commit.
Changes:
- The `remote_function` and `udf` methods in
`bigframes.functions._function_session.FunctionSession` now accept
an optional `deploy_immediately: bool` parameter (defaulting to `False`).
The previous `deploy_remote_function` and `deploy_udf` methods in
`FunctionSession` have been removed, and their logic is now
incorporated into the unified methods.
- The public API functions `bigframes.pandas.deploy_remote_function`
and `bigframes.pandas.deploy_udf` now call the corresponding
`FunctionSession` methods with `deploy_immediately=True`.
- The public API functions `bigframes.pandas.remote_function` and
`bigframes.pandas.udf` call the `FunctionSession` methods
with `deploy_immediately=False` (relying on the default).
- Unit tests in `tests/unit/functions/test_remote_function.py` have
been updated to patch the unified `FunctionSession` methods and
verify the correct `deploy_immediately` boolean is passed based on
which public API function is called.
Note: The underlying provisioning logic in `FunctionSession` currently
deploys functions immediately regardless of the `deploy_immediately`
flag. This flag serves as an indicator of intent and allows for
future enhancements to support true lazy deployment if desired, without
further API changes.
* Refactor function deployment to use distinct methods
This commit corrects a previous refactoring attempt to eliminate
code duplication and properly separates immediate-deployment functions
from standard (potentially lazy) functions.
Changes:
- `bigframes.functions._function_session.FunctionSession` now has
distinct methods: `remote_function`, `udf`,
`deploy_remote_function`, and `deploy_udf`. The
`deploy_immediately` flag has been removed from this class.
- `deploy_remote_function` and `deploy_udf` methods in
`FunctionSession` are responsible for ensuring immediate
deployment by calling the underlying provisioning logic directly.
The standard `remote_function` and `udf` methods in
`FunctionSession` also currently call this provisioning logic,
meaning all functions are deployed immediately as of now, but the
structure allows for future lazy evaluation for standard functions
without changing the deploy variants' contract.
- Public API functions in `bigframes.pandas` (`remote_function`,
`udf`, `deploy_remote_function`, `deploy_udf`) now correctly
delegate to their corresponding distinct methods in `FunctionSession`
(via the `Session` object).
- Unit tests in `tests/unit/functions/test_remote_function.py` have
been updated to mock and verify calls to the correct distinct
methods on `bigframes.session.Session`.
This resolves the issue of using a boolean flag to control
deployment type and instead relies on calling specific, dedicated
methods for immediate deployment, aligning with your request.
* Simplify internal deploy_remote_function and deploy_udf calls
This commit simplifies the implementation of
`deploy_remote_function` and `deploy_udf` within
`bigframes.functions._function_session.FunctionSession`.
Given that the standard `remote_function` and `udf` methods in
`FunctionSession` already perform immediate deployment of resources
(as the underlying provisioning logic they call is immediate),
the `deploy_remote_function` and `deploy_udf` methods in the
same class are simplified to directly call `self.remote_function(...)`
and `self.udf(...)` respectively.
This change makes the distinction between the `deploy_` variants and
the standard variants in `FunctionSession` primarily a matter of
semantic clarity and intent at that level; both paths currently
result in immediate deployment. The public API in `bigframes.pandas`
continues to offer distinct `deploy_` functions that call these
`FunctionSession.deploy_` methods, preserving your user-facing API
and its documented behavior of immediate deployment.
No changes were needed for the public API in `bigframes.pandas` or
the unit tests, as they were already aligned with calling distinct
methods on the `Session` object, which in turn calls the
now-simplified `FunctionSession` methods.
* add tests and use kwargs
* add missing func argument to bpd
---------
Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>deploy_remote_function and deploy_udf functions to immediately deploy functions to BigQuery (#1832)1 parent c06d8db commit c706759
File tree
5 files changed
+214
-4
lines changed- bigframes
- core
- functions
- pandas
- session
- tests/unit/functions
5 files changed
+214
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
110 | 110 | | |
111 | 111 | | |
112 | 112 | | |
113 | | - | |
114 | | - | |
| 113 | + | |
| 114 | + | |
115 | 115 | | |
116 | 116 | | |
117 | 117 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
668 | 668 | | |
669 | 669 | | |
670 | 670 | | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
671 | 695 | | |
672 | 696 | | |
673 | 697 | | |
| |||
866 | 890 | | |
867 | 891 | | |
868 | 892 | | |
| 893 | + | |
| 894 | + | |
| 895 | + | |
| 896 | + | |
| 897 | + | |
| 898 | + | |
| 899 | + | |
| 900 | + | |
| 901 | + | |
| 902 | + | |
| 903 | + | |
| 904 | + | |
| 905 | + | |
| 906 | + | |
| 907 | + | |
| 908 | + | |
| 909 | + | |
| 910 | + | |
| 911 | + | |
| 912 | + | |
| 913 | + | |
| 914 | + | |
| 915 | + | |
| 916 | + | |
| 917 | + | |
| 918 | + | |
869 | 919 | | |
870 | 920 | | |
871 | 921 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
117 | 117 | | |
118 | 118 | | |
119 | 119 | | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
120 | 136 | | |
121 | 137 | | |
122 | 138 | | |
| |||
140 | 156 | | |
141 | 157 | | |
142 | 158 | | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
143 | 173 | | |
144 | 174 | | |
145 | 175 | | |
| |||
330 | 360 | | |
331 | 361 | | |
332 | 362 | | |
| 363 | + | |
| 364 | + | |
333 | 365 | | |
334 | 366 | | |
335 | 367 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1343 | 1343 | | |
1344 | 1344 | | |
1345 | 1345 | | |
| 1346 | + | |
| 1347 | + | |
| 1348 | + | |
| 1349 | + | |
| 1350 | + | |
| 1351 | + | |
| 1352 | + | |
| 1353 | + | |
| 1354 | + | |
| 1355 | + | |
| 1356 | + | |
| 1357 | + | |
| 1358 | + | |
| 1359 | + | |
| 1360 | + | |
| 1361 | + | |
| 1362 | + | |
| 1363 | + | |
| 1364 | + | |
| 1365 | + | |
| 1366 | + | |
| 1367 | + | |
| 1368 | + | |
| 1369 | + | |
| 1370 | + | |
| 1371 | + | |
| 1372 | + | |
| 1373 | + | |
| 1374 | + | |
| 1375 | + | |
| 1376 | + | |
| 1377 | + | |
| 1378 | + | |
| 1379 | + | |
1346 | 1380 | | |
1347 | 1381 | | |
1348 | 1382 | | |
| |||
1565 | 1599 | | |
1566 | 1600 | | |
1567 | 1601 | | |
| 1602 | + | |
| 1603 | + | |
| 1604 | + | |
| 1605 | + | |
| 1606 | + | |
| 1607 | + | |
| 1608 | + | |
1568 | 1609 | | |
1569 | 1610 | | |
1570 | | - | |
1571 | 1611 | | |
1572 | 1612 | | |
1573 | 1613 | | |
| |||
1585 | 1625 | | |
1586 | 1626 | | |
1587 | 1627 | | |
| 1628 | + | |
| 1629 | + | |
| 1630 | + | |
| 1631 | + | |
| 1632 | + | |
| 1633 | + | |
| 1634 | + | |
| 1635 | + | |
| 1636 | + | |
| 1637 | + | |
| 1638 | + | |
| 1639 | + | |
| 1640 | + | |
| 1641 | + | |
| 1642 | + | |
| 1643 | + | |
| 1644 | + | |
| 1645 | + | |
| 1646 | + | |
| 1647 | + | |
| 1648 | + | |
| 1649 | + | |
| 1650 | + | |
| 1651 | + | |
| 1652 | + | |
| 1653 | + | |
| 1654 | + | |
| 1655 | + | |
| 1656 | + | |
| 1657 | + | |
| 1658 | + | |
1588 | 1659 | | |
1589 | 1660 | | |
1590 | 1661 | | |
| |||
1726 | 1797 | | |
1727 | 1798 | | |
1728 | 1799 | | |
| 1800 | + | |
| 1801 | + | |
| 1802 | + | |
| 1803 | + | |
1729 | 1804 | | |
1730 | 1805 | | |
1731 | | - | |
1732 | 1806 | | |
1733 | 1807 | | |
1734 | 1808 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
89 | 89 | | |
90 | 90 | | |
91 | 91 | | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
0 commit comments