Custom fields plugin for model builder
Custom fields
Custom fields allow extending model at configuration time, with the same sources. This plugin adds two types of custom fields - ones defined on an explicit element (usually the "custom_fields" element is used, but any name can be used) and other one inlining the custom fields directly to the main content.
Currently there is no support for inlining custom fields to "metadata" element, but this can be changed in the future.
Model file
Custom fields are defined on the level of "model":
model:
use: invenio
custom-fields:
- element: custom_fields
config: TEST_CUSTOM_FIELDS
properties:
metadata:
properties:
title: fulltext
Explicit custom fields
Explicit custom fields are defined using a pair of element name and config variable.
In the instance the custom fields will be separated into the element name:
# config
from invenio_records_resources.services.custom_fields.text import KeywordCF
TEST_CUSTOM_FIELDS = [
KeywordCF('blah')
]
// instance
{
"metadata": {
"title": "My Title"
},
"custom_fields": { // "element" from model
"blah": "Custom field value" // as defined in "TEST_CUSTOM_FIELDS" variable
}
}
Inline custom fields
Inline custom fields are placed on the root level of the instance, without an enclosing element. To define them, just leave the element definition. Note that only 1 definition of inline CF is allowed.
model:
use: invenio
custom-fields:
- config: INLINE_CF
properties:
metadata:
properties:
title: fulltext
# config
from invenio_records_resources.services.custom_fields.text import KeywordCF
INLINE_CF = [
KeywordCF('blah')
]
// instance
{
"metadata": {
"title": "My Title"
},
"blah": "Custom field value" // as defined in "INLINE_CF" variable
}
Custom fields nested in metadata
Custom fields nested inside the metadata are not supported yet.
Using custom fields
Custom fields influence the jsonschema file (adding a non-checked object or allowing additional properties) and the mapping file (adding an empty mapping for CF).
During deployment time, after the index is created and before data are poured in, a specialized mapping for custom fields must be created. To do so, call
invenio oarepo cf init
Metadata
Release files for oarepo-model-builder-cf 4.0.8
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| oarepo_model_builder_cf-4.0.8.tar.gz | 4.6 kB | Without provenance | Details for oarepo_model_builder_cf-4.0.8.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| oarepo_model_builder_cf-4.0.8-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details for oarepo_model_builder_cf-4.0.8-py2.py3-none-any.whl |
Total release size: 13.8 kB
Release files / oarepo_model_builder_cf-4.0.8.tar.gz
| Download URL | oarepo_model_builder_cf-4.0.8.tar.gz |
|---|---|
| Size | 4.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ca590a70cec738d4546cc75c792068e798ffffa7316e39bc06867397c5359b71
|
|
BLAKE2b-256 checksum How to use checksums |
4c88fe05b9d54a15065989cfe3d4a8482a8d0d18a02133c6083d49915082b5fc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.0 CPython/3.12.5
|
Release files / oarepo_model_builder_cf-4.0.8-py2.py3-none-any.whl
| Download URL | oarepo_model_builder_cf-4.0.8-py2.py3-none-any.whl |
|---|---|
| Size | 9.2 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
3edc13355ba079fbab1433b3a868dbb009d7f4788c2bbdba39f88f7fdd000d0a
|
|
BLAKE2b-256 checksum How to use checksums |
092e3ef0584b6edf3b2e23ea7bc94fb05a27e9e9b4d7eaba6e48a7386c00d669
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.0 CPython/3.12.5
|
Security for oarepo-model-builder-cf 4.0.8
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.