Releases: G-Node/python-odml
Releases · G-Node/python-odml
Version 1.4.0
Breaking changes
The switch from odML version 1.3 to 1.4 contains many cool updates which should make work more comfortable, but also includes some breaking changes.
Update of the odML file format version
- The odML format version number in odML files has changed from "1" to "1.1".
Changes in odML classes
- The odML class hierarchy has been flattened:
- removing
base._baseobjclass, leavingBaseObjectas the root odML class. - removing
doc.Documentclass, leavingBaseDocumentas the only odML Document class. - removing
section.Sectionclass, leavingBaseSectionas the only odML Section class. - removing
property.Propertyclass leavingBasePropertyas the only odML Property class.
- removing
baseobjectandsectionableare renamed toBaseObjectandSectionablerespectively.base.SafeListandbase.SmartListhave been merged,base.SafeListhas been removed.base.SmartListcan now only contain Sections or Properties. See #272.- The
reordermethod is moved from thebaseto theSectionclass. See #267.
Changes in Value handling:
- The
Valueclass has been removed. Property.valuenow always holds a list of uniform values.Property.valuealways returns a copy of the actual value list. See #227.- Values can only be changed directly via the
__setitem__method of aProperty Valueattributesuncertainty,unit,dtypeandreferencehave been moved toPropertyand now apply to all values of theProperty.valuelist.- The
Valueattributesfilename,encoderandchecksumhave been removed.
DType changes:
- The
binarydtype has been removed. Providing binary content via odML files is discouraged in favor of providing a reference to the origin files using theURLdtype instead.
Mapping
- Any
mappingfunctionality has been removed.
Minor breaking changes
XMLReader.fromFile()and.fromString()have been renamed to.from_file()and.from_string()respectively.
Features and changes
Required odML entity attributes handling
- Required attributes of odML entities in
odml.formatwhere changed:Section.name,Section.typeandProperty.nameare the only attributes set to be required for their respective odML entities. See #240. Section.nameandProperty.namecan now beNoneon init. If this is the case, the entities'idvalue is used asnamevalue.- Hardcoded checks for existing
nameattributes in the XML Parser are removed. Only attributes set as required informatare now used to check for missing required odML entity attributes. See #241. - The
nameattribute of aSectionor aPropertycan now only be rewritten if there is no sibling with the same name on the same hierarchical level. See #283.
Addition of the 'id' attribute
Document,SectionandPropertynow have anidattribute to uniquely identify any entity. If no valid id is provided when an entity is initialized, an id is automatically generated and assigned.- Adding the
new_id()method toDocument,SectionandPropertywhich generates and sets a new valid id for any entity. See #262.
Changes in DType handling
- Setting a dtype now also supports odML style tuple types. See #254.
- DTypes now always return the defined default values if a value is
Noneor"". - Any boolean dtype value other than
"false", "f", 0, False, "true", "t", 1orTruewill now raise aValueError. See #224
'base.Sectionable' (Document and Section) changes
- Adds a
base.Sectionable.extendmethod for child Sections and Properties. See #237. - Refactors the
base.Sectionable.insertand.appendmethods. Only properBaseSectionswith a unique name can be added to the Section child list of aSectionable. - Appending multiple Sections or Properties has been removed from the
appendmethod to mirror Propertyappendfunctionality and sinceextendnow serves this need.
'Section' and 'Property' merge
Propertynow provides amergemethod to merge two properties. This will sync all but the dependency and dependencyValue attributes. ValueErrors are raised, if information is set in both properties but are in conflict. See #221.- Adds a
Section.merge_check()method which validates whether a Section including all its sub-sections and sub-properties can properly be merged. AValueErroris raised if any potential merge problem arises. This is necessary since a recursive Section merge cannot be easily rolled back once begun. - A Section merge imports
referenceanddefinitionfrom the "source" Section if they wereNonein the "destination" Section. See #273. - Adds a
strictflag to anymergemethod. Now allSectionandPropertyattribute checks during a merge will only be done, ifstrict=True. Onstrict=FalseaSectionorPropertyattribute will only be replaced with the "source" value, if the "destination" value isNone. Otherwise the "destination" value will be kept and the "source" value lost. See #270.
Changes of 'Section' and 'Property' clone
- When a
Sectionor aPropertyis cloned, a new id is set for the clone and of any cloned children. See #259.
'Document' changes
- Tuples of Sections can now no longer be used with
Document.appendsinceDocument.extendshould be used to add multiple new Sections to a Document.
'Section' changes
- Adds a
Section.extendmethod.
'Property' changes
Propertyhas the new attributevalue_originwhich may contain the origin of the property's value e.g. a filename.Propertyinit now supports setting all attributes as well as its parent.Propertynow providesappend,extendandremovemethods to change the actual value list. This approach is required to ensure DType checks when adding new values to an existing list. See #223.- Only valid dtypes can now be set on
Propertyinit. See #253.
Terminology changes
- The default odML terminology repository is set to
http://portal.g-node.org/odml/terminologies/v1.1/terminologies.xml.
Changes in Tools and IO
- The
XMLParsercan now be run in warning mode: any errors encountered during parsing will just print a warning, but will not stop and exit during the parsing process. - An odML document can now only be saved, if the validation does not show any errors. Saving an invalid document will stop the process before saving and print all encountered errors.
- All parsers are now more relaxed when encountering unsupported or missing tags and only print warnings instead of ending with an exception. Warnings are collected and can be accessed via the parser object.
- When trying to open a file with any of the odML parsers, the document format version number is checked. If the version number does not match the supported one, file loading will fail with an exception.
New tools
- Added the
tools.RDFWriterandtoosl.RDFReaderclasses, which enable the export of odML documents to RDF and also provides the used ontology OWL file atdoc/odml_terminology/. - Added the
tools.ODMLWriterandtools.ODMLReaderclasses which serve as an easy entry point to saving and loading for all the supported file formatsXML,YAML,JSONandRDF. - Added the
tools.DictWriterandtools.DictReaderclasses which convert Python dictionary data to odML data and vice versa, which in turn is required for both YAML and JSON format loading and saving. - Removed the
tools.jsonparserfile which is no longer required due to the classes intools.odmlparserandtools.dict_parser. - Added the
tools.FormatConverterclass which enables batch conversion of one odML format into another. - Added the
tools.VersionConverterclass which enables conversion of pre-v1.4 odML files into valid v1.4 odML.- The
VersionConverterconvertsXML,JSONandYAMLbased odML files of odML file version 1.0 to odML file version 1.1. - Only attributes supported by
Document,SectionandPropertyare exported. Any non supported attribute will produce a warning message, the content will be discarded. - The value content is moved from a
Valueobject to its parentPropertyvalue list. - The first encountered
unitoruncertaintyof values of aPropertywill be moved to its parentProperty. Any differing subsequentunitoruncertaintyof values of the samePropertywill produce a warning message, the content will be discarded. - The first
filenameattribute content of aValueis moved to thevalue_originattribute of its parentProperty. - Any g-node terminology URL in
repositoryorlinkis updated from v1.0 to their v1.1 counterparts if available. - A
VersionConverterobject provides a.conversion_loglist attribute to access all info and warning messages after a conversion has taken place. See #234.
- The
Fixes
- Various installation issues have been resolved for Linux and MacOS.
Falseas well asFare now properly converted to bool values in both Python 2 and 3. See #222.- Fixes saving datetime related values to JSON. See #248.
- odML style custom tuples can now properly be saved using the
XMLParser. Documentnow properly uses the dtypes date setter on init. See #249.- Fixes load errors on Empty and
Noneboolean and datetime related values. See #245. - Excludes
idwhen comparing odML entities for equality. See #260. - When a
Propertyis cloned, the parent of the clone is now properly set toNone. - Avoids an
AttributeErroronget_path()when aPropertyhas no parent. See #256. - Avoids an
AttributeErroronget_merged_equivalent()when aPropertyhas no parent. See #257. - Avoids an error on
Property.append(), if the dtype was not set. See #266. - Makes sure that
Property.append()exits on empty values but accepts0andFalse. - Sets `Property.uncerta...
Version 1.3.4
Fixes
- Potential installation issues due to import from
info.py.
Version 1.3.3
Features
- Terminology caching and loading update.
- Terminology section access and type listing functions.
- Define and use common format version number for all parsers.
- Supported format version check: When trying to open a file with any of the odml parsers, first the document format version number is checked. If the found version number does not match the supported one, file loading will fail an exception, since this is the oldest format version. If anyone tries to open a newer format, they should first update their odML package and not use this one.
- Document saving: An odML document can now only be saved, if the validation does not show any errors. Saving an invalid document will exit while printing all encountered errors.
- Parser: All parsers are now more relaxed when encountering unsupported tags or missing tags and only print warnings instead of ending with an exception. Warnings are collected and can be accessed via the parser object (required for display in odml-ui to avoid potential loss of information).
- Package and format information added or updated:
Version,Format version,Contact,Homepage,Author, PyPIClassifiers,Copyright. - Removes the license text from
setup.py. The license text interfered with the PyPI process in a way, that the description was not displayed on PyPI. - Removes the image folder from the project, since they are exclusively used in the outsourced odml-ui project.
Fixes
Version 1.3.2
- Expose load, save, and display functions to top level module
- These functions accept a
backendargument that specifies the parser or writer. Can be one ofXML,JSON, orYAML.
- These functions accept a
Version 1.3.1
- move ui to a separate repository https://github.com/g-node/odml-ui
- python3 compatibility
- add json and yaml storage backends