Repository navigation
Expose device metadata on schema-built device modules - #61
Open
bruno-f-cruz wants to merge 2 commits into
Open
bruno-f-cruz wants to merge 2 commits into
bruno-f-cruz wants to merge 2 commits into
Conversation
DeviceModuleLike leaves DEVICE_METADATA optional so device modules written by hand still match. DescribedDeviceModuleLike requires it, so code needing the schema can accept it directly or narrow a DeviceModuleLike to it with isinstance.
This branch has not been deployed
This file contains hidden or 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
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.
Generated device packages now carry their source
device.ymlas aDEVICE_METADATAstring constant (harp-tech/generators#188), mirroringDevice.Metadatain the C# interface. This brings the runtime path to parity, so a module built withcreate_device_moduleexposes the same constant, and adds a protocol for code that needs it.DeviceModuledeclaresDEVICE_METADATA: str, andcreate_device_modulesets it from the schema text and exports it in__all__.\n, so line endings are normalized, and schema bytes are decoded the way the YAML parser detects them: a UTF-16 byte order mark, otherwise UTF-8 with an optional byte order mark.DescribedDeviceModuleLikeextendsDeviceModuleLikewithDEVICE_METADATA: str. Generated packages andDeviceModulematch it structurally, so code that needs the schema can accept it directly, or narrow aDeviceModuleLikewithisinstance, which typesDEVICE_METADATAasstr.tests/device/expected_device.pygains the block the generator emits fortests/assets/device.yml, so the existing check that both paths publish the same__all__keeps holding, and new tests compare the two values directly and pin which modules match each protocol.DeviceModuleLikedoes not requireDEVICE_METADATA, so device modules written by hand still match without carrying a schema, and packages generated before harp-tech/generators#188 keep satisfying it unchanged.