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

query attributes with edited global attributes #1162

Merged
merged 3 commits into from
Oct 13, 2023

Conversation

paulr34
Copy link
Collaborator

@paulr34 paulr34 commented Oct 4, 2023

No description provided.

@paulr34 paulr34 marked this pull request as ready for review October 5, 2023 17:15
@paulr34 paulr34 requested a review from bzbarsky-apple October 5, 2023 17:26
Copy link
Contributor

@bzbarsky-apple bzbarsky-apple left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not seem to fix the output of zcl_attributes....

src-electron/upgrade/upgrade.js Outdated Show resolved Hide resolved
@codecov-commenter
Copy link

codecov-commenter commented Oct 9, 2023

Codecov Report

Merging #1162 (4b83332) into master (a8d5c6d) will increase coverage by 0.02%.
The diff coverage is 91.89%.

❗ Current head 4b83332 differs from pull request most recent head 1f3617c. Consider uploading reports for the commit 1f3617c to get more accurate results

@@            Coverage Diff             @@
##           master    #1162      +/-   ##
==========================================
+ Coverage   65.38%   65.41%   +0.02%     
==========================================
  Files         171      171              
  Lines       18366    18384      +18     
  Branches     3969     3971       +2     
==========================================
+ Hits        12008    12025      +17     
- Misses       6358     6359       +1     
Files Coverage Δ
src-electron/upgrade/upgrade.js 94.44% <94.11%> (-0.56%) ⬇️
src-electron/generator/helper-zcl.js 70.86% <90.00%> (+0.11%) ⬆️

@paulr34 paulr34 force-pushed the generate_zcl_attributes branch 2 times, most recently from 9d6ea90 to c06ff95 Compare October 11, 2023 00:57
@paulr34 paulr34 requested review from tecimovic and brdandu October 11, 2023 01:51
@paulr34
Copy link
Collaborator Author

paulr34 commented Oct 11, 2023

@tecimovic @brdandu could you guys please take a look at the Zigbee regen failures when you have a moment? Thanks

@paulr34 paulr34 force-pushed the generate_zcl_attributes branch 3 times, most recently from e7b1fab to 6b50b3c Compare October 11, 2023 22:42
src-electron/generator/helper-zcl.js Outdated Show resolved Hide resolved
src-electron/generator/helper-zcl.js Outdated Show resolved Hide resolved
src-electron/upgrade/upgrade.js Outdated Show resolved Hide resolved
src-electron/upgrade/upgrade.js Outdated Show resolved Hide resolved
src-electron/upgrade/upgrade.js Outdated Show resolved Hide resolved
src-electron/upgrade/upgrade.js Outdated Show resolved Hide resolved
src-electron/upgrade/upgrade.js Outdated Show resolved Hide resolved
src-electron/upgrade/upgrade.js Outdated Show resolved Hide resolved
src-electron/upgrade/upgrade.js Outdated Show resolved Hide resolved
@paulr34 paulr34 force-pushed the generate_zcl_attributes branch 3 times, most recently from 047586c to 182092d Compare October 12, 2023 02:56
src-electron/upgrade/upgrade.js Outdated Show resolved Hide resolved
src-electron/upgrade/upgrade.js Outdated Show resolved Hide resolved
let byName = data?.attributeAccessInterfaceAttributes
let lists = data?.listsUseAttributeAccessInterface
let forcedExternal = { byName, lists }
return forcedExternal
}

/**
* This function takes a clusterId and an array of attributes associated with that clusterID from the database
* and changes the global attributes (attributes with clusterId = null) to represent storage policy
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing below is restricted to global attributes...

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I just added a check "if(attribute.clusterId == null)". The "non global attributes" should already be computed from the loading process.

This function should only change global attributes.

@paulr34 paulr34 changed the title query the attributes with the edited global attributes query attributes with the edited global attributes Oct 12, 2023
@paulr34 paulr34 changed the title query attributes with the edited global attributes query attributes with edited global attributes Oct 12, 2023
try {
return JSON.parse(json)
} catch (err) {
return 'undefined'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return 'undefined'
return undefined

* @returns an array of objects representing attributes in the database
*/

async function computeStoragePolicy(db, clusterId, attributes) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
async function computeStoragePolicy(db, clusterId, attributes) {
async function computeStoragePolicyForGlobalAttributes(db, clusterId, attributes) {

if that's what it does.

@paulr34 paulr34 force-pushed the generate_zcl_attributes branch 3 times, most recently from ab8c376 to 935e58a Compare October 12, 2023 17:57
this.id,
packageIds
)
attributes = await upgrade.computeStoragePolicyForGlobalAttributes(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't feel right, layer-wise. The point of upgrade.js is to perform upgrades when you READ IN the .zap files.
You are here using upgrade.js when you're generating stuff.

Not saying that it's the wrong thing, functionally, but I'd then go and move the logic out of upgrade.js, put it somewhere else, and maybe have both places call the common place.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will make follow up PR, thanks

try {
return JSON.parse(json)
} catch (err) {
return undefined
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

? You are hiding exception here. Why do we need this? This feels wrong. I don't want for people to blindly start using this function, and then be confused why they get "error: undefined", instead of "error: JSON parsing error".

So this function makes no sense to me.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks will fix

let data = JSON.parse(obj)
zcl = zcl?.path
let obj = await fsp.readFile(zcl, 'utf-8')
let data = await parseJson(obj)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see why you wrap JSON parsin into a "fake asynchronous call"... (See my comment above).

src-electron/upgrade/upgrade.js Outdated Show resolved Hide resolved
zcl = zcl.path
let obj = await fsp.readFile(zcl)
let data = JSON.parse(obj)
zcl = zcl?.path
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Somewhere along the way this part is also eating up an "exception condition" (zcl being null or undefined).

@paulr34 paulr34 force-pushed the generate_zcl_attributes branch from 9e7f8b0 to 4b83332 Compare October 12, 2023 19:55
@paulr34 paulr34 merged commit 318db74 into project-chip:master Oct 13, 2023
11 of 12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants