Repository navigation
Let a project record its own attributes on stations and device types #1411
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
Open
mihow
wants to merge
8
commits into
main
Choose a base branch
from
feat/configurable-metadata-fields-full
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
cc75796
Add a reusable JSON metadata field for forms
mihow 8966e1a
Let projects record their own fields on stations and device types
mihow 367ab45
Write up the metadata field for the next agent session
mihow 6f634d9
Let operators record extra metadata on stations and device types
mihow 1171647
Hold the form-encoded station write to the same metadata rule as the API
mihow 88a93ee
Pin null on both metadata write paths, and record the object-only dec…
mihow a9c2612
Bring the metadata field's two halves together
47428a3
Merge remote-tracking branch 'origin/main' into feat/configurable-met…
mihow File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
33 changes: 33 additions & 0 deletions
33
ami/main/migrations/0096_deployment_metadata_device_metadata.py
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| # Generated by Django 4.2.10 on 2026-09-07 19:31 | ||
|
|
||
| import ami.main.models | ||
| from django.db import migrations, models | ||
|
|
||
|
|
||
| class Migration(migrations.Migration): | ||
| dependencies = [ | ||
| ("main", "0095_grant_sync_deployment_to_mldatamanager"), | ||
| ] | ||
|
|
||
| operations = [ | ||
| migrations.AddField( | ||
| model_name="deployment", | ||
| name="metadata", | ||
| field=models.JSONField( | ||
| blank=True, | ||
| default=dict, | ||
| help_text="Free-form JSON object holding attributes specific to this configuration, beyond the fields modelled natively. Camera height or habitat description, for example.", | ||
| validators=[ami.main.models.validate_metadata_object], | ||
| ), | ||
| ), | ||
| migrations.AddField( | ||
| model_name="device", | ||
| name="metadata", | ||
| field=models.JSONField( | ||
| blank=True, | ||
| default=dict, | ||
| help_text="Free-form JSON object holding attributes specific to this configuration, beyond the fields modelled natively. Camera height or habitat description, for example.", | ||
| validators=[ami.main.models.validate_metadata_object], | ||
| ), | ||
| ), | ||
| ] | ||
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
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.
🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
Repository: RolnickLab/antenna
Length of output: 20050
🤖 get_repo_knowledge executed:
get_repo_knowledge RolnickLab/antenna /tmp/coderabbit-repo-knowledge/rolnicklab-antenna-cc5c3310/architecture /tmp/coderabbit-repo-knowledge/rolnicklab-antenna-cc5c3310/learningsLength of output: 45671
🏁 Script executed:
Repository: RolnickLab/antenna
Length of output: 13050
🏁 Script executed:
Repository: RolnickLab/antenna
Length of output: 12797
Enforce object-only metadata in the database.
metadata_field()defines an object-only contract, but the validators do not run forModel.save(),bulk_create(), orQuerySet.update(). PostgreSQLjsonbaccepts arrays and scalar values, so these paths can store invalid metadata inDeployment.metadataandDevice.metadata. Add matchingjsonb_typeof(metadata) = 'object'check constraints and regression tests.🧰 Tools
🪛 Ruff (0.16.3)
[warning] 12-33: Mutable default value for class attribute
(RUF012)
🤖 Prompt for AI Agents