Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optional/Nullable support to Python Cluster Objects #11515

Merged

Conversation

mrjerryjohns
Copy link
Contributor

This amongst other things, adds support for optional and nullable types to the Python cluster objects. It does so by leveraging typing.Union and typing.Optional to do so. To represent nulls, a new Nullable type has
been created to encapsulate that.

Consequently, None indicates an optional field that is not present. NullValue indicates a null-value.

Consequently, the following representations map to the various combinations:

typing.Union[base-type, Types.Nullable] => a nullable base-type.
typing.Optional[base-type] => an optional base-type
typing.Union[base-type, Types.Nullable, None] => an optional, nullable,
base-type.

In addition, the generation helpers for Python have been cleaned up to better align with how it's done for the other languages.

Finally, a unit-test for the generated objects has been added which was crucial to fix some critical bugs in the implementation.

Tests:

  • Validated using test_generated_clusterobjects.py.
  • Validated by sending commands to the test cluster to a device.

This amongst other things, adds support for optional and nullable types
to the Python cluster objects. It does so by leveraging typing.Union and
typing.Optional to do so. To represent nulls, a new Nullable type has
been created to encapsulate that.

Consequently, 'None' indicates an optional field that is not present.
'NullValue' indicates a null-value.

Consequently, the following representations map to the various
combinations:

typing.Union[base-type, Types.Nullable] => a nullable base-type.
typing.Optional[base-type] => an optional base-type
typing.Union[base-type, Types.Nullable, None] => an optional, nullable,
base-type.

In addition, the generation helpers for Python have been cleaned up to
better align with how it's done for the other languages.

Finally, a unit-test for the generated objects has been added which was
crucial to fix some critical bugs in the implementation.

Tests:
- Validated using test_generated_clusterobjects.py.
- Validated by sending commands to the test cluster to a device.
@github-actions
Copy link

github-actions bot commented Nov 6, 2021

PR #11515: Size comparison from 6201b8e to f29bb8b

