diff --git a/README.md b/README.md index 7729924326b1ca95fa8fc0cbd82183003ed206ba..9b6d74f57671a274340c995c23d72fd3f03cd22e 100644 --- a/README.md +++ b/README.md @@ -25,4 +25,4 @@ But there is some inline documentation in [lib/siplib.py](siplib.py) and you may The initial version of the siblib in this repo is version 0.4 -Because the siplib is strongly coupled to the SIP xsd, the version numbering of the siplib will match with the version of the xsd schema which is 2.8.0 now. \ No newline at end of file +Because the siplib is strongly coupled to the SIP xsd, the version numbering of the siplib will match with the version of the xsd schema which is 2.8.1 now. \ No newline at end of file diff --git a/lib/etc/LTA-SIP.xsd b/lib/etc/LTA-SIP.xsd index f1c32c7b4520cbdfe2e2a8bc52411cabe05505bc..cd6618ab808f1ec0779e9b01cebdce8000c10df7 100644 --- a/lib/etc/LTA-SIP.xsd +++ b/lib/etc/LTA-SIP.xsd @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> -<xs:schema targetNamespace="http://www.astron.nl/SIP-Lofar" version="2.8.0" xmlns="http://www.astron.nl/SIP-Lofar" xmlns:xs="http://www.w3.org/2001/XMLSchema"> +<xs:schema targetNamespace="http://www.astron.nl/SIP-Lofar" version="2.8.1" xmlns="http://www.astron.nl/SIP-Lofar" xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:annotation> <xs:documentation> XML Schema for data model Submission Information Package LOFAR Long Term Archive @@ -616,7 +616,7 @@ <xs:element name="dataProductIdentifier" type="IdentifierType" maxOccurs="unbounded"/> </xs:sequence> </xs:complexType> - <xs:complexType name="PipelineRun"> + <xs:complexType name="PipelineRun" abstract="true"> <xs:complexContent> <xs:extension base="Process"> <xs:sequence> diff --git a/lib/ltasip.py b/lib/ltasip.py index 518fc49d580aced196016aa9e283b94e79bb52f5..c7ad2b7b5db54c3453992386b3a536a97cf97158 100644 --- a/lib/ltasip.py +++ b/lib/ltasip.py @@ -5,6 +5,18 @@ # Namespace http://www.astron.nl/SIP-Lofar from __future__ import unicode_literals + +try: + import pyxb.binding +except AttributeError: + import sys + if sys.version_info.major == 3 and sys.version_info.minor >= 10: + # MutableSequence, Iterable was moved in pyton 3.10 + # make pyxb work with 3.10 + import collections + collections.MutableSequence = collections.abc.MutableSequence + collections.Iterable = collections.abc.Iterable + import pyxb import pyxb.binding import pyxb.binding.saxer @@ -3610,7 +3622,7 @@ class PipelineRun(Process): """Complex type {http://www.astron.nl/SIP-Lofar}PipelineRun with content type ELEMENT_ONLY""" _TypeDefinition = None _ContentTypeTag = pyxb.binding.basis.complexTypeDefinition._CT_ELEMENT_ONLY - _Abstract = False + _Abstract = True _ExpandedName = pyxb.namespace.ExpandedName(Namespace, 'PipelineRun') _XSDLocation = pyxb.utils.utility.Location(DEFAULT_SIP_XSD_PATH, 619, 1) _ElementMap = Process._ElementMap.copy() diff --git a/lib/siplib.py b/lib/siplib.py index 98e64f5257e3e131efd1b1e42aaa5622c7a69f51..af8b6382efc450c4e6bf92f4159bd22ab89c3cfd 100644 --- a/lib/siplib.py +++ b/lib/siplib.py @@ -39,7 +39,7 @@ import logging logger = logging.getLogger(__name__) -VERSION = "SIPlib 2.8.0" +VERSION = "SIPlib 2.8.1" ltasip.Namespace.setPrefix('sip') @@ -896,7 +896,7 @@ class CorrelatorProcessing(): __channelwidth = None if channelwidth_frequency and channelwidth_frequencyunit: - __channelwidth = ltasip.Frequency(channelwidth_frequency, units=channelwidth_frequencyunit), + __channelwidth = ltasip.Frequency(channelwidth_frequency, units=channelwidth_frequencyunit) self.__pyxb_rtprocessing = ltasip.Correlator( integrationInterval=ltasip.Time(integrationinterval, units=integrationinterval_unit), @@ -963,7 +963,7 @@ class CoherentStokesProcessing(): processingType=processingtype) # Somehow this does not work in the constructor: - self.__pyxb_rtprocessing.channelwidth = __channelwidth + self.__pyxb_rtprocessing.channelWidth = __channelwidth def _get_pyxb_rtprocessing(self, suppress_warning=False): if not suppress_warning: @@ -998,7 +998,7 @@ class IncoherentStokesProcessing(): __channelwidth = None if channelwidth_frequency and channelwidth_frequencyunit: - __channelwidth = ltasip.Frequency(channelwidth_frequency, units=channelwidth_frequencyunit), + __channelwidth = ltasip.Frequency(channelwidth_frequency, units=channelwidth_frequencyunit) self.__pyxb_rtprocessing = ltasip.IncoherentStokes( rawSamplingTime=ltasip.Time(rawsamplingtime, units=rawsamplingtime_unit), @@ -1016,7 +1016,7 @@ class IncoherentStokesProcessing(): cobaltPipelineNumber=cobaltpipelinenumber, processingType = processingtype) # Somehow this does not work in the constructor: - self.__pyxb_rtprocessing.channelwidth = __channelwidth + self.__pyxb_rtprocessing.channelWidth = __channelwidth def _get_pyxb_rtprocessing(self, suppress_warning=False): if not suppress_warning: @@ -1059,7 +1059,7 @@ class FlysEyeProcessing(): # Somehow this does not work in the constructor: - self.__pyxb_rtprocessing.channelwidth = __channelwidth + self.__pyxb_rtprocessing.channelWidth = __channelwidth def _get_pyxb_rtprocessing(self, suppress_warning=False): if not suppress_warning: @@ -1347,8 +1347,8 @@ class Observation(): # Somehow this does not work in the constructor: if channelwidth_frequency and channelwidth_frequencyunit: - self.__pyxb_observation.channelwidth = ltasip.Frequency(channelwidth_frequency, - units=channelwidth_frequencyunit), + self.__pyxb_observation.channelWidth = ltasip.Frequency(channelwidth_frequency, + units=channelwidth_frequencyunit) def _get_pyxb_observation(self, suppress_warning=False): if not suppress_warning: @@ -1446,7 +1446,7 @@ class Sip(object): observingmode, description, process_map, - ): + return_xml=True): up = ltasip.UnspecifiedProcess( observingMode=observingmode, @@ -1454,21 +1454,22 @@ class Sip(object): **process_map.get_dict() ) self.__sip.unspecifiedProcess.append(up) - - return self.get_prettyxml() + if return_xml: + return self.get_prettyxml() def add_parset(self, identifier, - contents): + contents, + return_xml=True): self.__sip.parset.append(ltasip.Parset( identifier=identifier._get_pyxb_identifier(suppress_warning=True), contents=contents )) + if return_xml: + return self.get_prettyxml() - return self.get_prettyxml() - - def add_related_dataproduct_with_history(self, relateddataproduct_sip): + def add_related_dataproduct_with_history(self, relateddataproduct_sip, return_xml=True): # add the dataproduct described by the SIP (if not there) if not any( x.dataProductIdentifier.identifier == relateddataproduct_sip.__sip.dataProduct.dataProductIdentifier.identifier @@ -1507,7 +1508,8 @@ class Sip(object): for par in relateddataproduct_sip.__sip.parset: if not any(x.identifier.identifier == par.identifier.identifier for x in self.__sip.parset): self.__sip.parset.append(par) - return self.get_prettyxml() + if return_xml: + return self.get_prettyxml() def get_dataproduct_identifier(self): """ diff --git a/lib/validator.py b/lib/validator.py index 64097a4d8242b2ea0adbeb86e26a1cb934ea9e17..d926789731c60c0d31a241da0c46ce3629a17362 100644 --- a/lib/validator.py +++ b/lib/validator.py @@ -95,7 +95,7 @@ def check_consistency(sip): if not id_from in linkstodataproduct: raise Exception("The input dataproduct for pipeline '" + id + "' seems to be missing! -> ", id_from) - logger.info("General SIP structure seems ok!") + logger.info("General SIP structure for dataproduct with sip_id=%s seems ok!", id_out) return True # already raised Exception if there was a problem... diff --git a/setup.py b/setup.py index 6214ee1f6a3dd965dc9dd1dc41352813361f7078..6b7ab58f8ab5e31832ed11e745a82c944df3e8cb 100644 --- a/setup.py +++ b/setup.py @@ -11,7 +11,7 @@ scripts = glob.glob('bin/*') setuptools.setup( name="siputils", - version="2.8.0", + version="2.8.1", setuptools_git_versioning={ "template": "{tag}", "dev_template": "{tag}.dev{ccount}+git.{sha}", diff --git a/test/test_files/sipfrommom.xml b/test/test_files/sipfrommom.xml index 2de6a69249ad43f54779458a53ab7d28e1f2c4d5..d53da39e283bcc7a84ba89608ae32c0cb09a8f9b 100644 --- a/test/test_files/sipfrommom.xml +++ b/test/test_files/sipfrommom.xml @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <sip:ltaSip xmlns:sip="http://www.astron.nl/SIP-Lofar" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.astron.nl/SIP-Lofar LTA-SIP-2.8.0.xsd "> + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.astron.nl/SIP-Lofar LTA-SIP-2.8.1.xsd "> <sipGeneratorVersion>Version v2.17.5 (29-08-2016) (modified by hand by RG, May 2022)</sipGeneratorVersion> <project> <projectCode>LC6_016</projectCode> diff --git a/test/test_files/valid_sip.xml b/test/test_files/valid_sip.xml index bd7815c9e3fa74e5d974c55ddc9540affa68f1cd..ce62f965b8c7ca19896c19c065db5b75bee7e4d1 100644 --- a/test/test_files/valid_sip.xml +++ b/test/test_files/valid_sip.xml @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <sip:ltaSip xmlns:sip="http://www.astron.nl/SIP-Lofar" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.astron.nl/SIP-Lofar LTA-SIP-2.8.0.xsd "> + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.astron.nl/SIP-Lofar LTA-SIP-2.8.1.xsd "> <sipGeneratorVersion>Version v2.17.5 (29-08-2016) (modified by hand by RG, May 2022)</sipGeneratorVersion> <project> <projectCode>LC6_016</projectCode> diff --git a/test/test_siplib.py b/test/test_siplib.py index acb514b115545868567eb19c5306126f3b06d8f7..53a9e3fc8bc03f552f40291ed2bcfe758f48d911 100755 --- a/test/test_siplib.py +++ b/test/test_siplib.py @@ -594,12 +594,14 @@ class TestSIPlib(unittest.TestCase): def test_pipelines(self): mysip = create_basicdoc() - logger.info("===\nAdding simple pipelinerun:\n") - logger.info(mysip.add_pipelinerun( - siplib.SimplePipeline( - create_pipelinemap() - ) - )) + with self.assertRaises(pyxb.exceptions_.AbstractInstantiationError) as context: + logger.info("===\nAdding simple pipelinerun:\n") + logger.info(mysip.add_pipelinerun( + siplib.SimplePipeline( + create_pipelinemap() + ) + )) + self.assertIn('Cannot instantiate abstract type {http://www.astron.nl/SIP-Lofar}PipelineRun directly', str(context.exception)) logger.info("===\nAdding generic pipelinerun:\n") logger.info(mysip.add_pipelinerun( diff --git a/version b/version index 834f2629538327723c074ed4c3addca9888f0256..dbe590065479b394ecabbd44460125ae5fe544bf 100644 --- a/version +++ b/version @@ -1 +1 @@ -2.8.0 +2.8.1