Django Framework
django_basin3d.catalog
- synopsis:
The Django BASIN-3D Catalog
- module author:
Val Hendrix <vhendrix@lbl.gov>
- module author:
Danielle Svehla Christianson <dschristianson@lbl.gov>
- class django_basin3d.catalog.CatalogDjango(variable_filename='basin3d_observed_property_vocabulary.csv')[source]
Bases:
CatalogBase- find_attribute_mappings(datasource_id=None, attr_type=None, attr_vocab=None, from_basin3d=False)[source]
Find the list of attribute mappings given the specified fields. Exact matches are returned (see attr_vocab formats below for BASIN-3D vocab nuances). If no fields are specified, all registered attribute mappings will be returned.
- Parameters:
datasource – the datasource object
attr_vocab (
Union[str,List,None]) – the attribute vocabulary, the formats are one of the following: 1) datasource vocab that is a complete vocab 2) BASIN-3D vocab that is a complete vocab for a given attr_type regardless if it is compound or not. 3) BASIN-3D vocab that is compound and fully specified for each attr_type either with the complete vocab or with wildcards.from_basin3d (
bool) – boolean that says whether the attr_vocab is a BASIN-3D vocabulary. If not, then this a datasource vocabulary.
- Return type:
- Returns:
generator that yields
basin3d.models.AttributeMappingobjects
- find_datasource_attribute_mapping(datasource_id, attr_type, datasource_vocab)[source]
Find the datasource attribute vocabulary to BASIN-3D mapping given a specific datasource_id, attr_type, and datasource attr_vocab.
- Param:
datasource_id: the datasource identifier
- Param:
attr_type: attribute type
- Param:
datasource_vocab: the datasource attribute vocabulary
- Return type:
- Returns:
a
basin3d.models.AttributeMappingobject
- find_observed_properties(basin3d_vocab=None)[source]
Report the observed_properties available based on the BASIN-3D vocabularies specified. If no BASIN-3D vocabularies are specified, then return all observed properties available.
- django_basin3d.catalog.load_data_sources(sender, **kwargs)[source]
Load the Broker data sources from the registered plugins.
- Parameters:
sender –
kwargs –
- Returns:
- django_basin3d.catalog.reload_data_sources(sender, **kwargs)[source]
- Parameters:
sender –
kwargs –
- Returns:
django_basin3d.models
- synopsis:
The BASIN-3D Models
- module author:
Val Hendrix <vhendrix@lbl.gov>
- module author:
Danielle Svehla Christianson <dschristianson@lbl.gov>
- class django_basin3d.models.AttributeMapping(*args, **kwargs)[source]
Bases:
ModelA data class for attribute mappings between datasource vocabularies and BASIN-3D vocabularies. These are the associations defined in the datasource (i.e., plugin) mapping file.
- Fields:
attr_type: Attribute Type; e.g., STATISTIC, RESULT_QUALITY, OBSERVED_PROPERTY; separate compound mappings with ‘:’
basin3d_vocab: The BASIN-3D vocabulary; separate compound mappings with ‘:’
basin3d_desc: The BASIN-3D vocabulary descriptions; objects or enum
datasource_vocab: The datasource vocabulary
datasource_desc: The datasource vocabulary description
datasource: The datasource of the mapping
- exception DoesNotExist
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned
Bases:
MultipleObjectsReturned
- attr_type
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- basin3d_desc
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- basin3d_vocab
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- datasource
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parentis aForwardManyToOneDescriptorinstance.
- datasource_desc
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- datasource_id
- datasource_vocab
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- id
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- objects = <django.db.models.manager.Manager object>
- class django_basin3d.models.DataSource(*args, **kwargs)[source]
Bases:
ModelData Source definition
- Attributes:
id: string (inherited)
name: string
id_prefix: string, prefix that is added to all data source ids
plugin_module:
plugin_class:
credentials:
enabled:
- exception DoesNotExist
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned
Bases:
MultipleObjectsReturned
- attributemapping_set
Accessor to the related objects manager on the reverse side of a many-to-one relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Parent.childrenis aReverseManyToOneDescriptorinstance.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()defined below.
- id
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- id_prefix
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- location
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- name
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- objects = <django.db.models.manager.Manager object>
- plugin_class
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- plugin_module
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- class django_basin3d.models.ObservedProperty(*args, **kwargs)[source]
Bases:
ModelDefining the properties being observed (measured). See https://github.com/BASIN-3D/basin3d/blob/main/basin3d/data/basin3d_observed_property_vocabulary.csv
- Fields:
basin3d_vocab: string, BASIN-3D observed property vocabulary
full_name: string, Description of observed property
categories: List of strings, categories (in order of priority), .
units: string, units of the observed property
- exception DoesNotExist
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned
Bases:
MultipleObjectsReturned
- basin3d_vocab
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- categories
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- full_name
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- objects = <django.db.models.manager.Manager object>
- units
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- class django_basin3d.models.StringListField(*args, **kwargs)[source]
Bases:
TextFieldStringListField stored delimited strings in the database.
- Param:
delimiter
- Type:
- platform:
Unix, Mac
- synopsis:
BASIN-3D Serializers
- module author:
Val Hendrix <vhendrix@lbl.gov>
- module author:
Danielle Svehla Christianson <dschristianson@lbl.gov>
About Django Serializers:
Serializers allow complex data such as querysets and model instances to be converted to native Python datatypes that can then be easily rendered into JSON, XML or other content types. Serializers also provide deserialization, allowing parsed data to be converted back into complex types, after first validating the incoming data. https://www.django-rest-framework.org/api-guide/serializers/
- class django_basin3d.serializers.AttributeMappingSerializer(*args, **kwargs)[source]
Bases:
HyperlinkedModelSerializerAttribute Mapping Serializer
- class Meta[source]
Bases:
object- depth = 2
- fields = ('url', 'attr_type', 'basin3d_vocab', 'basin3d_desc', 'datasource_vocab', 'datasource_desc', 'datasource')
- model
alias of
AttributeMapping
- class django_basin3d.serializers.ChooseFieldsSerializerMixin(*args, **kwargs)[source]
Bases:
objectA serializer that dynamically sets fields
- class django_basin3d.serializers.DataSourceSerializer(*args, **kwargs)[source]
Bases:
HyperlinkedModelSerializerData Source serializer that converts a models.DataSource
- class Meta[source]
Bases:
object- depth = 1
- fields = ('url', 'name', 'location', 'id_prefix', 'attribute_mapping', 'observed_property', 'check')
- lookup_field = 'name'
- model
alias of
DataSource
- read_only_fields = ('name', 'location', 'id_prefix', 'attribute_mapping', 'observed_property', 'check')
- get_attribute_mapping(obj)[source]
Return the url for the attribute mapping associated with the current datasource :type obj: :param obj: :return:
- class django_basin3d.serializers.DelimitedListField(*args, **kwargs)[source]
Bases:
ListFieldConvert a delimited string field to a list
- child = CharField()
- class django_basin3d.serializers.ObservedPropertySerializer(*args, **kwargs)[source]
Bases:
HyperlinkedModelSerializerObserved Property Serializer
django_basin3d.views
- platform:
Unix, Mac
- synopsis:
BASIN-3D Views
- module author:
Val Hendrix <vhendrix@lbl.gov>
- module author:
Danielle Svehla Christianson <dschristianson@lbl.gov>
- django_basin3d.views.monitoring_features_lists(request, *args, **kwargs)[source]
Generate list of URLs to views for monitoring features based on availability in datasource
django_basin3d.viewsets
- platform:
Unix, Mac
- synopsis:
BASIN-3D ViewSets
- module author:
Val Hendrix <vhendrix@lbl.gov>
- module author:
Danielle Svehla Christianson <dschristianson@lbl.gov>
- class django_basin3d.viewsets.AttributeMappingViewSet(**kwargs)[source]
Bases:
ReadOnlyModelViewSetReturns a list of the Attribute Mappings for the registered Data Sources.
Properties
url: url, endpoint for Attribute Mapping
attr_type: string, attribute mapping type
basin3d_vocab: string, observed property vocabulary
basin3d_desc: list, Observed Property (dict) or enum (str)
datasource_vocab: string, datasource vocabulary
datasource_desc: string, datasource description
datasource: string, data source defining the observed property
- filter_backends = (<class 'django_filters.rest_framework.backends.DjangoFilterBackend'>,)
- queryset
- serializer_class
alias of
AttributeMappingSerializer
- class django_basin3d.viewsets.DataSourceViewSet(**kwargs)[source]
Bases:
ReadOnlyModelViewSetReturns a list of all Data Sources available to the BASIN-3D service
Properties
url: url, Endpoint for Data Source
name: string, Unique name for the Data Source
location: string, Location of the Data Source
id_prefix: string, unique id prefix for all Data Source ids
attribute_mapping: url, List of Attribute Mappings that are mapped for Data Source
observed_property: url, List of Observed Properties that are mapped for Data Source
check: url, Validate the Data Source connection
- attribute_mapping(request, id_prefix=None)[source]
Retrieve the Attribute Mappings for a Data Source.
Maps to /datasource/{id_prefix}/attributemapping/
- Parameters:
request –
id_prefix –
- Returns:
- check(request, id_prefix=None)[source]
Determine if Data Source is available :type request: :param request: :type id_prefix: :param id_prefix: :return:
- lookup_field = 'id_prefix'
- observed_property(request, id_prefix=None)[source]
Retrieve the Observed Properties mapped for the current Data Source.
Maps to /datasource/{id_prefix}/observedproperty/
- Parameters:
request –
id_prefix –
- Returns:
- queryset
- serializer_class
alias of
DataSourceSerializer
- class django_basin3d.viewsets.ObservedPropertyViewSet(**kwargs)[source]
Bases:
ReadOnlyModelViewSetReturns a list of available BASIN-3D Observed Properties
Properties
url: url, Endpoint for the observed property vocabulary
basin3d_vocab: string, Unique BASIN-3D observed property vocabulary
full_name: string, Descriptive name
categories: list of strings, Categories of which the variable is a member, listed in hierarchical order
units: string, units
- filter_backends = (<class 'django_filters.rest_framework.backends.DjangoFilterBackend'>,)
- queryset
- serializer_class
alias of
ObservedPropertySerializer
- platform:
Unix, Mac
- synopsis:
BASIN-3D
DataSourcecatalog classes- module author:
Valerie C. Hendrix <vchendrix@lbl.gov>
- module author:
Danielle Svehla Christianson <dschristianson@lbl.gov>
- class basin3d.core.catalog.CatalogBase(variable_filename='basin3d_observed_property_vocabulary.csv')[source]
Bases:
object- find_attribute_mappings(datasource, attr_type, attr_vocab, from_basin3d)[source]
Find the list of attribute mappings given the specified fields. Exact matches are returned (see attr_vocab formats below for BASIN-3D vocab nuances). If no fields are specified, all registered attribute mappings will be returned.
- Parameters:
datasource – the datasource object
attr_type – the attribute type
attr_vocab – the attribute vocabulary, the formats are one of the following: 1) datasource vocab that is a complete vocab 2) BASIN-3D vocab that is a complete vocab for a given attr_type regardless if it is compound or not. 3) BASIN-3D vocab that is compound and fully specified for each attr_type either with the complete vocab or with wildcards.
from_basin3d – boolean that says whether the attr_vocab is a BASIN-3D vocabulary. If not, then this a datasource vocabulary.
- Return type:
- Returns:
generator that yields
basin3d.models.AttributeMappingobjects
- find_datasource_attribute_mapping(datasource_id, attr_type, attr_vocab)[source]
Find the datasource attribute vocabulary to BASIN-3D mapping given a specific datasource_id, attr_type, and datasource attr_vocab.
- Param:
datasource_id: the datasource identifier
- Param:
attr_type: attribute type
- Param:
datasource_vocab: the datasource attribute vocabulary
- Return type:
- Returns:
a
basin3d.models.AttributeMappingobject
- find_observed_properties(basin3d_vocab=None)[source]
Report the observed_properties available based on the BASIN-3D vocabularies specified. If no BASIN-3D vocabularies are specified, then return all observed properties available.
- Parameters:
basin3d_vocab – list of the BASIN-3D observed properties
- Return type:
- Returns:
generator that yields
basin3d.models.ObservedPropertyobjects
- find_observed_property(basin3d_vocab)[source]
Return the
basin3d.models.ObservedPropertyobject for the BASIN-3D vocabulary specified.- Parameters:
basin3d_vocab – BASIN-3D vocabulary
- Return type:
- Returns:
a
basin3d.models.ObservedPropertyobject
- exception basin3d.core.catalog.CatalogException[source]
Bases:
ExceptionThe exception class for the Catalog
- class basin3d.core.catalog.CatalogSqlAlchemy(variable_filename='basin3d_observed_property_vocabulary.csv')[source]
Bases:
CatalogBase- find_attribute_mappings(datasource_id=None, attr_type=None, attr_vocab=None, from_basin3d=False)[source]
Find the list of attribute mappings given the specified fields. Exact matches are returned (see attr_vocab formats below for BASIN-3D vocab nuances). If no fields are specified, all registered attribute mappings will be returned.
- Parameters:
attr_vocab (
Union[str,List,None]) – the attribute vocabulary, the formats are one of the following: 1) datasource vocab that is a complete vocab 2) BASIN-3D vocab that is a complete vocab for a given attr_type regardless if it is compound or not. 3) BASIN-3D vocab that is compound and fully specified for each attr_type either with the complete vocab or with wildcards.from_basin3d (
bool) – boolean that says whether the attr_vocab is a BASIN-3D vocabulary. If not, then this a datasource vocabulary.
- Return type:
- Returns:
generator that yields
basin3d.models.AttributeMappingobjects
- find_datasource_attribute_mapping(datasource_id, attr_type, datasource_vocab)[source]
Find the datasource attribute vocabulary to BASIN-3D mapping given a specific datasource_id, attr_type, and datasource attr_vocab.
- Parameters:
- Return type:
- Returns:
a
basin3d.models.AttributeMappingobject
- find_observed_properties(basin3d_vocab=None)[source]
Report the observed_properties available based on the BASIN-3D vocabularies specified. If no BASIN-3D vocabularies are specified, then return all observed properties available.
- basin3d.core.catalog.DATASOURCE_NONE = DataSource(id='', name='', id_prefix='', location='', credentials={})
The default DataSource object when a DataSource is not found
- basin3d.core.catalog.logger = <Basin3dLogger basin3d.core.catalog (WARNING)>
The logger for the catalog