Full report (38 builds for efr32, esp32, k32w, linux, mbed, nrfconnect, p6, qpg, telink)
platform target config section 6201b8e f29bb8b change % change
efr32 lighting-app BRD4161A (read only) 745816 745816 0 0.0
(read/write) 115740 115740 0 0.0
.bss 113964 113964 0 0.0
.data 1776 1776 0 0.0
.text 745808 745808 0 0.0
BRD4161A+rpc (read only) 733352 733352 0 0.0
(read/write) 132364 132364 0 0.0
.bss 130468 130468 0 0.0
.data 1892 1892 0 0.0
.text 733344 733344 0 0.0
lock-app BRD4161A (read only) 725104 725104 0 0.0
(read/write) 113556 113556 0 0.0
.bss 111820 111820 0 0.0
.data 1736 1736 0 0.0
.text 725096 725096 0 0.0
window-app BRD4161A (read only) 726000 726000 0 0.0
(read/write) 113884 113884 0 0.0
.bss 112140 112140 0 0.0
.data 1740 1740 0 0.0
.text 725992 725992 0 0.0
esp32 all-clusters-app c3devkit (read only) 882758 882758 0 0.0
(read/write) 1306040 1306040 0 0.0
.dram0.bss 57608 57608 0 0.0
.dram0.data 16472 16472 0 0.0
.flash.rodata 198712 198712 0 0.0
.flash.text 882758 882758 0 0.0
.iram0.text 57624 57624 0 0.0
m5stack (read only) 913599 913599 0 0.0
(read/write) 423336 423336 0 0.0
.dram0.bss 60112 60112 0 0.0
.dram0.data 32108 32108 0 0.0
.flash.rodata 204952 204952 0 0.0
.flash.text 913599 913599 0 0.0
.iram0.text 125115 125115 0 0.0
k32w lighting-app k32w061+se05x+release (read/write) 699528 699528 0 0.0
.bss 77808 77808 0 0.0
.data 1908 1908 0 0.0
.text 614012 614012 0 0.0
lock-app k32w061+debug (read/write) 592332 592332 0 0.0
.bss 68340 68340 0 0.0
.data 1876 1876 0 0.0
.text 516316 516316 0 0.0
shell k32w061+debug (read/write) 657828 657828 0 0.0
.bss 78980 78980 0 0.0
.data 1844 1844 0 0.0
.text 571204 571204 0 0.0
linux all-clusters-app debug (read only) 1704161 1704161 0 0.0
(read/write) 119232 119232 0 0.0
.bss 50608 50608 0 0.0
.data 1042 1042 0 0.0
.data.rel.ro 62304 62304 0 0.0
.dynamic 592 592 0 0.0
.got 4088 4088 0 0.0
.init 27 27 0 0.0
.init_array 552 552 0 0.0
.rodata 139221 139221 0 0.0
.text 1431522 1431522 0 0.0
bridge-app debug+rpc (read only) 1292181 1292181 0 0.0
(read/write) 69808 69808 0 0.0
.bss 35536 35536 0 0.0
.data 1568 1568 0 0.0
.data.rel.ro 27736 27736 0 0.0
.dynamic 592 592 0 0.0
.got 3952 3952 0 0.0
.init 27 27 0 0.0
.init_array 408 408 0 0.0
.rodata 111028 111028 0 0.0
.text 1085285 1085285 0 0.0
chip-tool debug (read only) 4916093 4916093 0 0.0
(read/write) 126504 126504 0 0.0
.bss 18736 18736 0 0.0
.data 2224 2224 0 0.0
.data.rel.ro 100112 100112 0 0.0
.dynamic 592 592 0 0.0
.got 4368 4368 0 0.0
.init 27 27 0 0.0
.init_array 432 432 0 0.0
.rodata 232944 232944 0 0.0
.text 4414613 4414613 0 0.0
lighting-app debug+rpc (read only) 1553193 1553193 0 0.0
(read/write) 102776 102776 0 0.0
.bss 41176 41176 0 0.0
.data 1170 1170 0 0.0
.data.rel.ro 55136 55136 0 0.0
.dynamic 608 608 0 0.0
.got 4112 4112 0 0.0
.init 27 27 0 0.0
.init_array 536 536 0 0.0
.rodata 129649 129649 0 0.0
.text 1289986 1289986 0 0.0
ota-provider-app debug (read only) 1251385 1251385 0 0.0
(read/write) 67976 67976 0 0.0
.bss 37600 37600 0 0.0
.data 752 752 0 0.0
.data.rel.ro 24536 24536 0 0.0
.dynamic 592 592 0 0.0
.got 4016 4016 0 0.0
.init 27 27 0 0.0
.init_array 448 448 0 0.0
.rodata 112232 112232 0 0.0
.text 1043074 1043074 0 0.0
ota-requestor-app debug (read only) 1329681 1329681 0 0.0
(read/write) 77232 77232 0 0.0
.bss 45728 45728 0 0.0
.data 816 816 0 0.0
.data.rel.ro 25544 25544 0 0.0
.dynamic 592 592 0 0.0
.got 3992 3992 0 0.0
.init 27 27 0 0.0
.init_array 520 520 0 0.0
.rodata 124208 124208 0 0.0
.text 1107442 1107442 0 0.0
shell debug (read only) 788041 788041 0 0.0
(read/write) 58184 58184 0 0.0
.bss 16648 16648 0 0.0
.data 242 242 0 0.0
.data.rel.ro 36784 36784 0 0.0
.dynamic 592 592 0 0.0
.got 3528 3528 0 0.0
.init 27 27 0 0.0
.init_array 344 344 0 0.0
.rodata 77935 77935 0 0.0
.text 608642 608642 0 0.0
tv-app debug (read only) 1817153 1817153 0 0.0
(read/write) 290400 290400 0 0.0
.bss 223248 223248 0 0.0
.data 2704 2704 0 0.0
.data.rel.ro 58792 58792 0 0.0
.dynamic 592 592 0 0.0
.got 4408 4408 0 0.0
.init 27 27 0 0.0
.init_array 616 616 0 0.0
.rodata 155304 155304 0 0.0
.text 1519586 1519586 0 0.0
mbed all-clusters-app CY8CPROTO_062_4343W+release (read only) 6224 6224 0 0.0
(read/write) 2291640 2291640 0 0.0
.bss 178924 178924 0 0.0
.data 5224 5224 0 0.0
.heap 852296 852296 0 0.0
.text 1254240 1254240 0 0.0
lighting-app CY8CPROTO_062_4343W+release (read only) 6224 6224 0 0.0
(read/write) 2271736 2271736 0 0.0
.bss 171980 171980 0 0.0
.data 5576 5576 0 0.0
.heap 858888 858888 0 0.0
.text 1234336 1234336 0 0.0
lock-app CY8CPROTO_062_4343W+release (read only) 6224 6224 0 0.0
(read/write) 2249456 2249456 0 0.0
.bss 170876 170876 0 0.0
.data 5560 5560 0 0.0
.heap 860008 860008 0 0.0
.text 1212056 1212056 0 0.0
pigweed-app CY8CPROTO_062_4343W+release (read only) 6224 6224 0 0.0
(read/write) 1139744 1139744 0 0.0
.bss 11752 11752 0 0.0
.data 4368 4368 0 0.0
.heap 1020328 1020328 0 0.0
.text 103128 103128 0 0.0
shell CY8CPROTO_062_4343W+release (read only) 6224 6224 0 0.0
(read/write) 2048912 2048912 0 0.0
.bss 156256 156256 0 0.0
.data 4968 4968 0 0.0
.heap 875224 875224 0 0.0
.text 1011512 1011512 0 0.0
nrfconnect lighting-app nrf52840dk_nrf52840 (read/write) 861619 861619 0 0.0
bss 111280 111280 0 0.0
rodata 96932 96932 0 0.0
text 577776 577776 0 0.0
nrf52840dk_nrf52840+rpc (read/write) 823951 823951 0 0.0
bss 107632 107632 0 0.0
rodata 88112 88112 0 0.0
text 551924 551924 0 0.0
nrf5340dk_nrf5340_cpuapp (read/write) 786646 786646 0 0.0
bss 112652 112652 0 0.0
rodata 92192 92192 0 0.0
text 507236 507236 0 0.0
lock-app nrf52840dk_nrf52840 (read/write) 838327 838327 0 0.0
bss 110312 110312 0 0.0
rodata 93304 93304 0 0.0
text 559256 559256 0 0.0
nrf5340dk_nrf5340_cpuapp (read/write) 763622 763622 0 0.0
bss 111724 111724 0 0.0
rodata 88608 88608 0 0.0
text 488808 488808 0 0.0
pigweed-app nrf52840dk_nrf52840 (read/write) 497323 497323 0 0.0
bss 51824 51824 0 0.0
rodata 45776 45776 0 0.0
text 339436 339436 0 0.0
pump-app nrf52840dk_nrf52840 (read/write) 844419 844419 0 0.0
bss 110452 110452 0 0.0
rodata 95012 95012 0 0.0
text 563420 563420 0 0.0
pump-controller-app nrf52840dk_nrf52840 (read/write) 838183 838183 0 0.0
bss 110348 110348 0 0.0
rodata 93304 93304 0 0.0
text 558992 558992 0 0.0
shell nrf52840dk_nrf52840 (read/write) 776231 776231 0 0.0
bss 109100 109100 0 0.0
rodata 72540 72540 0 0.0
text 519988 519988 0 0.0
nrf5340dk_nrf5340_cpuapp (read/write) 691270 691270 0 0.0
bss 110084 110084 0 0.0
rodata 67184 67184 0 0.0
text 440584 440584 0 0.0
p6 all-clusters-app default (read/write) 2301104 2301104 0 0.0
.bss 106872 106872 0 0.0
.data 2528 2528 0 0.0
.heap 923944 923944 0 0.0
.text 1259368 1259368 0 0.0
lock-app default (read/write) 2213816 2213816 0 0.0
.bss 95680 95680 0 0.0
.data 2400 2400 0 0.0
.heap 935264 935264 0 0.0
.text 1172080 1172080 0 0.0
qpg lighting-app qpg6100+debug (read only) 490864 490864 0 0.0
(read/write) 114144 114144 0 0.0
.bss 50968 50968 0 0.0
.data 1008 1008 0 0.0
.text 485544 485544 0 0.0
lock-app qpg6100+debug (read only) 467212 467212 0 0.0
(read/write) 114140 114140 0 0.0
.bss 49912 49912 0 0.0
.data 964 964 0 0.0
.text 461892 461892 0 0.0
persistent-storage-app qpg6100+debug (read only) 153316 153316 0 0.0
(read/write) 114144 114144 0 0.0
.bss 19448 19448 0 0.0
.data 360 360 0 0.0
.text 147996 147996 0 0.0
telink lighting-app tlsr9518adk80d (read/write) 663218 663218 0 0.0
bss 69092 69092 0 0.0
noinit 33216 33216 0 0.0
text 458228 458228 0 0.0

