Skip to content

Commit

Permalink
Asdf setup (#10)
Browse files Browse the repository at this point in the history
asdf:
- add basic file/directory layout for asdf files
  - asdf schemas are located in `weldx/asdf/schemas/weldx.bam.de/weldx`
  - tag implementations are in `weldx/asdf/tags/weldx`
- implement support for pint quantities
- implement support for basic pandas time class
- implement base welding classes from AWS/NIST "A Welding Data Dictionary"
- add and implement ISO groove types (DIN EN ISO 9692-1:2013)
- add basic jinja templates and functions for adding simple dataclass objects
- setup package to include and install ASDF extensions and schemas (see setup.py, MANIFEST.in)
- add basic tests for writing/reading all ASDF classes (these only run code without any real checks!)

module:
- add and populate `__init__.py` files
- add setup.py package configuration for install
  - required packages
  - package metadata
  - asdf extension entry points
  - version support
- update pandas, scipy, xarray and pint minimum versions (in conda env and setup.py)
- add versioneer
- update options in setup.cfg
- update tool configurations
  - ignore `asdf`-module in deepsource run

CI:
- add local conda build workflow (no artifacts so far, testing only)
- add asdf schema test workflow with local package install (schemas are excluded from default pytest run)
- add debug isort workflow (can be used to check files that would be sorted, we can activate isort test with new options in release 5.0)
  • Loading branch information
CagtayFabry authored Apr 30, 2020
1 parent 329f8e3 commit e0e0cf3
Show file tree
Hide file tree
Showing 74 changed files with 7,835 additions and 11 deletions.
3 changes: 3 additions & 0 deletions .codacy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,6 @@ engines:
exclude_paths:
- 'docs/**'
- '.vulture_whitelist.py'
- 'versioneer.py'
- 'weldx/_version.py'
- 'scripts/**'
5 changes: 4 additions & 1 deletion .deepsource.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ test_patterns = [

exclude_patterns = [
"docs/**",
".vulture_whitelist.py"
".vulture_whitelist.py",
"versioneer.py",
"weldx/_version.py",
"weldx/asdf/**"
]

[[analyzers]]
Expand Down
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
weldx/_version.py export-subst
24 changes: 24 additions & 0 deletions .github/workflows/conda_build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: conda build
on: [push]

jobs:
test:
name: conda build (local)
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-18.04]
steps:
- uses: actions/checkout@v1
- name: Include $CONDA in $PATH
run: echo ::add-path::$CONDA/bin
- name: Add conda-forge & print conda info
run: |
conda config --append channels conda-forge
conda info -a
- name: Create conda build environment
run: conda env create -f ./conda.recipe/build_env.yml
- name: Build from local conda recipe
run: |
source activate build_env
conda build .
45 changes: 45 additions & 0 deletions .github/workflows/pytest_asdf.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: pytest asdf
on: [push]

jobs:
# pytest:
# name: pytest asdf
# runs-on: ${{ matrix.os }}
# strategy:
# matrix:
# os: [ubuntu-18.04]
# steps:
# - uses: actions/checkout@v1
# - name: Include $CONDA in $PATH
# run: echo ::add-path::$CONDA/bin
# - name: Print conda info
# run: conda info -a
# - name: Create conda environment
# run: conda env create -f ./environment.yml
# - name: Conda develop install of source package for ASDF Schema links
# run: |
# conda install conda-build -n weldx
# - name: Run tests with added asdf schema file location
# run: |
# source activate weldx
# python setup.py install --user
# pytest --asdf-tests --ignore=tests/
pytest:
name: pytest asdf
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-18.04]
py: [ '3.7', '3.8' ]
steps:
- uses: actions/checkout@v1
- uses: actions/setup-python@v1
with:
python-version: ${{ matrix.py }}
- name: pip installs
run: |
pip install pytest pytest-cov
pip install .
- name: run pytest
run: |
pytest --asdf-tests --ignore=tests/
24 changes: 23 additions & 1 deletion .github/workflows/static_analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,28 @@ jobs:
run: |
flake8
isort:
name: isort
runs-on: ${{ matrix.os }}
continue-on-error: true
strategy:
matrix:
os: [ubuntu-18.04]
py: [ '3.7', '3.8' ]
steps:
- uses: actions/checkout@v1
- uses: actions/setup-python@v1
with:
python-version: ${{ matrix.py }}
- name: pip installs
run: pip install git+https://github.com/timothycrosley/isort.git
- name: show isort diff
run: |
isort ./weldx --diff
- name: run isort
run: |
isort ./weldx --check-only
vulture:
name: vulture
runs-on: ${{ matrix.os }}
Expand All @@ -57,4 +79,4 @@ jobs:
run: pip install vulture==1.4
- name: run vulture
run: |
vulture .
vulture . --exclude weldx/asdf/,versioneer.py,weldx/_version.py
23 changes: 23 additions & 0 deletions .typo-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,32 @@ excluded_files:
- "docs*"
- "environment.yml"
- "tools*"
- "versioneer.py"
- "weldx/_version.py"

