-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
update_cluster_revisions.py: Add possibility to bump cluster revisions to the latest in spec #36456
base: master
Are you sure you want to change the base?
update_cluster_revisions.py: Add possibility to bump cluster revisions to the latest in spec #36456
Conversation
Changed Files
|
PR #36456: Size comparison from c3b35eb to 53d4c18 Full report (3 builds for cc32xx, stm32)
|
PR #36456: Size comparison from c3b35eb to ab056da Full report (68 builds for bl602, bl702, bl702l, cc13x4_26x4, cc32xx, cyw30739, efr32, esp32, linux, nrfconnect, nxp, psoc6, qpg, stm32, telink, tizen)
|
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.
Thank you!
Co-authored-by: Boris Zbarsky <[email protected]>
@@ -126,6 +170,41 @@ def updateOne(item): | |||
subprocess.check_call(['./scripts/tools/zap/convert.py', target]) | |||
|
|||
|
|||
def updateOneToLatest(item): |
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.
Please follow pep8
satule (e.g. update_one_to_latest
)
json.dump(data, file) | ||
|
||
# Now run convert.py on the file to have ZAP reformat it however it likes. | ||
subprocess.check_call(['./scripts/tools/zap/convert.py', target]) |
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.
Please include python3
in the command
@@ -51,6 +70,34 @@ def getTargets(cluster_id: int): | |||
return targets | |||
|
|||
|
|||
def get_outdated_clusters(data: object, xml_clusters: dict, args) -> list[ClusterInfo]: |
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.
The contents of args could have been state of a VersionUpdateProcessor class.
Overall this script relies too much on passing data around that could be state of a class
def get_outdated_clusters(data: object, xml_clusters: dict, args) -> list[ClusterInfo]: | ||
result = [] | ||
for endpoint in data.get("endpointTypes", []): | ||
endpoint_id = endpoint.get("id") - 1 |
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 is NOT the endpoint_id. Endpoint IDs are separate from the id
field. This may work oddly on ZAP files that have non-contiguous endpoint IDs.
except (KeyError, ValueError): | ||
continue | ||
# Filter in outdated clusters only | ||
if (cluster_revision == spec_revision): |
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.
avoid C-style ()
around whole condition
if (cluster_revision == spec_revision): | ||
break | ||
# If old_revision is present, filter in matching only | ||
if (args.old_revision is not None and cluster_revision != args.old_revision): |
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.
Parenthesize sub-expressions:
if (args.old_revision is not None and cluster_revision != args.old_revision): | |
if (args.old_revision is not None) and (cluster_revision != args.old_revision): |
cluster_code: int | ||
cluster_spec_revision: int | ||
cluster_name: str | ||
json_attribute: object |
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.
nit, for hinting isn't this a dict[str,object]
?
@@ -51,6 +70,34 @@ def getTargets(cluster_id: int): | |||
return targets | |||
|
|||
|
|||
def get_outdated_clusters(data: object, xml_clusters: dict, args) -> list[ClusterInfo]: |
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.
nit, there is a mix of functions in this PR mixed with with snake_case and lowerCamelCase. Overall I think autopep8 does say we should to functions are snake_case. My suggestions is keep it the same for the file and if we want to migrate the entire file we do it all at once in the file as a follow up refactor
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.
Or follow Tennessee's recommendation of starting the switch to pep8 and doing that for all your newly introduced functions
This PR adds a new feature to the
update_cluster_revisions.py
tool:--new-revision
argument is omitted.If
--new-revision
is provided, the tool uses it and behaves as previously implemented.I've also added documentation in
README.md
on how to use the tool and expected output examples.