Extensions to, or code closely associated with, third-party libraries relied on by this application.
assets_tracking_service.lib.markdown
A plugin based on https://github.com/kostyachum/python-markdown-plain-text is used to strip Markdown formatting from text for use in HTML titles for example.
A plugin based on https://github.com/daGrevis/mdx_linkify is used to convert inline URLs and email addresses in Markdown text into HTML links.
A plugin based on https://gitlab.com/ayblaq/prependnewline/ is used to automatically add additional line breaks to correctly paragraphs from lists in Markdown and ensure proper formatting.
Important
These are rough/working notes that will be written up properly when this module is extracted.
lantern.lib.metadata_library
Includes classes for Records.
These redesigned and refactored classes will replace core parts of the Metadata Library project.
Records are a partial representation of the ISO 19115
information model implemented as a base data class (lantern.lib.metadata_library.models.record.Record). They
generically describe resources (maps [products], datasets, collections, etc.).
Important
The Records model does not support all properties supported by the BAS ISO 19115 JSON Schema. See the Record Limitations section for more information.
Note
When encoded as XML records are interoperable with applications that support ISO 19139 encoded records.
Warning
When encoded as JSON, records are only interoperable with applications that support the BAS ISO 19115 JSON Schema.
The Record data class provides:
- access to typed record properties
- record configuration validation
- filtering list based properties such as contacts, aggregations, etc.
- loading and dumping record configurations (including from/to JSON documents)
Sub-properties are implemented as additional data classes (e.g. an Identification class). Code list properties are
implemented using Enum classes.
The Record data class includes a validate() method which will:
- validate the record configuration against the BAS ISO 19115 JSON schema
- validate the record configuration against any of these supported profiles:
Records will be validated automatically when needed. Invalid records will raise a
lantern.lib.metadata_library.models.record.RecordInvalidError exception.
Supported common elements (references not normative or exhaustive):
*.citation.title*.citation.dates*.citation.edition*.citation.identifiers*.citation.contacts(exceptcontact.position)*.citation.series(with local workaround forseries.pageuntil v5 schema)*.constraints(limited restriction code list options)*.maintenance*.online resource(partial)
Supported elements (references not normative or exhaustive):
$schemafile_identifierfile_revision(non-ISO 19115 property, see RecordRevision)hierarchy_levelmetadata.character_set(hard-coded to 'utf8')metadata.language(hard-coded to 'eng')metadata.contacts(see*.citation.contacts)metadata.constraintsmetadata.maintenancemetadata.date_stampmetadata.metadata_standardreference_system_infoidentification.title(via*.citation.title)identification.dates(via*.citation.dates)identification.edition(via*.citation.edition)identification.identifiers(via*.citation.identifiers)identification.contacts(except*.citation.contacts)identification.abstractidentification.purposeidentification.other_citation_detailsidentification.supplemental_informationidentification.aggregationsidentification.extents(temporal and bounding box extents only)identification.graphic_overviewsidentification.spatial_resolutionidentification.maintenanceidentification.character_set(hard-coded to 'utf8')identification.language(hard-coded to 'eng')(identification.)data_quality.domain_consistency(identification.)data_quality.lineage.statementdistribution.distributordistribution.format(formatandhrefonly)distribution.transfer_option
Unsupported elements (not normative or exhaustive):
*.contact.position*.online_resource.protocol(identification.)data_quality.lineage.process_step(identification.)data_quality.lineage.sourcesdistribution.format(except name and URL)identification.creditidentification.extent.geographic.identifieridentification.extent.verticalidentification.keywordsidentification.resource_formatsidentification.spatial_representation_typeidentification.statusidentification.topics
Records can be authored using any tool or system that can produce a valid record configuration. These may be created
directly as JSON documents, or constructed as Record data class instances and then dumped to JSON.
Tip
For manual editing, consider an editor that supports JSON schemas for inline validation and enum auto-completion.
Within Python applications or scripts, consider using Record data classes for typed record properties, validation
and easy serialisation to JSON.
Note
There is no formal guidance on what to include in record configurations. However, a starting point may be the Examples Records defined for the MAGIC Discovery ISO 19115 Profile.
Tip
See the Guide for how titles, summaries, abstracts and lineage statements can be formatted.
If authoring Records using data classes, a set of presets in the lantern.lib.metadata_library.models.record.presets
package are available to create common config subsets and improve consistency across records.
For example:
lantern.lib.metadata_library.models.record.presets.extents.make_bbox_extent:- simplifies creating a bounding box extent from a set of coordinates
lantern.lib.metadata_library.models.record.presets.constraints.OGL_V3:- provides a constant for the Open Government Licence
Tip
A larger scale present (lantern.lib.metadata_library.models.record.presets.base.RecordMagic) exists for
creating typical MAGIC records, valid against the MAGIC Discovery (v2) and Administration (v1) profiles.
A set of utility functions in the lantern.lib.metadata_library.models.record.utils package are available to perform
common or complex tasks.
To support properties that cannot be represented natively in the ISO 19115 information model, key value data can be
encoded in a JSON string within the identifification.supplemental_information element of a Record.
Warning
The use of key values is non-standard and exclusive. If used, other content MUST NOT be included in the element.
Keys in this data are not controlled and must be accessed defensively.
Tip
The lantern.lib.metadata_library.models.record.utils.kv.get_kv and set_kv Utility Functions
MAY be used to access and update key value data.
The lantern.lib.metadata_library.models.record.utils.admin.get_admin and set_admin utility functions extend the
Metadata Library
methods to access and update MAGIC Administration metadata to work with Records.
Warning
This section is Work in Progress (WIP) and may not be complete/accurate.
To add support for a new ISO element within Records:
- create a new data class for the new element in the relevant top module (i.e.
identification.py) - define enums for code lists if needed
- define a cattrs (un)structure hook if needed
- include the new class as a property in the relevant top-level class (i.e.
Identification) - register the cattrs (un)structure hook in the top-level class hooks if needed
- add tests for the new class testing all permutations, and cattrs hook if needed
- amend tests for top-level class (i.e.
TestIdentification) variant:- add variant for minimal instance of the new class if optional
- amend all variants with a minimal instance of the new class if required
- amend asserts to check new class as required
- amend tests for top-level cattrs hooks if changed
- if new class part of minimal record, update
fx_record_config_minimalfixture - amend tests for root-level class (i.e.
TestRecord):- amend tests for root-level cattrs hooks if top-level hooks changed (as an integration check)
- amend variants in
test_loopas needed (include all possible options in complete variant)
- amend list of unsupported properties in
/docs/data-model.md#record-limitationsas needed
assets_tracking_service.lib.arcgis
The Esri ArcGIS API for Python package is not used in this project due to the number of dependencies it relies on (see Esri/arcgis-python-api#1692).
Instead, direct HTTP requests are made the relevant operations in the ArcGIS REST API.
A vendored subset of data classes and enums for representing content items are maintained in this package.
Warning
These classes have been modified from their original versions in some cases to remove unneeded functionality and to adjust types to comply with linting rules in this project.
Supported item JSON properties:
- id
- owner
- org_id
- url (service endpoint)
- access (sharing level)
- title
- type [enum]
- snippet
- description
- accessInformation (attribution)
- licenseInfo
Unsupported item JSON properties:
- created
- isOrgItem
- modified
- guid
- name
- typeKeywords
- tags
- thumbnail
- documentation
- extent
- categories
- spatialReference
- classification
- culture
- properties
- advancedSettings
- proxyFilter
- size
- subInfo
- appCategories
- industries
- languages
- largeThumbnail
- banner
- screenshots
- listed
- ownerFolder
- protected
- commentsEnabled
- numComments
- numRatings
- avgRating
- cnumViews
- itemControl
- scoreCompleteness
- groupDesignations
- apiToken1ExpirationDate
- apiToken2ExpirationDate
- lastViewed
Warning
This section is Work in Progress (WIP) and may not be complete/accurate.
Note
Overall, this package is limited to functionality required by the esri-record and esri-item dev tasks only.
Partially supported features (not-exhaustive):
- the
metadataEditableproperty- not exposed as a property via these classes
- used only in the
_update_agol_item()method of theesri-itemdev task (force set)
Known unsupported features (not-exhaustive):
- group sharing (see also ArcGIS Item Limitations)
- Unsupported Item JSON Properties