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

Update single-pass weld schema #578

Merged
merged 8 commits into from
Oct 6, 2021
Merged

Conversation

vhirtham
Copy link
Collaborator

@vhirtham vhirtham commented Oct 4, 2021

Changes

Update the single-pass weld schema to use a TimeSeries instead of a Signal for welding_current and welding_voltage

Related Issues

See #559

Checks

  • updated CHANGELOG.rst
  • updated tests
  • updated doc/
  • update example/tutorial notebooks
  • update manifest file

@vhirtham vhirtham added the ASDF everything ASDF related (python + schemas) label Oct 4, 2021
@codecov
Copy link

codecov bot commented Oct 4, 2021

Codecov Report

Merging #578 (09750a9) into master (e2b1602) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #578   +/-   ##
=======================================
  Coverage   94.83%   94.83%           
=======================================
  Files          93       93           
  Lines        5745     5745           
=======================================
  Hits         5448     5448           
  Misses        297      297           
Impacted Files Coverage Δ
weldx/asdf/cli/welding_schema.py 96.90% <ø> (ø)

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 e2b1602...09750a9. Read the comment docs.

@vhirtham
Copy link
Collaborator Author

vhirtham commented Oct 4, 2021

@CagtayFabry Do you still have the script to update the example in the schema?

We should probably add these changes to the 0.5.0 release.

@vhirtham vhirtham marked this pull request as ready for review October 4, 2021 10:49
@vhirtham vhirtham changed the title Spw update Update single-pass weld schema Oct 4, 2021
@CagtayFabry
Copy link
Member

CagtayFabry commented Oct 5, 2021

@CagtayFabry Do you still have the script to update the example in the schema?

We should probably add these changes to the 0.5.0 release.

that was all regex 🚀
the example is the file generated from asdf/cli/welding_schema.py so I think just rebuild and use that

I was wondering why the asdf schema tests pass here but it makes sense because the schema tests don't know about any custom schema file to validate against etc.

and we should wait for this with 0.5.0 for sure :)

@vhirtham
Copy link
Collaborator Author

vhirtham commented Oct 5, 2021

that was all regex 🚀 the example is the file generated from asdf/cli/welding_schema.py so I think just rebuild and use that

okay, I will use this then

I was wondering why the asdf schema tests pass here but it makes sense because the schema tests don't know about any custom schema file to validate against etc.

Was wondering about this too until I realized that custom schema examples are not validated 😄

@CagtayFabry
Copy link
Member

I was wondering why the asdf schema tests pass here but it makes sense because the schema tests don't know about any custom schema file to validate against etc.

Was wondering about this too until I realized that custom schema examples are not validated 😄

I think the examples do get validated ( the second dot of the test output here) but it will only validate the tagged objects in the tree and not the overall schema layout (because the test doesn't know we want to use the file as a custom_schema)

@vhirtham
Copy link
Collaborator Author

vhirtham commented Oct 5, 2021

I was wondering why the asdf schema tests pass here but it makes sense because the schema tests don't know about any custom schema file to validate against etc.

Was wondering about this too until I realized that custom schema examples are not validated 😄

I think the examples do get validated ( the second dot of the test output here) but it will only validate the tagged objects in the tree and not the overall schema layout (because the test doesn't know we want to use the file as a custom_schema)

That's what I meant.

Copy link
Member

@CagtayFabry CagtayFabry left a comment

Choose a reason for hiding this comment

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

🚀 ⭐

@vhirtham vhirtham merged commit 42f3c50 into BAMWelDX:master Oct 6, 2021
@vhirtham vhirtham deleted the spw_update branch October 6, 2021 07:55
@marscher
Copy link
Contributor

marscher commented Oct 8, 2021

Just a reminder, If we change a schema, shouldn't we begin to increase the version number of the schema? Now files created with the old version will just fail to validate against the same version, which is kind of confusing. Just a quick question, is there an ASDF way of upgrading trees according to a schema (like a Converter)?

@CagtayFabry
Copy link
Member

Just a reminder, If we change a schema, shouldn't we begin to increase the version number of the schema? Now files created with the old version will just fail to validate against the same version, which is kind of confusing. Just a quick question, is there an ASDF way of upgrading trees according to a schema (like a Converter)?

yes, if we make schemas we should change the schema name (=increase version numbers)
For 0.5 the version change is included in changing the asdf tags to asdf://

I only consider the released weldx version as 'stable' in the sense that they should work, I expect changes on master between weldx to break things rather often (until the release)

For the file-schema here, if you want to load an 0.4.x file and convert it to 0.5.0 the following should work (load legacy file, change tree, save as new file)

from pathlib import Path

from weldx import WeldxFile
from weldx.asdf.util import get_schema_path

file_schema = get_schema_path("single_pass_weld-1.0.0.schema.yaml") # legacy schema to validate

compat_file = Path("old.weldx") # path to version 0.4 file
new_file = Path("new.weldx") # path to save new 0.5 file
with WeldxFile(
    compat_file,
    mode="r",
    custom_schema=file_schema,
    sync=False,
    asdffile_kwargs={"copy_arrays": True},
) as file_04:
    file_04["welding_current"] = file_04["welding_current"].data # need to change this for new schema
    file_04["welding_voltage"] = file_04["welding_voltage"].data # need to change this for new schema
    file_05 = WeldxFile(tree=file_04, mode="rw", custom_schema="single_pass_weld-0.1.0") # validate against new schema
    if new_file.exists():
        new_file.unlink()
    file_05.write_to(new_file)

if you want to convert a file that was contructed with the current master, the following should work:

  • load the file without validating against the new schema
  • make changes to the tree (s.a.)
      tree["welding_current"] = tree["welding_current"].data # need to change this for new schema
      tree["welding_voltage"] = tree["welding_voltage"].data # need to change this for new schema
  • save to new file (or overwrite old) and use schema validation with current schema again

let me know if it works

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.

3 participants