mivot_validator.instance_checking.xml_interpreter package

Submodules

mivot_validator.instance_checking.xml_interpreter.annotation_seeker module

Created on 11 Dec 2021

@author: laurentmichel

class mivot_validator.instance_checking.xml_interpreter.annotation_seeker.AnnotationSeeker(xml_block)[source]

Bases: object

This class provides tools extracting mapping sub-blocks that often used by others stakeholders All functions using the mapping are using this class the get XML elements. To make the job simpler for others tools, the XML is namespace removed from the mapping block whatever it is. This is usually done by Astropy as well

get_collection_item_by_primarykey(coll_dmid, key_value)[source]

Get the GLOBALS/COLLECTION/INSTANCE with COLLECTION@dmid=dmid and the INSTANCE has a PRIMARY_ke which @value matches key_value An exception is risen if there less or more than one element matching the criteria. The 2 parameter match the dynamic REFERENCE definition :param coll_dmid: :param key_value:

get_globals()[source]

GLOBALS getter

get_globals_collection(dmid)[source]

Gets the GLOBALS/COLLECTION with @dmid=dmid :param dmid:

get_globals_collection_dmids()[source]

Gets the list of all the @dmid of GLOBALS/COLLECTION

get_globals_collection_dmtypes()[source]

Gets the list the @dmtype of GLOBALS/COLLECTION/INSTANCE Used for collections of static objects

get_globals_collections()[source]

Returns the list of all GLOBALS/COLLECTION elements. These collection have no dmroles but often dmids. They have particular roles - Used by references (e.g. filter definition) - Used as head of the mapped model (e.g. [Cube instance])

get_globals_instance_by_dmid(dmid)[source]

Gets the GLOBALS/INSTANCE with @dmid=dmid :param dmid:

get_globals_instance_dmids()[source]

Gets the list the @dmid GLOBALS/INSTANCE :param dmid:

get_globals_instance_dmtypes()[source]

Gets the list the @dmtype GLOBALS/INSTANCE

get_globals_instance_from_collection(sourceref, pk_value)[source]

Gets the GLOBALS/COLLECTION[@dmid=sourceref]/INSTANCE/PRIMARY_KEY[@value=’pk_value’] :param dmid:

get_globals_instances()[source]

Returns the list of all GLOBALS/INSTANCE elements. These collection have no dmroles but often dmids. They have particular roles - Used by references (e.g. filter definition) - Used as head of the mapped model (e.g. Cube instance)

get_instance_by_dmtype(dmtype_pattern)[source]

Gets all the mapped instances that have a @dmtype containing dmtype_pattern :param dmtype_pattern:

get_instance_dmtypes()[source]

Gets @dmtypes of all mapped instances

get_tablerefs()[source]

Return the list of all the @tableref found in the mapping

get_templates_block(tableref)[source]

Return the TEMPLATES mapping block of the table matcing @tableref :param tableref:

get_templates_instance_by_dmid(tableref, dmid)[source]

Gets the TEMPLATES/INSTANCE with @dmid=dmid and TEMPLATES@tableref=tableref :param tableref: @tableref of the serarched TEMPLATES :param dmid: searched @dmid

mivot_validator.instance_checking.xml_interpreter.att_utils module

Created on Jul 6, 2020

@author: laurentmichel

class mivot_validator.instance_checking.xml_interpreter.att_utils.AttUtils[source]

Bases: object

Some static methods doing tests on JSON mapping elements

static id_matches(element, searched_id)[source]

Returns True if element[@ID] matches id

static type_matches(element, searched_type)[source]

Returns True if element[@dmtype] matches searched_type

mivot_validator.instance_checking.xml_interpreter.dynamic_reference module

Created on 22 Dec 2021

@author: laurentmichel

class mivot_validator.instance_checking.xml_interpreter.dynamic_reference.DynamicReference(model_view, tag_name, templates_ref, xml_block)[source]

Bases: object

classdocs

get_target_instance(data_row)[source]

mivot_validator.instance_checking.xml_interpreter.exceptions module

