-
Notifications
You must be signed in to change notification settings - Fork 82
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
handling global attributes per cluster #1142
Conversation
@tecimovic @bzbarsky-apple @brdandu proof of concept for changing global attributes on a per cluster basis. I am aware that I need to clean it up but It works. |
71f91b8
to
2a22341
Compare
ready for review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just tested, and this does not seem to fix #543 in any of the contexts I looked at:
- We are still ending up with accessor codegen for global attributes when we should not.
- We are not getting the relevant attributes flagged as external in endpoint_config.h
- zap convert is not marking them external in the .zap file.
Thank you. I will work on those cases tomorrow. |
098292d
to
2a22341
Compare
Codecov Report
@@ Coverage Diff @@
## master #1142 +/- ##
==========================================
+ Coverage 65.16% 65.25% +0.08%
==========================================
Files 170 171 +1
Lines 18232 18284 +52
Branches 3927 3936 +9
==========================================
+ Hits 11881 11931 +50
- Misses 6351 6353 +2
|
src-electron/db/query-upgrade.js
Outdated
const fs = require('fs') | ||
const fsp = fs.promises | ||
|
||
async function selectClusterName(db, clusterRef) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you need this move this to query-cluster.js
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
originally I had it there but will probably just do what you suggested above, thanks
src-electron/db/query-upgrade.js
Outdated
return attributeName[0].NAME | ||
} | ||
|
||
async function queryMetaFile(db, packageId) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use query-package#getPackageByPackageId instead and get rid of this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unfortunately that query does not retrieve the PATH which I need
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm are you sure: I see
const querySelectFromPackage =
SELECT
PACKAGE_ID,
PATH,
TYPE,
CRC,
VERSION,
CATEGORY,
DESCRIPTION
FROM PACKAGE ``
Also fix Zigbee Code generation Issue in the CI |
src-electron/db/query-upgrade.js
Outdated
* @returns An array of objects | ||
*/ | ||
|
||
async function checkGlobals(db, attributeId) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This name is way more generic than the documented behavior of the function. And how does the attributeId fit in with the documented behavior bit? It does not seem to be used below....
I suspect this function just needs to be renamed to reflect what it actually does.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
agree, will fix, thanks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
attributeId is used to get the associated package
src-electron/db/query-upgrade.js
Outdated
* @returns A flag. | ||
*/ | ||
|
||
async function checkStorage( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps computeStorageOption?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sounds good to me, will fix, thanks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@paulr34 Actually, there is one more thing still broken here. This template:
{{#zcl_clusters}}
{{#zcl_attributes_server}}
{{#unless (isStrEqual storagePolicy "attributeAccessInterface")}}
does not behave correctly, because for global attributes this query is not producing the right storagePolicy.....
Thank you for catching this. I'm on it. |
|
@bzbarsky-apple is the above list correct? or out of date? |
e8b944b
to
9f6b561
Compare
src-electron/db/query-upgrade.js
Outdated
if (forcedExternal.lists == true && attribute.type == 'array') { | ||
storageOption = dbEnum.storageOption.external | ||
} | ||
if ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bzbarsky-apple this code which presumably changes global attributes to external if they are in the list seems to cause CI and codeine failures. Any idea what the failures mean?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That code changes all attributes to be external if they are of array type. And that code is very much pre-existing, the right behavior, and not the problem here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
okay thank you
src-electron/db/query-upgrade.js
Outdated
let zcl = await queryPackage.getMetaFile(db, pkgs) | ||
let obj = await fsp.readFile(zcl) | ||
let data = JSON.parse(obj) | ||
let externals = data.attributeAccessInterfaceAttributes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is attributeAccessInterfaceAttributes always present in the zcl meta file?
Optional Chaining (data?.fieldName) can be used here when it's not guaranteed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is attributeAccessInterfaceAttributes always present in the zcl meta file?
No.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good idea @jingteng25742 will fix, thanks
src-electron/db/query-upgrade.js
Outdated
) { | ||
let storageOption | ||
let attributeName | ||
if (!clusterName) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you meant to test clusterName or clusterRef?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clusterName
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe you are passing null values to the cluster name and then extracting the cluster name regardless. See let storageOption = await queryUpgrade.computeStorage( db, null,
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I only retrieve clusterName if it is null
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (!clusterName) {
clusterName = await queryCluster.selectClusterName(db, clusterRef)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So this is a partial fix, in that it does not fix item 1 from #1142 (review), right?
staticAttribute.storagePolicy, | ||
forcedExternal, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess my architectural question is this: if we are doing the "getForcedExternalStorage" thing here, what is the point of having storagePolicy as a concept at all?
That is, why are we bothering to store a storage policy in the db?
All of this could really benefit from some architecture documentation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Going into this I had no idea what the history behind storagePolicy was. After debugging, I think we have to do getForcedExternalStorage here because it is the only way to reference the cluster.
Note, we are still using storage policy when creating endpoints from scratch. As in, when we have a "new Configuration". But point taken.
src-electron/db/query-upgrade.js
Outdated
let zcl = await queryPackage.getMetaFile(db, pkgs) | ||
let obj = await fsp.readFile(zcl) | ||
let data = JSON.parse(obj) | ||
let externals = data.attributeAccessInterfaceAttributes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is attributeAccessInterfaceAttributes always present in the zcl meta file?
No.
right |
f01d09b
to
64a5de8
Compare
src-electron/db/query-upgrade.js
Outdated
return attributeName[0].NAME | ||
} | ||
|
||
async function queryMetaFile(db, packageId) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm are you sure: I see
const querySelectFromPackage =
SELECT
PACKAGE_ID,
PATH,
TYPE,
CRC,
VERSION,
CATEGORY,
DESCRIPTION
FROM PACKAGE ``
src-electron/db/query-config.js
Outdated
) | ||
let storageOption = await queryUpgrade.computeStorage( | ||
db, | ||
null, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this null instead of the cluster name?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
because clusterName is not needed when upgrading a new configuration so I used it as a differentiator
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
never mind, you're right. will fix.
src-electron/db/query-upgrade.js
Outdated
) { | ||
let storageOption | ||
let attributeName | ||
if (!clusterName) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe you are passing null values to the cluster name and then extracting the cluster name regardless. See let storageOption = await queryUpgrade.computeStorage( db, null,
8cb8ed6
to
5b65d3c
Compare
a73c55a
to
879713a
Compare
3905ebd
to
98d91d4
Compare
handling global attributes per cluster
#543