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

Add weldx file wrapper #341

Merged
merged 70 commits into from
May 4, 2021
Merged
Show file tree
Hide file tree
Changes from 56 commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
c6b7ac1
initial import weldx file and test
marscher Apr 16, 2021
041b525
import lift in base
marscher Apr 16, 2021
b004da4
fix some tests, added sync (wrapper for update) to avoid conflict wit…
marscher Apr 16, 2021
a00d058
added tests, some features
marscher Apr 19, 2021
0d9c1f0
case for readonly files
marscher Apr 19, 2021
014313b
skip read_only test due to asdf bug.
marscher Apr 20, 2021
8f86a42
refactor custom schema
marscher Apr 20, 2021
9328787
use new parse option for get_yaml_header
marscher Apr 20, 2021
80ea737
made file arg optional (use bytebuffer as default)
marscher Apr 20, 2021
529187d
work on files
marscher Apr 20, 2021
2b04719
added more tests, added error handling
marscher Apr 22, 2021
19ad612
fix history test
marscher Apr 22, 2021
0dd801e
minor
marscher Apr 23, 2021
977b88c
fix invalid file type error msg
marscher Apr 23, 2021
cbfcc12
amend changelog
marscher Apr 23, 2021
0eb690a
types module including file-like types
marscher Apr 27, 2021
db4436d
use types_path_and_file_like
marscher Apr 27, 2021
4723865
fix custom schema
marscher Apr 27, 2021
b0aa836
use WeldxFile in custom_metadata.ipynb
marscher Apr 27, 2021
0279a4d
use WeldxFile in GMAW_process.ipynb
marscher Apr 27, 2021
60ff52a
use WeldxFile in GMAW_process.ipynb
marscher Apr 27, 2021
2bc2aa7
use write_args from ctor in write_to
marscher Apr 27, 2021
0b01e04
use WeldxFile in more notebooks
marscher Apr 27, 2021
2d54b13
clear output
marscher Apr 27, 2021
52b6b2d
fix jupyter json repr
marscher Apr 28, 2021
186dd0d
minor
marscher Apr 26, 2021
2e4408a
linting fun
marscher Apr 29, 2021
df1ffb9
pydocstyle
marscher Apr 29, 2021
aade856
pydocstyle
marscher Apr 29, 2021
bceb629
Merge remote-tracking branch 'origin/master' into add_weldx_file_wrapper
marscher Apr 29, 2021
5cc45f2
[pytest] enable doctests
marscher Apr 29, 2021
ba8ea46
[pydocstyle] use numpy convention
marscher Apr 29, 2021
4b77ebc
more docstrings
marscher Apr 29, 2021
9aa019e
add is_interactive_session
marscher Apr 29, 2021
e00f964
fix docstest failure
marscher Apr 29, 2021
37f604d
[pytest] do not try to collect tests from doc dir
marscher Apr 29, 2021
56e15c8
linting hell
marscher Apr 29, 2021
e49ccf2
fix buffer created with read-only
marscher Apr 29, 2021
c68376d
workaround for type deduction in sphinx.
marscher Apr 29, 2021
1b3d6a4
sync files prior showing header, cpy to tmp buff, if not (displaying …
marscher Apr 29, 2021
d027437
fix is_interactive_session
marscher Apr 29, 2021
96bde9e
three possibilites to visualize (plain str, syntax highlighted yaml, …
marscher Apr 29, 2021
5f17897
fix doctest: windows creates 32bit ints
marscher Apr 30, 2021
ade9fb6
linting, static
marscher Apr 30, 2021
047cf4e
docstrings, all variable
marscher Apr 30, 2021
48aa286
f
marscher Apr 30, 2021
d505784
ignore unresolved type annotation as it would require importing ipython
marscher Apr 30, 2021
6bee1b6
[gha/static_analysis] unpin pydocstyle
marscher Apr 30, 2021
53116b3
file-types, proper deprecation
marscher Apr 30, 2021
71273eb
remove metadata
marscher Apr 30, 2021
1e582fe
clear output
marscher Apr 30, 2021
376727c
fix docstyle
marscher Apr 30, 2021
487056a
Merge branch 'master' into add_weldx_file_wrapper
marscher May 3, 2021
36ac901
properly ignore missing docstrings in test
marscher May 3, 2021
5f5e103
fix import
marscher May 3, 2021
6331c8f
added types to api docs
marscher May 3, 2021
624705b
Update weldx/asdf/file.py
marscher May 4, 2021
ccc8f29
Update weldx/asdf/file.py
marscher May 4, 2021
6d36b7c
Update weldx/asdf/file.py
marscher May 4, 2021
b6f1b37
Update weldx/asdf/file.py
marscher May 4, 2021
f692b6c
simplify test
marscher May 3, 2021
3a33818
fix instance check
marscher May 3, 2021
df93ff4
fix instance check
marscher May 3, 2021
fc70747
minor [ci skip]
marscher May 4, 2021
1fc94ee
validate software entries
marscher May 4, 2021
eeaf6ee
clean up
marscher May 4, 2021
a381566
fix docstr, imports
marscher May 4, 2021
f1e2543
small comment on private function. [ci skip]
marscher May 4, 2021
1b7f85f
disable interactive widgets
marscher May 4, 2021
dbe3b62
be clear on returned type
marscher May 4, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/static_analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
with:
python-version: ${{ matrix.py }}
- name: pip installs
run: pip install pydocstyle==5.*
run: pip install pydocstyle
- name: run pydocstyle
run: |
pydocstyle
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
- added `asdf.util.get_schema_path` helper function [[#325]](https://github.com/BAMWelDX/weldx/pull/325)
- added `util.compare_nested` to check equality of two nested data
structures. [[#328]](https://github.com/BAMWelDX/weldx/pull/328)
- added `WeldxFile` wrapper to handle asdf files with
history and schemas more easily. [[#341]](https://github.com/BAMWelDX/weldx/pull/341).

### changes

Expand Down
1 change: 1 addition & 0 deletions doc/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ API
weldx.measurement
weldx.transformations
weldx.util
weldx.types
weldx.visualization
weldx.welding

Expand Down
4 changes: 3 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ install_requires =
ipywidgets
k3d
meshio
attrdict

include_package_data = True

Expand Down Expand Up @@ -89,9 +90,10 @@ exclude =
doc/conf.py,

[pydocstyle]
# convention numpy is currently equivalent to ignoring 'D107', 'D203', 'D212', 'D213', 'D402', 'D413'
convention = numpy
match = (?!__)(?!_version)(?!conftest).*\.py
match_dir = [^\.][^\docs].*
ignore = D203,D213

[tool:pytest]
addopts = --tb=short --color=yes -rs --cov=weldx --cov-report=term-missing:skip-covered --doctest-modules
Expand Down
20 changes: 6 additions & 14 deletions tutorials/GMAW_process.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,8 @@
"metadata": {},
"outputs": [],
"source": [
"import asdf\n",
"import weldx\n",
"from weldx import Q_\n",
"from weldx.asdf.extension import WeldxAsdfExtension, WeldxExtension\n",
"from weldx.core import TimeSeries as TS\n",
"from weldx.welding.processes import GmawProcess"
]
Expand Down Expand Up @@ -118,7 +116,10 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## using ASDF"
"## using ASDF\n",
"We write the dictionary containing our structured data to an ASDF file using the WeldxFile\n",
"class. We pass the tree as a named keyword argument.\n",
"The tree will be serialized to ASDF in memory, and we can have a look at the ASDF header."
]
},
{
Expand All @@ -136,17 +137,8 @@
"metadata": {},
"outputs": [],
"source": [
"buffer = weldx.asdf.util._write_buffer(tree)\n",
"weldx.asdf.util.notebook_fileprinter(buffer)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"data = weldx.asdf.util._read_buffer(buffer)"
"file = weldx.WeldxFile(tree=tree)\n",
"file.show_asdf_header()"
]
},
{
Expand Down
13 changes: 6 additions & 7 deletions tutorials/custom_metadata.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Now let's look at the ASDF file contents with our metadata:"
"Now let's look at the ASDF file contents with our metadata. We will find our data\n",
"at the very end after the ASDF header."
]
},
{
Expand All @@ -66,10 +67,9 @@
"metadata": {},
"outputs": [],
"source": [
"from weldx.asdf.util import _write_buffer, notebook_fileprinter\n",
"\n",
"buffer = _write_buffer({\"sensor\": HKS_sensor})\n",
"notebook_fileprinter(buffer)"
"from weldx import WeldxFile\n",
"file = WeldxFile(tree={\"sensor\": HKS_sensor})\n",
"file.show_asdf_header()"
]
},
{
Expand All @@ -92,9 +92,8 @@
"metadata": {},
"outputs": [],
"source": [
"from weldx.asdf.util import _read_buffer\n",
"data = WeldxFile(file.write_to())\n",
"\n",
"data = _read_buffer(buffer)\n",
"display(data[\"sensor\"].wx_metadata)\n",
"display(data[\"sensor\"].wx_user)"
]
Expand Down
2 changes: 1 addition & 1 deletion tutorials/geometry_02_geometry.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.2"
"version": "3.8.8"
}
},
"nbformat": 4,
Expand Down
30 changes: 15 additions & 15 deletions tutorials/groove_types_01.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -189,9 +189,10 @@
"source": [
"## using ASDF\n",
"\n",
"All groove types can be save to _ASDF_-files with the included schemas and _ASDF_-extension from the weldx-package.\n",
"\n",
"Writing the asdf file into a buffer:"
"All groove types can be saved to _ASDF_-files with the included schemas and _ASDF_-extension from the weldx-package.\n",
"Note that these schemas and extensions are being handled automatically and you do not have\n",
"to worry about these.\n",
"Here we demonstrate the writing of the groove data into a buffer (in-memory file):"
]
},
{
Expand All @@ -201,7 +202,7 @@
"outputs": [],
"source": [
"tree = dict(test_v_groove=v_groove)\n",
"buffer = weldx.asdf.util._write_buffer(tree)"
"file = weldx.WeldxFile(tree=tree)"
]
},
{
Expand All @@ -217,14 +218,15 @@
"metadata": {},
"outputs": [],
"source": [
"weldx.asdf.util.notebook_fileprinter(buffer)"
"file.show_asdf_header()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Reading the file contents again and validating the extracted groove:"
"Now we are taking a copy of the first file by calling `WeldxFile.write_to`.\n",
"Then we read the file contents again and validating the extracted groove:"
]
},
{
Expand All @@ -233,7 +235,8 @@
"metadata": {},
"outputs": [],
"source": [
"data = weldx.asdf.util._read_buffer(buffer)\n",
"file_copy = file.write_to()\n",
"data = weldx.WeldxFile(file_copy)\n",
"data[\"test_v_groove\"]"
]
},
Expand All @@ -249,7 +252,11 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [],
"source": [
"# generate test grooves\n",
Expand All @@ -262,13 +269,6 @@
"for k, v in groove_dict.items():\n",
" v[0].plot(line_style=\"-\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand Down
19 changes: 7 additions & 12 deletions tutorials/measurement_example.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -460,25 +460,20 @@
" # \"data_sources\": sources,\n",
" # \"data_processors\": processors,\n",
"}\n",
"buffer = weldx.asdf.util._write_buffer(tree)"
"file = weldx.WeldxFile(tree=tree)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"weldx.asdf.util.notebook_fileprinter(buffer)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [],
"source": [
"data = weldx.asdf.util._read_buffer(buffer)"
"file.show_asdf_header()"
]
}
],
Expand Down
7 changes: 4 additions & 3 deletions tutorials/welding_example_01_basics.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,8 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## using ASDF"
"## using ASDF\n",
"Now we write all of our structured data to an ASDF file and have a look at the ASDF header."
]
},
{
Expand All @@ -562,7 +563,7 @@
"metadata": {},
"outputs": [],
"source": [
"buffer = weldx.asdf.util._write_buffer(tree)"
"file = weldx.WeldxFile(tree=tree)"
]
},
{
Expand All @@ -571,7 +572,7 @@
"metadata": {},
"outputs": [],
"source": [
"weldx.asdf.util.notebook_fileprinter(buffer)"
"file.show_asdf_header()"
]
}
],
Expand Down
2 changes: 2 additions & 0 deletions weldx/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

# asdf extensions and tags
import weldx.asdf
from weldx.asdf.file import WeldxFile

# class imports to weldx namespace
from weldx.constants import WELDX_QUANTITY as Q_
Expand Down Expand Up @@ -55,6 +56,7 @@
"Shape",
"SpatialData",
"Trace",
"WeldxFile",
"asdf",
"core",
"geometry",
Expand Down
Loading