Skip to content

lopper:assists:baremetal_getsupported_comp_xlnx: Add support to inclu… #552

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

Merged
merged 1 commit into from
May 21, 2025

Conversation

sathishkumar-amd
Copy link
Contributor

…de the examples in the lib_list.yaml

In the current implementation the examples are not included in the lib_list yaml file, Add support to include the examples in the lib_list.yaml to show the available examles for the library in the GUI. To enhance functionality, add support for reading examples from custom configurations in YAML files. If a YAML file contains a condition within the examples section in the form of a Python code block, read and execute this code to update the examples based on the specified conditions. This approach allows dynamic configuration adjustments based on predefined logic, improving flexibility and customization in managing examples

@sathishkumar-amd
Copy link
Contributor Author

Hi @onkarharsh and @kedareswararao
Please review this

@@ -46,7 +75,7 @@ def xlnx_baremetal_getsupported_comp(tgt_node, sdt, options):

matched_node = get_cpu_node(sdt, options)
proc_ip_name = matched_node['xlnx,ip-name'].value[0]

family = sdt.tree.dct['family'][0]
Copy link
Contributor

Choose a reason for hiding this comment

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

Try to use propval() if possible, that takes care of exceptions as well..

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Used propval() as suggested

try:
exec(examples["condition"], {}, local_scope)
except Exception as e:
_error("The condition in the YAML file has failed. -> {e}")
Copy link
Contributor

Choose a reason for hiding this comment

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

Put this as a warning, not an error.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added warning as suggested

exec(examples["condition"], {}, local_scope)
except Exception as e:
_error("The condition in the YAML file has failed. -> {e}")
examples = {key: value for key, value in examples.items() if key in local_scope["examples"]}
Copy link
Contributor

Choose a reason for hiding this comment

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

Move this examples under try block. If the condition fails, the old flow should still continue working.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated code as suggested

except Exception as e:
_error("The condition in the YAML file has failed. -> {e}")
examples = {key: value for key, value in examples.items() if key in local_scope["examples"]}
for ex,deps in examples.items():
Copy link
Contributor

Choose a reason for hiding this comment

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

Delete "condition" key from examples before this loop to make old flow work.

@@ -46,7 +75,7 @@ def xlnx_baremetal_getsupported_comp(tgt_node, sdt, options):

matched_node = get_cpu_node(sdt, options)
proc_ip_name = matched_node['xlnx,ip-name'].value[0]

family = sdt.tree['/'].propval('family')[0]
Copy link
Contributor

Choose a reason for hiding this comment

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

check the presence of index 0 element before processing,

Copy link
Contributor

@onkarharsh onkarharsh left a comment

Choose a reason for hiding this comment

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

Added few more comments, please check.

examples = {key: value for key, value in examples.items() if key in local_scope["examples"]}
except Exception as e:
_warning(f"The condition in the {yaml_file} file has failed. -> {e}")
examples = {key: value for key, value in examples.items() if key != "condition"}
Copy link
Contributor

Choose a reason for hiding this comment

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

examples.pop("condition", None) ?

…de the examples in the lib_list.yaml

In the current implementation the examples are not included in the lib_list yaml file,
Add support to include the examples in the lib_list.yaml to show the available examles for the library in the GUI.
To enhance functionality, add support for reading examples from custom configurations in YAML files.
If a YAML file contains a condition within the examples section in the form of a Python code block,
read and execute this code to update the examples based on the specified conditions.
This approach allows dynamic configuration adjustments based on predefined logic,
improving flexibility and customization in managing examples

Signed-off-by: Sathish Kumar Kamishettigari <sathishkumar.kamishettigari@amd.com>
@sathishkumar-amd
Copy link
Contributor Author

Added few more comments, please check.

Updated the code as suggested

Copy link
Contributor

@onkarharsh onkarharsh left a comment

Choose a reason for hiding this comment

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

Final version looks fine.

@zeddii zeddii merged commit 0846969 into devicetree-org:master May 21, 2025
1 check 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.

3 participants