@github-actions
Copy link

github-actions bot commented Nov 14, 2021

PR #11515: Size comparison from ea10a5d to 2f52efc

Increases above 0.2%:

platform target config section ea10a5d 2f52efc change % change
esp32 all-clusters-app c3devkit .flash.rodata 167704 168040 336 0.2
linux all-clusters-app debug (read only) 1713393 1722337 8944 0.5
(read/write) 126304 126816 512 0.4
.data.rel.ro 62304 62720 416 0.7
.text 1439250 1447842 8592 0.6
bridge-app debug+rpc (read only) 1307461 1312741 5280 0.4
.text 1098725 1103909 5184 0.5
chip-tool debug (read only) 4662317 4921493 259176 5.6
(read/write) 163976 167208 3232 2.0
.data.rel.ro 115024 118256 3232 2.8
.rodata 259730 268242 8512 3.3
.text 4100501 4343605 243104 5.9
lighting-app debug+rpc (read only) 1574201 1582281 8080 0.5
.text 1309762 1317746 7984 0.6
ota-provider-app debug (read only) 1262729 1267337 4608 0.4
.text 1052626 1057106 4480 0.4
ota-requestor-app debug (read only) 1347545 1352009 4464 0.3
.text 1124034 1128402 4368 0.4
tv-app debug (read only) 1853257 1858569 5312 0.3
.text 1551202 1556418 5216 0.3
telink lighting-app tlsr9518adk80d text 461088 462372 1284 0.3
Increases (34 builds for efr32, esp32, k32w, linux, mbed, nrfconnect, p6, qpg, telink)
platform target config section ea10a5d 2f52efc change % change
efr32 lighting-app BRD4161A (read only) 748808 750088 1280 0.2
.text 748800 750080 1280 0.2
BRD4161A+rpc (read only) 736372 737636 1264 0.2
.text 736364 737628 1264 0.2
lock-app BRD4161A (read only) 725648 726752 1104 0.2
.text 725640 726744 1104 0.2
window-app BRD4161A (read only) 726560 727744 1184 0.2
.text 726552 727736 1184 0.2
esp32 all-clusters-app c3devkit (read only) 825666 826956 1290 0.2
(read/write) 1224066 1224466 400 0.0
.dram0.bss 57016 57088 72 0.1
.flash.rodata 167704 168040 336 0.2
.flash.text 825666 826956 1290 0.2
m5stack (read only) 896459 897631 1172 0.1
(read/write) 422224 422624 400 0.1
.dram0.bss 62112 62184 72 0.1
.flash.rodata 194732 195060 328 0.2
.flash.text 891075 892247 1172 0.1
k32w lighting-app k32w061+se05x+release (read/write) 701740 702540 800 0.1
.text 616524 617324 800 0.1
lock-app k32w061+debug (read/write) 592956 593548 592 0.1
.text 517252 517844 592 0.1
shell k32w061+debug (read/write) 658640 659232 592 0.1
.text 572176 572768 592 0.1
linux all-clusters-app debug (read only) 1713393 1722337 8944 0.5
(read/write) 126304 126816 512 0.4
.bss 57680 57776 96 0.2
.data.rel.ro 62304 62720 416 0.7
.rodata 140117 140277 160 0.1
.text 1439250 1447842 8592 0.6
bridge-app debug+rpc (read only) 1307461 1312741 5280 0.4
.rodata 111764 111860 96 0.1
.text 1098725 1103909 5184 0.5
chip-tool debug (read only) 4662317 4921493 259176 5.6
(read/write) 163976 167208 3232 2.0
.data.rel.ro 115024 118256 3232 2.8
.rodata 259730 268242 8512 3.3
.text 4100501 4343605 243104 5.9
lighting-app debug+rpc (read only) 1574201 1582281 8080 0.5
.rodata 129745 129841 96 0.1
.text 1309762 1317746 7984 0.6
ota-provider-app debug (read only) 1262729 1267337 4608 0.4
.rodata 113255 113383 128 0.1
.text 1052626 1057106 4480 0.4
ota-requestor-app debug (read only) 1347545 1352009 4464 0.3
.rodata 124112 124208 96 0.1
.text 1124034 1128402 4368 0.4
shell debug (read only) 788969 789081 112 0.0
.text 609170 609282 112 0.0
tv-app debug (read only) 1853257 1858569 5312 0.3
.rodata 156973 157069 96 0.1
.text 1551202 1556418 5216 0.3
mbed all-clusters-app CY8CPROTO_062_4343W+release (read/write) 2291040 2292200 1160 0.1
.bss 179612 179692 80 0.0
.text 1253640 1254800 1160 0.1
lighting-app CY8CPROTO_062_4343W+release (read/write) 2273856 2274688 832 0.0
.text 1236456 1237288 832 0.1
lock-app CY8CPROTO_062_4343W+release (read/write) 2249552 2250128 576 0.0
.text 1212152 1212728 576 0.0
nrfconnect lighting-app nrf52840dk_nrf52840 (read/write) 864247 865175 928 0.1
text 580580 581516 936 0.2
nrf52840dk_nrf52840+rpc (read/write) 826619 827567 948 0.1
bss 107316 107320 4 0.0
rodata 88268 88272 4 0.0
text 554752 555688 936 0.2
nrf5340dk_nrf5340_cpuapp (read/write) 789286 790234 948 0.1
bss 112336 112340 4 0.0
rodata 92336 92340 4 0.0
text 510048 510984 936 0.2
lock-app nrf52840dk_nrf52840 (read/write) 839463 840199 736 0.1
text 560880 561616 736 0.1
nrf5340dk_nrf5340_cpuapp (read/write) 764778 765514 736 0.1
text 490440 491176 736 0.2
pump-app nrf52840dk_nrf52840 (read/write) 845559 846327 768 0.1
text 565044 565800 756 0.1
pump-controller-app nrf52840dk_nrf52840 (read/write) 839335 839903 568 0.1
text 560616 561236 620 0.1
shell nrf52840dk_nrf52840 (read/write) 775483 775499 16 0.0
text 520008 520020 12 0.0
nrf5340dk_nrf5340_cpuapp (read/write) 690538 690554 16 0.0
text 440616 440628 12 0.0
p6 all-clusters-app default (read/write) 2299576 2301232 1656 0.1
.bss 112608 112680 72 0.1
.text 1257840 1259496 1656 0.1
lock-app default (read/write) 2213616 2214704 1088 0.0
.text 1171880 1172968 1088 0.1
qpg lighting-app qpg6100+debug (read only) 493352 494216 864 0.2
.text 488032 488896 864 0.2
lock-app qpg6100+debug (read only) 468096 468752 656 0.1
.text 462776 463432 656 0.1
telink lighting-app tlsr9518adk80d (read/write) 666566 667854 1288 0.2
text 461088 462372 1284 0.3
Decreases (3 builds for mbed, nrfconnect, p6)
platform target config section ea10a5d 2f52efc change % change
mbed all-clusters-app CY8CPROTO_062_4343W+release .heap 851616 851536 -80 -0.0
nrfconnect pump-controller-app nrf52840dk_nrf52840 rodata 93144 93104 -40 -0.0
p6 all-clusters-app default .heap 918216 918144 -72 -0.0
Full report (38 builds for efr32, esp32, k32w, linux, mbed, nrfconnect, p6, qpg, telink)
platform target config section ea10a5d 2f52efc change % change
efr32 lighting-app BRD4161A (read only) 748808 750088 1280 0.2
(read/write) 115940 115940 0 0.0
.bss 114140 114140 0 0.0
.data 1800 1800 0 0.0
.text 748800 750080 1280 0.2
BRD4161A+rpc (read only) 736372 737636 1264 0.2
(read/write) 132568 132568 0 0.0
.bss 130644 130644 0 0.0
.data 1924 1924 0 0.0
.text 736364 737628 1264 0.2
lock-app BRD4161A (read only) 725648 726752 1104 0.2
(read/write) 113724 113724 0 0.0
.bss 111964 111964 0 0.0
.data 1756 1756 0 0.0
.text 725640 726744 1104 0.2
window-app BRD4161A (read only) 726560 727744 1184 0.2
(read/write) 114044 114044 0 0.0
.bss 112284 112284 0 0.0
.data 1760 1760 0 0.0
.text 726552 727736 1184 0.2
esp32 all-clusters-app c3devkit (read only) 825666 826956 1290 0.2
(read/write) 1224066 1224466 400 0.0
.dram0.bss 57016 57088 72 0.1
.dram0.data 14092 14092 0 0.0
.flash.rodata 167704 168040 336 0.2
.flash.text 825666 826956 1290 0.2
.iram0.text 61394 61394 0 0.0
m5stack (read only) 896459 897631 1172 0.1
(read/write) 422224 422624 400 0.1
.dram0.bss 62112 62184 72 0.1
.dram0.data 34056 34056 0 0.0
.flash.rodata 194732 195060 328 0.2
.flash.text 891075 892247 1172 0.1
.iram0.text 122987 122987 0 0.0
k32w lighting-app k32w061+se05x+release (read/write) 701740 702540 800 0.1
.bss 77508 77508 0 0.0
.data 1908 1908 0 0.0
.text 616524 617324 800 0.1
lock-app k32w061+debug (read/write) 592956 593548 592 0.1
.bss 68028 68028 0 0.0
.data 1876 1876 0 0.0
.text 517252 517844 592 0.1
shell k32w061+debug (read/write) 658640 659232 592 0.1
.bss 78820 78820 0 0.0
.data 1844 1844 0 0.0
.text 572176 572768 592 0.1
linux all-clusters-app debug (read only) 1713393 1722337 8944 0.5
(read/write) 126304 126816 512 0.4
.bss 57680 57776 96 0.2
.data 1042 1042 0 0.0
.data.rel.ro 62304 62720 416 0.7
.dynamic 592 592 0 0.0
.got 4112 4112 0 0.0
.init 27 27 0 0.0
.init_array 552 552 0 0.0
.rodata 140117 140277 160 0.1
.text 1439250 1447842 8592 0.6
bridge-app debug+rpc (read only) 1307461 1312741 5280 0.4
(read/write) 77424 77424 0 0.0
.bss 42896 42896 0 0.0
.data 1568 1568 0 0.0
.data.rel.ro 27960 27960 0 0.0
.dynamic 592 592 0 0.0
.got 3984 3984 0 0.0
.init 27 27 0 0.0
.init_array 408 408 0 0.0
.rodata 111764 111860 96 0.1
.text 1098725 1103909 5184 0.5
chip-tool debug (read only) 4662317 4921493 259176 5.6
(read/write) 163976 167208 3232 2.0
.bss 41192 41192 0 0.0
.data 2272 2272 0 0.0
.data.rel.ro 115024 118256 3232 2.8
.dynamic 592 592 0 0.0
.got 4416 4416 0 0.0
.init 27 27 0 0.0
.init_array 472 472 0 0.0
.rodata 259730 268242 8512 3.3
.text 4100501 4343605 243104 5.9
lighting-app debug+rpc (read only) 1574201 1582281 8080 0.5
(read/write) 110192 110192 0 0.0
.bss 48080 48080 0 0.0
.data 1234 1234 0 0.0
.data.rel.ro 55552 55552 0 0.0
.dynamic 608 608 0 0.0
.got 4136 4136 0 0.0
.init 27 27 0 0.0
.init_array 536 536 0 0.0
.rodata 129745 129841 96 0.1
.text 1309762 1317746 7984 0.6
ota-provider-app debug (read only) 1262729 1267337 4608 0.4
(read/write) 75176 75176 0 0.0
.bss 44512 44512 0 0.0
.data 784 784 0 0.0
.data.rel.ro 24776 24776 0 0.0
.dynamic 592 592 0 0.0
.got 4016 4016 0 0.0
.init 27 27 0 0.0
.init_array 448 448 0 0.0
.rodata 113255 113383 128 0.1
.text 1052626 1057106 4480 0.4
ota-requestor-app debug (read only) 1347545 1352009 4464 0.3
(read/write) 78944 78944 0 0.0
.bss 46976 46976 0 0.0
.data 848 848 0 0.0
.data.rel.ro 26040 26040 0 0.0
.dynamic 592 592 0 0.0
.got 3992 3992 0 0.0
.init 27 27 0 0.0
.init_array 472 472 0 0.0
.rodata 124112 124208 96 0.1
.text 1124034 1128402 4368 0.4
shell debug (read only) 788969 789081 112 0.0
(read/write) 65064 65064 0 0.0
.bss 23400 23400 0 0.0
.data 242 242 0 0.0
.data.rel.ro 36928 36928 0 0.0
.dynamic 592 592 0 0.0
.got 3528 3528 0 0.0
.init 27 27 0 0.0
.init_array 344 344 0 0.0
.rodata 77903 77903 0 0.0
.text 609170 609282 112 0.0
tv-app debug (read only) 1853257 1858569 5312 0.3
(read/write) 407896 407896 0 0.0
.bss 339752 339752 0 0.0
.data 2768 2768 0 0.0
.data.rel.ro 59696 59696 0 0.0
.dynamic 592 592 0 0.0
.got 4432 4432 0 0.0
.init 27 27 0 0.0
.init_array 616 616 0 0.0
.rodata 156973 157069 96 0.1
.text 1551202 1556418 5216 0.3
mbed all-clusters-app CY8CPROTO_062_4343W+release (read only) 6224 6224 0 0.0
(read/write) 2291040 2292200 1160 0.1
.bss 179612 179692 80 0.0
.data 5216 5216 0 0.0
.heap 851616 851536 -80 -0.0
.text 1253640 1254800 1160 0.1
lighting-app CY8CPROTO_062_4343W+release (read only) 6224 6224 0 0.0
(read/write) 2273856 2274688 832 0.0
.bss 172556 172556 0 0.0
.data 5576 5576 0 0.0
.heap 858312 858312 0 0.0
.text 1236456 1237288 832 0.1
lock-app CY8CPROTO_062_4343W+release (read only) 6224 6224 0 0.0
(read/write) 2249552 2250128 576 0.0
.bss 171436 171436 0 0.0
.data 5568 5568 0 0.0
.heap 859440 859440 0 0.0
.text 1212152 1212728 576 0.0
pigweed-app CY8CPROTO_062_4343W+release (read only) 6224 6224 0 0.0
(read/write) 1139744 1139744 0 0.0
.bss 11752 11752 0 0.0
.data 4368 4368 0 0.0
.heap 1020328 1020328 0 0.0
.text 103128 103128 0 0.0
shell CY8CPROTO_062_4343W+release (read only) 6224 6224 0 0.0
(read/write) 2048376 2048376 0 0.0
.bss 155912 155912 0 0.0
.data 4968 4968 0 0.0
.heap 875568 875568 0 0.0
.text 1010976 1010976 0 0.0
nrfconnect lighting-app nrf52840dk_nrf52840 (read/write) 864247 865175 928 0.1
bss 110964 110964 0 0.0
rodata 97080 97080 0 0.0
text 580580 581516 936 0.2
nrf52840dk_nrf52840+rpc (read/write) 826619 827567 948 0.1
bss 107316 107320 4 0.0
rodata 88268 88272 4 0.0
text 554752 555688 936 0.2
nrf5340dk_nrf5340_cpuapp (read/write) 789286 790234 948 0.1
bss 112336 112340 4 0.0
rodata 92336 92340 4 0.0
text 510048 510984 936 0.2
lock-app nrf52840dk_nrf52840 (read/write) 839463 840199 736 0.1
bss 109988 109988 0 0.0
rodata 93144 93144 0 0.0
text 560880 561616 736 0.1
nrf5340dk_nrf5340_cpuapp (read/write) 764778 765514 736 0.1
bss 111400 111400 0 0.0
rodata 88452 88452 0 0.0
text 490440 491176 736 0.2
pigweed-app nrf52840dk_nrf52840 (read/write) 497327 497327 0 0.0
bss 51824 51824 0 0.0
rodata 45780 45780 0 0.0
text 339436 339436 0 0.0
pump-app nrf52840dk_nrf52840 (read/write) 845559 846327 768 0.1
bss 110128 110128 0 0.0
rodata 94856 94856 0 0.0
text 565044 565800 756 0.1
pump-controller-app nrf52840dk_nrf52840 (read/write) 839335 839903 568 0.1
bss 110024 110024 0 0.0
rodata 93144 93104 -40 -0.0
text 560616 561236 620 0.1
shell nrf52840dk_nrf52840 (read/write) 775483 775499 16 0.0
bss 108736 108736 0 0.0
rodata 72160 72160 0 0.0
text 520008 520020 12 0.0
nrf5340dk_nrf5340_cpuapp (read/write) 690538 690554 16 0.0
bss 109720 109720 0 0.0
rodata 66804 66804 0 0.0
text 440616 440628 12 0.0
p6 all-clusters-app default (read/write) 2299576 2301232 1656 0.1
.bss 112608 112680 72 0.1
.data 2520 2520 0 0.0
.heap 918216 918144 -72 -0.0
.text 1257840 1259496 1656 0.1
lock-app default (read/write) 2213616 2214704 1088 0.0
.bss 101296 101296 0 0.0
.data 2400 2400 0 0.0
.heap 929648 929648 0 0.0
.text 1171880 1172968 1088 0.1
qpg lighting-app qpg6100+debug (read only) 493352 494216 864 0.2
(read/write) 114144 114144 0 0.0
.bss 50640 50640 0 0.0
.data 1008 1008 0 0.0
.text 488032 488896 864 0.2
lock-app qpg6100+debug (read only) 468096 468752 656 0.1
(read/write) 114140 114140 0 0.0
.bss 49576 49576 0 0.0
.data 964 964 0 0.0
.text 462776 463432 656 0.1
persistent-storage-app qpg6100+debug (read only) 105408 105408 0 0.0
(read/write) 114142 114142 0 0.0
.bss 8978 8978 0 0.0
.data 272 272 0 0.0
.text 100088 100088 0 0.0
telink lighting-app tlsr9518adk80d (read/write) 666566 667854 1288 0.2
bss 69320 69320 0 0.0
noinit 33216 33216 0 0.0
text 461088 462372 1284 0.3