Created on 11 Dec 2021

@author: laurentmichel

exception mivot_validator.instance_checking.xml_interpreter.exceptions.MappingException[source]

Bases: Exception

exception mivot_validator.instance_checking.xml_interpreter.exceptions.NotImplementedException[source]

Bases: Exception

mivot_validator.instance_checking.xml_interpreter.join_operator module

Set of 2 classes operating the join operations. Retrieve ad format data that are joined with a particular primary row

Created on 22 Dec 2021

@author: laurentmichel

class mivot_validator.instance_checking.xml_interpreter.join_operator.JoinOperator(model_view, table_ref, xml_join_block)[source]

Bases: object

classdocs

get_matching_data(primary_row)[source]
get_matching_model_view(resolve_ref=True)[source]
class mivot_validator.instance_checking.xml_interpreter.join_operator.Where(resource_seeker, foreignkey, primarykey, fk_is_constant=False)[source]

Bases: object

Evaluator of foreign data against a primary key

match(primary_key_value, foreign_row)[source]

Returns True if the value of the foreign key read out of the foreign row matches primary_key_value The comparisons are based on string representations of the evaluated values

Parameters:
  • primary_key – value of the primary key

  • foreign_row – Numpy data row of the joined table that must be checked against the primary key

set_foreign_col(foreign_table_ref)[source]
set_primary_col(primary_table_ref)[source]

mivot_validator.instance_checking.xml_interpreter.model_viewer module

Created on 5 Jan 2022

@author: laurentmichel

class mivot_validator.instance_checking.xml_interpreter.model_viewer.ModelViewer(resource, votable_path=None)[source]

Bases: object

ModelViewer is a PyVO table wrapper aiming at providing a model view on VOTable data read with usual tools

Standard usage applied to data rows

votable = parse(votable_path)
for resource in votable.resources:
    model_viewer = ModelViewer(resource)
    model_viewer.connect_table("results")
    while True:
        data_row = model_viewer.get_next_row()
        if data_row is None:
            break
        model_view = model_viewer.get_model_view()
        json_model_view = model_viewer.get_json_model_view()
    break

Standard usage applied to global instances

votable = parse(votable_path)
for resource in votable.resources:
    model_viewer = ModelViewer(resource)
    time_series = model_viewer.get_globals_instance("cube:TimeSeries")
property annotation_seeker

Return an API to search various components in the XML mapping block

connect_table(tableref)[source]

Iterate over the table identified by tableref Required to browse table data. Connect to the first table if tableref is None

property connected_table
property connected_table_ref
property current_data_row
get_declared_models()[source]