excluded_words:
- typoci
# python packages -----------------------------
- asdf
- numpy
- pandas
- xarray
- scipy
- pytest
- pydocstyle
- matplotlib
- versioneer
- isort
- networkx
# matplotlib ----------------------------------
- pyplot
- gca
- plt
# flake8 --------------------------------------
- noqa
- addopts
# asdf ----------------------------------------
- yamlutil
# numpy ---------------------------------------
- arange
- allclose
Expand All @@ -41,14 +49,21 @@ excluded_words:
- vstack
# pandas / xarray -----------------------------
- bfill
- ffill
- idxmax
- idxmin
- isel
- iloc
- isin
- isnan
- ffill
- fillna
- sel
- dtypes
- timedelta
- timedeltaindex
- datetimeindex
- isoformat
# jupyter notebooks ---------------------------
- jupyter
- nbformat
Expand All @@ -58,6 +73,11 @@ excluded_words:
- ipython
# scipy ---------------------------------------
- Slerp
# welding -------------------------------------
- weldment
# conda ---------------------------------------
- conda
- noarch
# other ---------------------------------------
- addopts
- csm
Expand All @@ -67,4 +87,7 @@ excluded_words:
- interp
- isort
- linearization
- ureg
- Cagtay
- Fabry
- xyz
3 changes: 3 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
recursive-include weldx/asdf/schemas *.yaml
include versioneer.py
include weldx/_version.py
8 changes: 8 additions & 0 deletions conda.recipe/build_env.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
name: build_env
channels:
- defaults
dependencies:
- python=3.7
- setuptools
- conda-build
- conda-verify
32 changes: 32 additions & 0 deletions conda.recipe/meta.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{% set data = load_setup_py_data() %}

package:
name: weldx
version: {{ data['version'] }}

source:
path: ..

build:
script: python setup.py install --single-version-externally-managed --record=record.txt
number: 0
noarch: python

requirements:
build:
- python
- setuptools
run:
- python
# dependencies are defined in setup.py
{% for dep in data['install_requires'] %}
- {{ dep.lower() }}
{% endfor %}

test:
imports:
- weldx

about:
home: www.bam.de/weldx
license: BSD
9 changes: 5 additions & 4 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,16 @@ channels:
dependencies:
- python=3.7
- numpy>=1.18
- pandas>=0.25
- scipy
- xarray
- pint
- pandas>=1.0
- scipy>=1.4
- xarray>=0.15
- pint>=0.11
- bottleneck
- asdf=2.5.1
- sphinx
- recommonmark
- openpyxl
- jinja2
# graph packages
- networkx
# Code quality
Expand Down
Empty file added scripts/__init__.py
Empty file.
94 changes: 94 additions & 0 deletions scripts/aws_run.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
"""Run the AWS Data Dictionary debug example."""

import asdf
import pprint

from weldx.constants import WELDX_QUANTITY as Q_

from weldx.asdf.extension import WeldxExtension, WeldxAsdfExtension

# welding process -----------------------------------------------------------------
from weldx.asdf.tags.weldx.aws.process.gas_component import GasComponent
from weldx.asdf.tags.weldx.aws.process.shielding_gas_type import ShieldingGasType
from weldx.asdf.tags.weldx.aws.process.shielding_gas_for_procedure import (
ShieldingGasForProcedure,
)
from weldx.asdf.tags.weldx.aws.process.arc_welding_process import ArcWeldingProcess

# weld design -----------------------------------------------------------------
from weldx.asdf.tags.weldx.aws.design.joint_penetration import JointPenetration
from weldx.asdf.tags.weldx.aws.design.weld_details import WeldDetails
from weldx.asdf.tags.weldx.aws.design.connection import Connection
from weldx.asdf.tags.weldx.aws.design.workpiece import Workpiece
from weldx.asdf.tags.weldx.aws.design.sub_assembly import SubAssembly
from weldx.asdf.tags.weldx.aws.design.weldment import Weldment
from weldx.asdf.tags.weldx.aws.design.base_metal import BaseMetal
from weldx.asdf.tags.weldx.core.iso_groove import get_groove


# welding process -----------------------------------------------------------------
gas_comp = [
GasComponent("argon", Q_(82, "percent")),
GasComponent("carbon dioxide", Q_(18, "percent")),
]
gas_type = ShieldingGasType(gas_component=gas_comp, common_name="SG")

gas_for_procedure = ShieldingGasForProcedure(
use_torch_shielding_gas=True,
torch_shielding_gas=gas_type,
torch_shielding_gas_flowrate=Q_(20, "l / min"),
)

arc_welding_process = ArcWeldingProcess("GMAW")
process = {
"arc_welding_process": arc_welding_process,
"shielding_gas": gas_for_procedure,
}

# weld design -----------------------------------------------------------------
v_groove = get_groove(
groove_type="VGroove",
workpiece_thickness=Q_(9, "mm"),
groove_angle=Q_(50, "deg"),
root_face=Q_(4, "mm"),
root_gap=Q_(2, "mm"),
)

joint_penetration = JointPenetration(
complete_or_partial="completePenetration", root_penetration=Q_(1.0, "mm")
)
weld_details = WeldDetails(
joint_design=v_groove, weld_sizes=Q_(320, "mm"), number_of_passes=1
)
connection = Connection(
joint_type="butt_joint",
weld_type="singleVGroove",
joint_penetration=joint_penetration,
weld_details=weld_details,
)
workpieces = [Workpiece(geometry="V-Groove")]
sub_assembly = [SubAssembly(workpiece=workpieces, connection=connection)]

weldment = Weldment(sub_assembly)

base_metal = BaseMetal("steel", "plate", Q_(10.3, "mm"))

filename = "aws_demo.yaml"
tree = dict(process=process, weldment=weldment, base_metal=base_metal)

# Write the data to a new file
with asdf.AsdfFile(
tree,
extensions=[WeldxExtension(), WeldxAsdfExtension()],
ignore_version_mismatch=False,
) as ff:
ff.write_to(filename, all_array_storage="inline")

# read back data from ASDF file
with asdf.open(
filename, copy_arrays=True, extensions=[WeldxExtension(), WeldxAsdfExtension()]
) as af:
data = af.tree
pprint.pprint(data["process"])
pprint.pprint(data["weldment"].__dict__)
pprint.pprint(data["base_metal"].__dict__)
Loading

0 comments on commit e0e0cf3

Please sign in to comment.