@mrjerryjohns mrjerryjohns force-pushed the python/nullable-optional branch from 72c1899 to 93d06c9 Compare November 15, 2021 00:13
@github-actions
Copy link

github-actions bot commented Nov 15, 2021

PR #11515: Size comparison from 507ba15 to 93d06c9

Full report (38 builds for efr32, esp32, k32w, linux, mbed, nrfconnect, p6, qpg, telink)
platform target config section 507ba15 93d06c9 change % change
efr32 lighting-app BRD4161A (read only) 750088 750088 0 0.0
(read/write) 115940 115940 0 0.0
.bss 114140 114140 0 0.0
.data 1800 1800 0 0.0
.text 750080 750080 0 0.0
BRD4161A+rpc (read only) 737636 737636 0 0.0
(read/write) 132568 132568 0 0.0
.bss 130644 130644 0 0.0
.data 1924 1924 0 0.0
.text 737628 737628 0 0.0
lock-app BRD4161A (read only) 726752 726752 0 0.0
(read/write) 113724 113724 0 0.0
.bss 111964 111964 0 0.0
.data 1756 1756 0 0.0
.text 726744 726744 0 0.0
window-app BRD4161A (read only) 727744 727744 0 0.0
(read/write) 114044 114044 0 0.0
.bss 112284 112284 0 0.0
.data 1760 1760 0 0.0
.text 727736 727736 0 0.0
esp32 all-clusters-app c3devkit (read only) 826956 826956 0 0.0
(read/write) 1224466 1224466 0 0.0
.dram0.bss 57088 57088 0 0.0
.dram0.data 14092 14092 0 0.0
.flash.rodata 168040 168040 0 0.0
.flash.text 826956 826956 0 0.0
.iram0.text 61394 61394 0 0.0
m5stack (read only) 897631 897631 0 0.0
(read/write) 422624 422624 0 0.0
.dram0.bss 62184 62184 0 0.0
.dram0.data 34056 34056 0 0.0
.flash.rodata 195060 195060 0 0.0
.flash.text 892247 892247 0 0.0
.iram0.text 122987 122987 0 0.0
k32w lighting-app k32w061+se05x+release (read/write) 702540 702540 0 0.0
.bss 77508 77508 0 0.0
.data 1908 1908 0 0.0
.text 617324 617324 0 0.0
lock-app k32w061+debug (read/write) 593548 593548 0 0.0
.bss 68028 68028 0 0.0
.data 1876 1876 0 0.0
.text 517844 517844 0 0.0
shell k32w061+debug (read/write) 659232 659232 0 0.0
.bss 78820 78820 0 0.0
.data 1844 1844 0 0.0
.text 572768 572768 0 0.0
linux all-clusters-app debug (read only) 1722337 1722337 0 0.0
(read/write) 126816 126816 0 0.0
.bss 57776 57776 0 0.0
.data 1042 1042 0 0.0
.data.rel.ro 62720 62720 0 0.0
.dynamic 592 592 0 0.0
.got 4112 4112 0 0.0
.init 27 27 0 0.0
.init_array 552 552 0 0.0
.rodata 140277 140277 0 0.0
.text 1447842 1447842 0 0.0
bridge-app debug+rpc (read only) 1312741 1312741 0 0.0
(read/write) 77424 77424 0 0.0
.bss 42896 42896 0 0.0
.data 1568 1568 0 0.0
.data.rel.ro 27960 27960 0 0.0
.dynamic 592 592 0 0.0
.got 3984 3984 0 0.0
.init 27 27 0 0.0
.init_array 408 408 0 0.0
.rodata 111860 111860 0 0.0
.text 1103909 1103909 0 0.0
chip-tool debug (read only) 4921493 4921493 0 0.0
(read/write) 167208 167208 0 0.0
.bss 41192 41192 0 0.0
.data 2272 2272 0 0.0
.data.rel.ro 118256 118256 0 0.0
.dynamic 592 592 0 0.0
.got 4416 4416 0 0.0
.init 27 27 0 0.0
.init_array 472 472 0 0.0
.rodata 268242 268242 0 0.0
.text 4343605 4343605 0 0.0
lighting-app debug+rpc (read only) 1582281 1582281 0 0.0
(read/write) 110192 110192 0 0.0
.bss 48080 48080 0 0.0
.data 1234 1234 0 0.0
.data.rel.ro 55552 55552 0 0.0
.dynamic 608 608 0 0.0
.got 4136 4136 0 0.0
.init 27 27 0 0.0
.init_array 536 536 0 0.0
.rodata 129841 129841 0 0.0
.text 1317746 1317746 0 0.0
ota-provider-app debug (read only) 1267337 1267337 0 0.0
(read/write) 75176 75176 0 0.0
.bss 44512 44512 0 0.0
.data 784 784 0 0.0
.data.rel.ro 24776 24776 0 0.0
.dynamic 592 592 0 0.0
.got 4016 4016 0 0.0
.init 27 27 0 0.0
.init_array 448 448 0 0.0
.rodata 113383 113383 0 0.0
.text 1057106 1057106 0 0.0
ota-requestor-app debug (read only) 1352009 1352009 0 0.0
(read/write) 78944 78944 0 0.0
.bss 46976 46976 0 0.0
.data 848 848 0 0.0
.data.rel.ro 26040 26040 0 0.0
.dynamic 592 592 0 0.0
.got 3992 3992 0 0.0
.init 27 27 0 0.0
.init_array 472 472 0 0.0
.rodata 124208 124208 0 0.0
.text 1128402 1128402 0 0.0
shell debug (read only) 789081 789081 0 0.0
(read/write) 65064 65064 0 0.0
.bss 23400 23400 0 0.0
.data 242 242 0 0.0
.data.rel.ro 36928 36928 0 0.0
.dynamic 592 592 0 0.0
.got 3528 3528 0 0.0
.init 27 27 0 0.0
.init_array 344 344 0 0.0
.rodata 77903 77903 0 0.0
.text 609282 609282 0 0.0
tv-app debug (read only) 1858569 1858569 0 0.0
(read/write) 407896 407896 0 0.0
.bss 339752 339752 0 0.0
.data 2768 2768 0 0.0
.data.rel.ro 59696 59696 0 0.0
.dynamic 592 592 0 0.0
.got 4432 4432 0 0.0
.init 27 27 0 0.0
.init_array 616 616 0 0.0
.rodata 157069 157069 0 0.0
.text 1556418 1556418 0 0.0
mbed all-clusters-app CY8CPROTO_062_4343W+release (read only) 6224 6224 0 0.0
(read/write) 2292200 2292200 0 0.0
.bss 179692 179692 0 0.0
.data 5216 5216 0 0.0
.heap 851536 851536 0 0.0
.text 1254800 1254800 0 0.0
lighting-app CY8CPROTO_062_4343W+release (read only) 6224 6224 0 0.0
(read/write) 2274688 2274688 0 0.0
.bss 172556 172556 0 0.0
.data 5576 5576 0 0.0
.heap 858312 858312 0 0.0
.text 1237288 1237288 0 0.0
lock-app CY8CPROTO_062_4343W+release (read only) 6224 6224 0 0.0
(read/write) 2250128 2250128 0 0.0
.bss 171436 171436 0 0.0
.data 5568 5568 0 0.0
.heap 859440 859440 0 0.0
.text 1212728 1212728 0 0.0
pigweed-app CY8CPROTO_062_4343W+release (read only) 6224 6224 0 0.0
(read/write) 1139744 1139744 0 0.0
.bss 11752 11752 0 0.0
.data 4368 4368 0 0.0
.heap 1020328 1020328 0 0.0
.text 103128 103128 0 0.0
shell CY8CPROTO_062_4343W+release (read only) 6224 6224 0 0.0
(read/write) 2048376 2048376 0 0.0
.bss 155912 155912 0 0.0
.data 4968 4968 0 0.0
.heap 875568 875568 0 0.0
.text 1010976 1010976 0 0.0
nrfconnect lighting-app nrf52840dk_nrf52840 (read/write) 865175 865175 0 0.0
bss 110964 110964 0 0.0
rodata 97080 97080 0 0.0
text 581516 581516 0 0.0
nrf52840dk_nrf52840+rpc (read/write) 827567 827567 0 0.0
bss 107320 107320 0 0.0
rodata 88272 88272 0 0.0
text 555688 555688 0 0.0
nrf5340dk_nrf5340_cpuapp (read/write) 790234 790234 0 0.0
bss 112340 112340 0 0.0
rodata 92340 92340 0 0.0
text 510984 510984 0 0.0
lock-app nrf52840dk_nrf52840 (read/write) 840199 840199 0 0.0
bss 109988 109988 0 0.0
rodata 93144 93144 0 0.0
text 561616 561616 0 0.0
nrf5340dk_nrf5340_cpuapp (read/write) 765514 765514 0 0.0
bss 111400 111400 0 0.0
rodata 88452 88452 0 0.0
text 491176 491176 0 0.0
pigweed-app nrf52840dk_nrf52840 (read/write) 497327 497327 0 0.0
bss 51824 51824 0 0.0
rodata 45780 45780 0 0.0
text 339436 339436 0 0.0
pump-app nrf52840dk_nrf52840 (read/write) 846327 846327 0 0.0
bss 110128 110128 0 0.0
rodata 94856 94856 0 0.0
text 565800 565800 0 0.0
pump-controller-app nrf52840dk_nrf52840 (read/write) 839903 839903 0 0.0
bss 110024 110024 0 0.0
rodata 93104 93104 0 0.0
text 561236 561236 0 0.0
shell nrf52840dk_nrf52840 (read/write) 775499 775499 0 0.0
bss 108736 108736 0 0.0
rodata 72160 72160 0 0.0
text 520020 520020 0 0.0
nrf5340dk_nrf5340_cpuapp (read/write) 690554 690554 0 0.0
bss 109720 109720 0 0.0
rodata 66804 66804 0 0.0
text 440628 440628 0 0.0
p6 all-clusters-app default (read/write) 2301232 2301232 0 0.0
.bss 112680 112680 0 0.0
.data 2520 2520 0 0.0
.heap 918144 918144 0 0.0
.text 1259496 1259496 0 0.0
lock-app default (read/write) 2214704 2214704 0 0.0
.bss 101296 101296 0 0.0
.data 2400 2400 0 0.0
.heap 929648 929648 0 0.0
.text 1172968 1172968 0 0.0
qpg lighting-app qpg6100+debug (read only) 494216 494216 0 0.0
(read/write) 114144 114144 0 0.0
.bss 50640 50640 0 0.0
.data 1008 1008 0 0.0
.text 488896 488896 0 0.0
lock-app qpg6100+debug (read only) 468752 468752 0 0.0
(read/write) 114140 114140 0 0.0
.bss 49576 49576 0 0.0
.data 964 964 0 0.0
.text 463432 463432 0 0.0
persistent-storage-app qpg6100+debug (read only) 105408 105408 0 0.0
(read/write) 114142 114142 0 0.0
.bss 8978 8978 0 0.0
.data 272 272 0 0.0
.text 100088 100088 0 0.0
telink lighting-app tlsr9518adk80d (read/write) 667854 667854 0 0.0
bss 69320 69320 0 0.0
noinit 33216 33216 0 0.0
text 462372 462372 0 0.0