return the list of declared models ({name: url, …}

get_globals_instance(dmtype, resolve_ref=True)[source]

The a model view on the GLOBALS object (INSTANCE or COLLECTION) with @dmtype=dmtype

get_globals_models()[source]

Collection types are GLOBALS/COLLECTION/INSTANCE@dmtype: used for collections of static objects

:returnThe dmtypes of all the top level INSTANCE/COLLECTION

of GLOBALS

Return type:

{‘COLLECTION’: [dmtpyes], ‘INSTANCE’: [dmtypes]}

get_model_component_by_role(searched_dmrole)[source]

return the list of the xml instances with dmrole=searched_role from the model view of the current data row Return a [] if no matching dmrole was found

get_model_component_by_type(searched_dmtype)[source]

return the list of the xml instances with @dmtype=searched_ type from the model view of the current data row Return a {} if no matching dmtype was found

get_model_view(resolve_ref=True)[source]

return a XML model view of the last read row

get_next_row()[source]

Return the next data row of the connected table

get_table_ids()[source]

return a list of the table located just below self.resource

get_templates_models()[source]

COLLECTION not implemented yet

:returnThe dmtypes (except ivoa:ANY) of all INSTANCE/COLLECTION

of all TEMPLATES

Return type:

{‘tableref: {‘COLLECTIONS’: [dmtpyes], ‘INSTANCE’: [dmtypes]}, …}

property resource_seeker

Return an API to search various components in the VOTabel resource

rewind()[source]

Rewind the table iterator of the connected table

mivot_validator.instance_checking.xml_interpreter.resource_seeker module

Created on 7 Nov 2021

@author: laurentmichel

class mivot_validator.instance_checking.xml_interpreter.resource_seeker.ResourceSeeker(resource)[source]

Bases: object

TODO At the time of writing the class is static in order to be callable from any part of the code. This feature should be made thread-safe in a public release

get_id_index_mapping(table_name)[source]

build an index binding colum number with field id :param table_name: name of the table

get_id_unit_mapping(table_name)[source]

build an index binding filed unit with field id :param table_name: name of the table

get_params()[source]

returns the VOTable PARAMS

get_table(table_name)[source]

Returns the table matching table_name first by ID and the by name :param table_name:

get_table_ids()[source]

Return the list of table ids Only resource children are considered The id is first look up in ID then in name and finally ‘AnonymousTable’ is taken

votable = None
votable_path = None

mivot_validator.instance_checking.xml_interpreter.static_reference_resolver module

Created on 22 Dec 2021

@author: laurentmichel

class mivot_validator.instance_checking.xml_interpreter.static_reference_resolver.StaticReferenceResolver[source]

Bases: object

Namespace for the function processing the static REFERENCEs

static resolve(annotation_seeker, templates_ref, instance)[source]

Resolve all static REFERENCEs found in instance. The referenced objects are first searched in GLOBALS and then in the templates_ref table. REFERENCE elements are replaced with the referenced objects set with the roles of the REFERENCEs

  • A exception is risen if the reference cannot be resolved

  • Works even if REFERENCE tags are numbered by the former processing

Parameters:
  • annotation_seeker – utility to extract desired elements from the mapping block

  • templates_ref – Identifier of the table where instance comes from

  • instance – etree Element

Returns:

the number of references resolved

static resolve_from_forein_key(ref_element, annotation_seeker)[source]

Resolve a static reference based on a key mechanism e.g.

<REFERENCE_4 dmrole="coords:Coordinate.coordSys"
             sourceref="_CoordinateSystems">
    <FOREIGN_KEY ref="_band" value="G"/>
</REFERENCE_4>
  • The target table is meant to be in GLOBALS

  • FOREIGN_KEY@value is not pas of the mapping, it is meant to be added by the caller while reading the data rows

Parameters:
  • annotation_seeker – utility to extract desired elements from the mapping block

  • ref_element – <REFERENCE> element

mivot_validator.instance_checking.xml_interpreter.table_iterator module

Created on 1 dec. 2021

@author: laurentmichel

class mivot_validator.instance_checking.xml_interpreter.table_iterator.TableIterator(name, data_table)[source]

Bases: object

Simple wrapper iterating over table rows

mivot_validator.instance_checking.xml_interpreter.vocabulary module

Created on 30 août 2021

author: michel

class mivot_validator.instance_checking.xml_interpreter.vocabulary.Att[source]

Bases: object

classdocs

dmid = 'dmid'
dmref = 'dmref'
dmrole = 'dmrole'
dmtype = 'dmtype'
foreignkey = 'foreignkey'
name = 'name'
primarykey = 'primarykey'
ref = 'ref'
sourceref = 'sourceref'
tableref = 'tableref'
value = 'value'
class mivot_validator.instance_checking.xml_interpreter.vocabulary.Ele[source]

Bases: object

classdocs

ATTRIBUTE = 'ATTRIBUTE'
COLLECTION = 'COLLECTION'
GLOBALS = 'GLOBALS'
INSTANCE = 'INSTANCE'
JOIN = 'JOIN'
MODEL = 'MODEL'
NOROLE = 'NOROLE'
REFERENCE = 'REFERENCE'
TEMPLATES = 'TEMPLATES'
VODML = 'VODML'
WHERE = 'WHERE'
namespace = ''
mivot_validator.instance_checking.xml_interpreter.vocabulary.key_match(searched_key, key_set)[source]

Module contents