-
Notifications
You must be signed in to change notification settings - Fork 0
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
Add initial Node
and NodeInfo
types and expose node info functionality in Python module
#6
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NodeInfo
types and expose node info functionality in Python moduleNode
and NodeInfo
types and expose node info functionality in Python module
79266d9
to
a658823
Compare
The commit adds a new struct `Node` which is used to represent Reclass nodes and classes, code to load YAML files from the filesystem, and a function which transforms relative class includes into their absolute form, based on the node's location within the inventory structure. We also add a very simple example inventory in `tests/inventory` which will be extended with additional cases as new features are implemented.
The `NodeInfo` and `NodeInfoMeta` types provide structured forms of the return value of the Python Reclass `nodeinfo()` method. We introduce initial versions of `as_py_obj()` and `as_py_dict()` for the serde_yaml `Value` and `Mapping` types. These won't remain as-is, but allow us to transform serde_yaml data into Python objects for now. We also add the `chrono` crate to manage the Node's render timestamp in Rust. Additionally, we enable the pyo3 `chrono` feature to get conversion between `chrono::DateTime` and `PyDateTime`.
The `_reclass_` parameter can be used in references in Python reclass. To allow this, we need to inject the parameter into the Node's parameters just after we parse the node.
We add a default getter named `__reclass__` for `NodeInfo` which returns a typed `NodeInfoMeta`, and rename the previous `__reclass__` getter which returns the `NodeInfoMeta` as a dict to `reclass_as_dict` and make it a regular method.
a658823
to
bf1a1e7
Compare
bastjan
approved these changes
Aug 31, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The PR adds a new struct
Node
which is used to represent Reclass nodes and classes, code to load YAML files from the filesystem, and a function which transforms relative class includes into their absolute form, based on the node's location within the inventory structure.We also add a very simple example inventory in
tests/inventory
which will be extended with additional cases as new features are implemented.Additionally, the PR add
NodeInfo
andNodeInfoMeta
types which provide structured forms of the return value of the Python Reclassnodeinfo()
method.Finally, the PR introduces initial versions of
as_py_obj()
andas_py_dict()
for the serde_yamlValue
andMapping
types. These won't remain as-is, but allow us to transform serde_yaml data into Python objects for now.Checklist
bug
,enhancement
,documentation
,change
,breaking
,dependency
,internal
as they show up in the changelog