Add region property to site and device metadata with automatic propogation#1332
Add region property to site and device metadata with automatic propogation#1332noursaidi wants to merge 1 commit into
Conversation
- Update schema/site_metadata.json to include region. - Update schema/model_system.json to include region under location. - Regenerate Java schema classes. - Update Registrar and LocalDevice to automatically copy region from site metadata to device metadata if unset during normalization. - Add unit tests in LocalDeviceTest to verify the propagation logic. Co-authored-by: noursaidi <9341216+noursaidi@users.noreply.github.com>
grafnu
left a comment
There was a problem hiding this comment.
I don't understand the reason for this.... ?!?!?
| } | ||
| }, | ||
| "region": { | ||
| "description": "The region according to the site model in which the device is installed in", |
There was a problem hiding this comment.
why is this needed in the device model? When is a device ever not in the region for the entire site?
There was a problem hiding this comment.
It will shouldn't ever be different, but it needs to be in the device metadata it's describing the device, and we know which region the device is in (the site metadata describes the site). The use cases would be filtering both messages in pubsub where we can add this as an attribute, and also device, where we filter metadata for devices). We can do elaborate data relationship/joins, but it's better and preferable for all the data to be in the device metadata
There was a problem hiding this comment.
Ok, I think I understand now. My concern is that it ends up in the pre-normalized metadata too, which then makes it redundant info. Can you add a simple check (should just be a line or two) in registrar that generates a warning if it's in the pre-normalized metadata?
Also, should have a test for this in tests/sites somewhre -- doesnt' need to be new, but just add a region into one of the existing sites, so the effects of this are obvious. (Also then can add a field into a metadata.json file somewhere and see the error). Unit tests for things like this aren't always that useful since they're way too spot focused, which is why I'm looking for the site-level tests.
This change introduces a new
regionfield to the UDMI metadata schemas. It is added as a top-level property insite_metadata.jsonand as a property within thelocationobject inmodel_system.json(used for device metadata).The Registrar has been updated to automatically propagate this
regionfrom the site metadata to any device that does not have its ownregionexplicitly set. This ensures consistency across a site while allowing for per-device overrides.Java classes were regenerated to include the new fields, and unit tests were added to
LocalDeviceTest.javato verify that:PR created automatically by Jules for task 17728302459280877011 started by @noursaidi