Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

set default tag sorting order #733

Merged
merged 5 commits into from
Apr 7, 2022

Conversation

CagtayFabry
Copy link
Member

@CagtayFabry CagtayFabry commented Apr 5, 2022

Changes

  • update the default sorting order of select_tag for WeldxConverter
  • use full tag naming schema in all explicit converters

Checks

  • updated CHANGELOG.rst

@CagtayFabry CagtayFabry added the ASDF everything ASDF related (python + schemas) label Apr 5, 2022
@CagtayFabry CagtayFabry requested a review from marscher April 5, 2022 10:26
@CagtayFabry CagtayFabry mentioned this pull request Apr 5, 2022
5 tasks
@github-actions
Copy link

github-actions bot commented Apr 5, 2022

Unit Test Results

       1 files  ±0         1 suites  ±0   3m 2s ⏱️ -50s
2 158 tests ±0  2 158 ✔️ ±0  0 💤 ±0  0 ±0 

Results for commit 9cf873c. ± Comparison against base commit 027b279.

♻️ This comment has been updated with latest results.

@CagtayFabry CagtayFabry marked this pull request as ready for review April 5, 2022 10:52
@@ -12,8 +12,7 @@
class XarrayDataArrayConverter(WeldxConverter):
"""Serialization class for xarray.DataArray."""

name = "core/data_array"
version = "0.1.0"
tags = ["asdf://weldx.bam.de/weldx/tags/core/data_array-0.1.*"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should these now be tuples as well (as the type hint in the base class suggests.). I added this in #727, since I thought it make more sense to indicate that this is immutable.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

true, probably tuple is fitting

I only used list here because this is how it is in the asdf codebase.
I think the tags attribute gets 'resolved' in asdf and ends up as a list anyway. I don't know if that breaks with tuples here.

Frankly I would just stick to what asdf is doing to avoid any troubles if we can

@CagtayFabry
Copy link
Member Author

please feel free to make further changes and/or merge @marscher

As long as the tests pass we should be good here 👍

@codecov
Copy link

codecov bot commented Apr 5, 2022

Codecov Report

Merging #733 (9cf873c) into master (af9df21) will decrease coverage by 0.00%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master     #733      +/-   ##
==========================================
- Coverage   95.88%   95.88%   -0.01%     
==========================================
  Files          92       92              
  Lines        6496     6489       -7     
==========================================
- Hits         6229     6222       -7     
  Misses        267      267              
Impacted Files Coverage Δ
weldx/geometry.py 96.80% <ø> (ø)
weldx/asdf/types.py 94.02% <100.00%> (+0.18%) ⬆️
weldx/tags/core/data_array.py 100.00% <100.00%> (ø)
weldx/tags/core/dataset.py 100.00% <100.00%> (ø)
weldx/tags/core/file.py 100.00% <100.00%> (ø)
weldx/tags/core/generic_series.py 100.00% <100.00%> (ø)
weldx/tags/core/graph.py 100.00% <100.00%> (ø)
weldx/tags/core/mathematical_expression.py 96.66% <100.00%> (-0.11%) ⬇️
...gs/core/transformations/local_coordinate_system.py 100.00% <100.00%> (ø)
weldx/tags/core/transformations/rotation.py 100.00% <100.00%> (ø)
... and 5 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 027b279...9cf873c. Read the comment docs.


def to_yaml_tree(self, obj, tag: str, ctx: SerializationContext):
raise NotImplementedError

def from_yaml_tree(self, node: dict, tag: str, ctx: SerializationContext):
raise NotImplementedError

def select_tag(self, obj, tags, ctx):
return sorted(tags)[-1]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we be sure, that the tags/objs involved are part of weldx? Should we make this assertion here, or in converters deriving from this, treating a special case?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we cannot really be sure of this here in cases where we also support 'reading' other tags into weldx properties (e.g. asdf/astropy quantities)

Right now I have implemented this manually in places where we support other tags

def select_tag(self, obj, tags, ctx):
tags = [tag for tag in tags if tag.startswith(WELDX_TAG_URI_BASE)]
return sorted(tags)[-1]

This code is probably a more reasonable default so there is one less thing to worry about in the Converter implementation (and if we ever want to write out a non weldx tag we can implement this in the converter)

To be extra save we could also guard the list sorting like so

def select_tag(self, obj, tags, ctx): 
    weldx_tags = [tag for tag in tags if tag.startswith(WELDX_TAG_URI_BASE)]
    if weldx_tags:
        return sorted(weldx_tags)[-1]
    return sorted(tags)[-1] 

@marscher marscher merged commit 99dbac2 into BAMWelDX:master Apr 7, 2022
@CagtayFabry CagtayFabry deleted the default_tag_sorting branch April 19, 2022 16:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ASDF everything ASDF related (python + schemas)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants