-
-
Notifications
You must be signed in to change notification settings - Fork 56
feat: Add support for Component modelCard field #914
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
base: main
Are you sure you want to change the base?
feat: Add support for Component modelCard field #914
Conversation
Signed-off-by: Wiebe Vandendriessche <[email protected]>
…ach support Signed-off-by: Wiebe Vandendriessche <[email protected]>
…formance metrics Signed-off-by: Wiebe Vandendriessche <[email protected]>
…al considerations (`modelParameters.datasets` remains a staged placeholder until CycloneDX#913) Signed-off-by: Wiebe Vandendriessche <[email protected]>
…/XML validation Signed-off-by: Wiebe Vandendriessche <[email protected]>
Signed-off-by: Wiebe Vandendriessche <[email protected]>
Signed-off-by: Wiebe Vandendriessche <[email protected]>
jkowalleck
left a comment
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.
Please also add a sufficient data model to https://github.com/CycloneDX/cyclonedx-python-lib/blob/main/tests/_data/models.py
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.
Pull Request Overview
This PR adds comprehensive support for the modelCard field on CycloneDX components, enabling machine learning model documentation including parameters, performance metrics, ethical considerations, and environmental impact tracking.
Key changes:
- Introduces complete
ModelCardtype hierarchy including parameters, quantitative analysis, and considerations - Adds environmental impact tracking with energy consumption and CO2 measurements (v1.6+)
- Temporarily gates
modelParameters.datasetsfield with validation that raisesNotImplementedErroruntil shared component data support (#913) is implemented
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 18 comments.
| File | Description |
|---|---|
| cyclonedx/model/model_card.py | Defines comprehensive ModelCard type system including 20+ classes for ML model documentation, energy tracking, and ethical considerations with proper schema versioning (1.5-1.7) |
| cyclonedx/model/component.py | Integrates model_card property into Component class with proper serialization annotations and comparable tuple support |
| tests/test_model_model_card.py | Provides extensive test coverage including schema validation for v1.5-1.7, sorting behavior, equality checks, and version-specific feature gating |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Is there documentation on how this works? |
Signed-off-by: Wiebe Vandendriessche <[email protected]>
not yet. We would be happy to see a dedicated pull-request that improves the documentation. in your case, you would create a BOM with just one bare component and a complete modelCard with every property filled. the system works like this:
|
Ok, i'll take a look for this! In the meantime i have encountered an issue regarding ModelCard.properties. It seems like ModelCard.properties validates in JSON but is rejected by XML. I tried to add top-level properties to ModelCard: JSON (1.7) validates successfully. Can you confirm the XML spec indeed does not have ModelCard.properties? How should we handle this in the code? Because right now it's not possible to add custom properties in a ModelCard. (however other classes inside the modelCard also have a "properties" field e.g. EnvironmentalConsiderations, and this does fully work) |
can confirm. JSON: https://cyclonedx.org/docs/1.7/json/#components_items_modelCard_properties
nope. it a bug. thanks for reporting - caused CycloneDX/specification#726 |
Good to know! What should I do in the meantime? Should we merge this pull request with a temporary solution that just disables ModelCard.properties (both json and xml) untill that issue in the spec is resolved (because I guess this will take long)? |
looking into this. give me some time. |
Thanks, sounds good. |
feat: Add support for Component modelCard field
Summary
modelCardsupport to components for CycloneDX 1.5+, including environmental considerations (1.6+).modelParameters.datasetsas unsupported pending [FEAT] Add support for Component data field #913.Linked Issues
Closes: #912
Part of [TRACKING] Complete support for CycloneDX v1.5: #578
Follow-up: #913
Changes
ModelCard,ModelParameters,QuantitativeAnalysis,PerformanceMetric,GraphicsCollection,ConfidenceInterval.Considerations,EthicalConsideration,FairnessAssessment.EnvironmentalConsiderations,EnergyConsumption,EnergyProvider,EnergyMeasure,Co2Measure, enumsEnergyActivity,EnergySource.Component.model_card(1.5+).NotImplementedErrorifmodelParameters.datasetsis populated.component.data/componentData.Schema Compatibility
modelCardwithmodelParameters,quantitativeAnalysis,considerations.environmentalConsiderationsand energy/CO2/provider types.Tests
bom-ref.Follow-ups
modelParameters.datasetsonce [FEAT] Add support for Component data field #913 lands:component.datamodel + union (inlinecomponentDataor{ref}).Breaking Changes
NotImplementedErroris raised only ifmodelParameters.datasetsis supplied, intentionally preventing invalid output.Validate modelCard locally