@andy31415
Copy link
Contributor

fast track: open for a long time, had sufficient time for feedback (and several comments provided & resolved). PR created and reviwed by domain owner.

@mrjerryjohns mrjerryjohns merged commit 8f23aa6 into project-chip:master Nov 15, 2021
PSONALl pushed a commit to PSONALl/connectedhomeip that referenced this pull request Dec 3, 2021
* Optional/Nullable support to Python Cluster Objects

This amongst other things, adds support for optional and nullable types
to the Python cluster objects. It does so by leveraging typing.Union and
typing.Optional to do so. To represent nulls, a new Nullable type has
been created to encapsulate that.

Consequently, 'None' indicates an optional field that is not present.
'NullValue' indicates a null-value.

Consequently, the following representations map to the various
combinations:

typing.Union[base-type, Types.Nullable] => a nullable base-type.
typing.Optional[base-type] => an optional base-type
typing.Union[base-type, Types.Nullable, None] => an optional, nullable,
base-type.

In addition, the generation helpers for Python have been cleaned up to
better align with how it's done for the other languages.

Finally, a unit-test for the generated objects has been added which was
crucial to fix some critical bugs in the implementation.

Tests:
- Validated using test_generated_clusterobjects.py.
- Validated by sending commands to the test cluster to a device.

* Review feedback

* Fixes the equality comparison in Python for Nones

* Re-gen cluster objects

* Adding debug mode to the newly added unit test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants