mastapy-cli-regression 0.1.0b1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- mastapy_cli_regression-0.1.0b1/.hgignore +124 -0
- mastapy_cli_regression-0.1.0b1/PKG-INFO +213 -0
- mastapy_cli_regression-0.1.0b1/README.md +181 -0
- mastapy_cli_regression-0.1.0b1/mastapy_cli_regression/__init__.py +29 -0
- mastapy_cli_regression-0.1.0b1/mastapy_cli_regression/common/__init__.py +1 -0
- mastapy_cli_regression-0.1.0b1/mastapy_cli_regression/common/api.py +303 -0
- mastapy_cli_regression-0.1.0b1/mastapy_cli_regression/common/cli.py +363 -0
- mastapy_cli_regression-0.1.0b1/mastapy_cli_regression/common/errors.py +13 -0
- mastapy_cli_regression-0.1.0b1/mastapy_cli_regression/common/explorer.py +31 -0
- mastapy_cli_regression-0.1.0b1/mastapy_cli_regression/common/image.py +69 -0
- mastapy_cli_regression-0.1.0b1/mastapy_cli_regression/common/json.py +104 -0
- mastapy_cli_regression-0.1.0b1/mastapy_cli_regression/common/print.py +25 -0
- mastapy_cli_regression-0.1.0b1/mastapy_cli_regression/common/types.py +9 -0
- mastapy_cli_regression-0.1.0b1/mastapy_cli_regression/common/version.py +12 -0
- mastapy_cli_regression-0.1.0b1/mastapy_cli_regression/comparing/__init__.py +1 -0
- mastapy_cli_regression-0.1.0b1/mastapy_cli_regression/comparing/comparer.py +423 -0
- mastapy_cli_regression-0.1.0b1/mastapy_cli_regression/legacy/README.txt +8 -0
- mastapy_cli_regression-0.1.0b1/mastapy_cli_regression/legacy/mastapy_bootstrapper.py +169 -0
- mastapy_cli_regression-0.1.0b1/mastapy_cli_regression/legacy/mastapy_shim/__init__.py +283 -0
- mastapy_cli_regression-0.1.0b1/mastapy_cli_regression/legacy/mastapy_shim/_lib/__init__.py +1 -0
- mastapy_cli_regression-0.1.0b1/mastapy_cli_regression/legacy/mastapy_shim/_lib/net462/ClrLoader.dll +0 -0
- mastapy_cli_regression-0.1.0b1/mastapy_cli_regression/legacy/mastapy_shim/_lib/net462/ClrLoader.dll.config +12 -0
- mastapy_cli_regression-0.1.0b1/mastapy_cli_regression/legacy/mastapy_shim/_lib/net462/PolyfillsForOldDotNet.System.Runtime.InteropServices.RuntimeInformation.dll +0 -0
- mastapy_cli_regression-0.1.0b1/mastapy_cli_regression/legacy/mastapy_shim/_lib/net462/Python.Runtime.dll +0 -0
- mastapy_cli_regression-0.1.0b1/mastapy_cli_regression/legacy/mastapy_shim/_lib/net462/Python.Runtime.dll.config +22 -0
- mastapy_cli_regression-0.1.0b1/mastapy_cli_regression/legacy/mastapy_shim/_lib/net462/System.ValueTuple.dll +0 -0
- mastapy_cli_regression-0.1.0b1/mastapy_cli_regression/legacy/mastapy_shim/_lib/net462/__init__.py +1 -0
- mastapy_cli_regression-0.1.0b1/mastapy_cli_regression/legacy/mastapy_shim/_polyfill/__init__.py +1 -0
- mastapy_cli_regression-0.1.0b1/mastapy_cli_regression/legacy/mastapy_shim/_polyfill/clr.py +35 -0
- mastapy_cli_regression-0.1.0b1/mastapy_cli_regression/legacy/mastapy_shim/_polyfill/pythonnet.py +198 -0
- mastapy_cli_regression-0.1.0b1/mastapy_cli_regression/legacy/mastapy_shim/licences.py +197 -0
- mastapy_cli_regression-0.1.0b1/mastapy_cli_regression/legacy/mastapy_shim/python_net.py +110 -0
- mastapy_cli_regression-0.1.0b1/mastapy_cli_regression/processing/__init__.py +1 -0
- mastapy_cli_regression-0.1.0b1/mastapy_cli_regression/processing/dependencies.py +89 -0
- mastapy_cli_regression-0.1.0b1/mastapy_cli_regression/processing/results.py +446 -0
- mastapy_cli_regression-0.1.0b1/mastapy_cli_regression/processing/runner.py +938 -0
- mastapy_cli_regression-0.1.0b1/mastapy_cli_regression.pth +2 -0
- mastapy_cli_regression-0.1.0b1/pyproject.toml +69 -0
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
# use glob syntax
|
|
2
|
+
syntax: glob
|
|
3
|
+
|
|
4
|
+
*.obj
|
|
5
|
+
*.pdb
|
|
6
|
+
*.user
|
|
7
|
+
obj/
|
|
8
|
+
[Pp]ackages/[0-9a-zA-Z]*/**
|
|
9
|
+
Build Output*/**
|
|
10
|
+
VSBuildObjects/**
|
|
11
|
+
*.suo
|
|
12
|
+
TestResult.xml
|
|
13
|
+
*.bak
|
|
14
|
+
*.orig
|
|
15
|
+
TestResults/**
|
|
16
|
+
Tests/* TeamCity Artifacts/**/**
|
|
17
|
+
*.tmp
|
|
18
|
+
MastaRelease/CDImageSource*/**
|
|
19
|
+
MastaRelease/Installer*/**
|
|
20
|
+
MastaRelease/MastaSuite*/**
|
|
21
|
+
MastaRelease/ReleaseBuild/**
|
|
22
|
+
MastaRelease/SuiteOutput*/**
|
|
23
|
+
MastaRelease/*.log
|
|
24
|
+
MastaRelease/*.mds
|
|
25
|
+
MastaRelease/*.mdf
|
|
26
|
+
MastaRelease/Help/MASTA/CHM/**/*.*
|
|
27
|
+
HaspHelper/Extracted/**
|
|
28
|
+
.vs/**
|
|
29
|
+
.venv/**
|
|
30
|
+
.nox/**
|
|
31
|
+
.pytest_cache/**
|
|
32
|
+
.ruff_cache/**
|
|
33
|
+
__pycache__/**
|
|
34
|
+
_build/**
|
|
35
|
+
_rst/**
|
|
36
|
+
stubs.min/**
|
|
37
|
+
_ReSharperPlatform*/**
|
|
38
|
+
TestFileResources/MAARegression/Reports/*/*.*
|
|
39
|
+
TestFileResources/MAARegression/Results/Changed/*.*
|
|
40
|
+
*.vspx
|
|
41
|
+
*.psess
|
|
42
|
+
*.tmp_proj
|
|
43
|
+
_ReSharper.Caches/*
|
|
44
|
+
*.vsp
|
|
45
|
+
MastaRelease/CD Template/Installs/**
|
|
46
|
+
Utility/Translation/LanguageDatabase_log.ldf
|
|
47
|
+
Utility/Translation/LanguageDatabase.mdf
|
|
48
|
+
MastaAPI/MastaAPI/**
|
|
49
|
+
MastaAPI/MastaAPI.Core/**
|
|
50
|
+
MastaAPI/documentation/_site/**
|
|
51
|
+
MastaAPI/Versioning.generated.cs
|
|
52
|
+
ScriptedMastaToolsCode/bin/**
|
|
53
|
+
StarterConsoleAppCode/bin/*
|
|
54
|
+
ExampleConsoleAppCode/bin/*
|
|
55
|
+
BearingCalculationApiCode/bin/*
|
|
56
|
+
BearingCatalogApiCode/bin/*
|
|
57
|
+
BearingWebsite/bin/*
|
|
58
|
+
BearingWebsiteCore/bin/*
|
|
59
|
+
PreparedApiProjects/*
|
|
60
|
+
MastaAPI/pythonStubs/stubsGen/logs
|
|
61
|
+
MastaAPI/PythonAPI/.workers/**
|
|
62
|
+
MastaAPI/PythonAPI/results/**
|
|
63
|
+
MastaAPI/PythonAPI/SMT/**
|
|
64
|
+
MastaAPI/PythonAPI/mastapy/**
|
|
65
|
+
MastaAPI/PythonAPI/mastapy.egg-info/**
|
|
66
|
+
MastaAPI/PythonAPI/lib/mastapy-cli-regression/mastapy_cli_regression/legacy/mastapy_shim/_lib/**
|
|
67
|
+
MastaAPI/PythonAPI/build/**
|
|
68
|
+
MastaAPI/PythonAPI/dist/**
|
|
69
|
+
MastaAPI/PythonAPI/src/mastapy/**
|
|
70
|
+
MastaAPI/PythonAPI/src/last_updated.json
|
|
71
|
+
MastaAPI/PythonAPI/tests/Results/**
|
|
72
|
+
MastaAPI/PythonAPI/tests/requirements-test.txt
|
|
73
|
+
MastaAPI/PythonAPI/tests/requirements-test-mastapy.txt
|
|
74
|
+
MastaAPI/PythonAPI/tests/requirements-workspace.txt
|
|
75
|
+
MastaAPI/PythonAPI/tests/.pip-audit_cache
|
|
76
|
+
MastaAPI/PythonAPI/sandbox.py
|
|
77
|
+
MastaAPI/PythonAPI/keyfile.json
|
|
78
|
+
mastafile.py
|
|
79
|
+
SMTStoreSolutions/Store/**
|
|
80
|
+
MastaAPI/pythonpackage/dist/*
|
|
81
|
+
MastaAPI/pythonpackage/build/*
|
|
82
|
+
SMTStoreSolutions/*/bin/*
|
|
83
|
+
SMTStoreSolutions/ReferenceTorqueCalculator/ReferenceTorqueCalculator/bin/
|
|
84
|
+
MastaAPI/documentation/template/styles/package-lock.json
|
|
85
|
+
MAAResources/MastaFiles/Analyses/Bevel LTCA/Spiral Bevel LTCA.Masta
|
|
86
|
+
MAAResources/MastaFiles/Analyses/LTCA/Internal Pair.Masta
|
|
87
|
+
MAAResources/MastaFiles/Analyses/LTCA/Marine Gear Set.Masta
|
|
88
|
+
MAAResources/MastaFiles/Analyses/LTCA/Truck With Stresses.Masta
|
|
89
|
+
TestFileResources/MAA/MastaFiles/AGMA different tolerance recommended.Masta
|
|
90
|
+
TestFileResources/MAA/MastaFiles/AGMA same tolerance recommended.Masta
|
|
91
|
+
TestFileResources/MAA/MastaFiles/AGMA tolerance recommended material fail.Masta
|
|
92
|
+
TestFileResources/MAA/MastaFiles/DIN same tolerance recommended.Masta
|
|
93
|
+
TestFileResources/MAA/MastaFiles/ISO different tolerance recommended.Masta
|
|
94
|
+
TestFileResources/MAA/MastaFiles/ISO same tolerance recommended.Masta
|
|
95
|
+
TestFileResources/MAA/MastaFiles/ISO tolerance recommended material fail.Masta
|
|
96
|
+
TestFileResources/MAARegression/Designs/Ignore/simple FE helix gear pair.M*
|
|
97
|
+
*/.idea/workspace.xml
|
|
98
|
+
*/.idea/projectSettingsUpdater.xml
|
|
99
|
+
.idea/config/applicationhost.config
|
|
100
|
+
Core/BuildOutput/**/*
|
|
101
|
+
.git/*
|
|
102
|
+
.gitattributes
|
|
103
|
+
.gitignore
|
|
104
|
+
.yarn/*
|
|
105
|
+
node_modules/*
|
|
106
|
+
.yarnrc.yml
|
|
107
|
+
.pnp.*
|
|
108
|
+
*.nupkg
|
|
109
|
+
# Default ignored files
|
|
110
|
+
MastaAPITests/LatestReferenceFile
|
|
111
|
+
MastaInstallationBuilder/GeometryModellerInstaller/**.msi
|
|
112
|
+
MastaInstallationBuilder/GeometryModellerInstaller/**.exe
|
|
113
|
+
MastaInstallationBuilder/GeometryModellerInstaller/**.dll
|
|
114
|
+
MastaInstallationBuilder/GeometryModellerInstaller/*.cab
|
|
115
|
+
MastaInstallationBuilder/GeometryModellerInstaller/Geometry Modeller (modified)-cache/**.*
|
|
116
|
+
MastaInstallationBuilder/GeometryModellerInstaller/GeometryModeller.MSIUpdate*/*.*
|
|
117
|
+
msbuild.log
|
|
118
|
+
MastaRelease/BuildNumberGenerator/bin/**/**
|
|
119
|
+
*_*_*tmp.csproj
|
|
120
|
+
*.Untracked.props
|
|
121
|
+
MastaInstallationBuilder/GraphApiInterop/bin/**/**
|
|
122
|
+
SMTNodeProjects/HTMLScripts/src/*.js
|
|
123
|
+
**/.idea/icon.svg
|
|
124
|
+
**/.idea/**/copilot.data.migration*
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: mastapy-cli-regression
|
|
3
|
+
Version: 0.1.0b1
|
|
4
|
+
Summary: Command-line tool for running a single mastapy script in multiple APIs and comparing results.
|
|
5
|
+
Author-email: George Baron <george.baron@smartmt.com>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Keywords: masta,mastapy,plugin,regression,smt
|
|
8
|
+
Classifier: Development Status :: 4 - Beta
|
|
9
|
+
Classifier: Environment :: Plugins
|
|
10
|
+
Classifier: Intended Audience :: Developers
|
|
11
|
+
Classifier: Intended Audience :: Science/Research
|
|
12
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
13
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
21
|
+
Requires-Python: >=3.10
|
|
22
|
+
Requires-Dist: beartype>=0.22.6
|
|
23
|
+
Requires-Dist: numpy>=1.22.0; python_version >= '3.9' and python_version < '3.12'
|
|
24
|
+
Requires-Dist: numpy>=1.26.0; python_version >= '3.12'
|
|
25
|
+
Requires-Dist: packaging>=25.0
|
|
26
|
+
Requires-Dist: polars>=1.36.1
|
|
27
|
+
Requires-Dist: rich-argparse>=1.7.2
|
|
28
|
+
Requires-Dist: rich>=14.2.0
|
|
29
|
+
Requires-Dist: seaborn>=0.13.2
|
|
30
|
+
Requires-Dist: xlsxwriter>=3.2.9
|
|
31
|
+
Description-Content-Type: text/markdown
|
|
32
|
+
|
|
33
|
+
<h1 align="center">
|
|
34
|
+
<img src="https://documentation.smartmt.com/MastaAPI/15.1.1/images/smt_logo.png" width="150" alt="SMT">
|
|
35
|
+
</h1><br>
|
|
36
|
+
|
|
37
|
+
[](https://github.com/astral-sh/uv) [](https://github.com/astral-sh/ruff) [](https://opensource.org/licenses/MIT) 
|
|
38
|
+
|
|
39
|
+
`mastapy-cli-regression` is a command-line plugin for [mastapy](https://pypi.org/project/mastapy/).
|
|
40
|
+
|
|
41
|
+
- **Website**: https://www.smartmt.com/
|
|
42
|
+
- **Support**: https://support.smartmt.com/
|
|
43
|
+
|
|
44
|
+

|
|
45
|
+
|
|
46
|
+
To install this plugin, run the following:
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
pip install mastapy[cli-regression]
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
This plugin is designed to be used on the command-line via the [mastapy](https://pypi.org/project/mastapy/) package using the following syntax:
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
python -m mastapy regression ...
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### Features
|
|
59
|
+
|
|
60
|
+
- Compare results between different versions of the MASTA API and automatically identify regressions.
|
|
61
|
+
- Completely automated and parallelized virtual environment creation, installation and script execution for each specified version of the MASTA API.
|
|
62
|
+
- Fully customisable comparisons; choose your own tolerances, group values together and decide how you want them to be compared.
|
|
63
|
+
- Supports loading legacy `mastapy` packages using modern Python versions.
|
|
64
|
+
- Export results to an Excel workbook for further analysis.
|
|
65
|
+
|
|
66
|
+
### Release Information
|
|
67
|
+
|
|
68
|
+
This is the initial release of the package.
|
|
69
|
+
|
|
70
|
+
### Pre-Requisites
|
|
71
|
+
|
|
72
|
+
Note that these pre-requisites are only required for launching the plugin from the command-line.
|
|
73
|
+
|
|
74
|
+
- `mastapy>=15.1.3`
|
|
75
|
+
- An internet connection
|
|
76
|
+
|
|
77
|
+
### Usage
|
|
78
|
+
|
|
79
|
+
Before starting, prepare a Python script for the plugin to execute. This must be a self-contained script (i.e. does not rely on `@mastapy.masta_property`) that can be executed from the command-line.
|
|
80
|
+
|
|
81
|
+
There are two steps to using this plugin. Before executing your script, you must modify it to export a comparison structure, `mastapy_cli_regression.Comparer`, which the plugin will read to run your regression tests. The following is an example script demonstrating a modified script.
|
|
82
|
+
|
|
83
|
+
```python
|
|
84
|
+
from mastapy import Examples
|
|
85
|
+
|
|
86
|
+
# Import the Comparer from the regression package.
|
|
87
|
+
from mastapy_cli_regression import Comparer
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
def main() -> None:
|
|
91
|
+
design = Examples.Components.SIMPLE_HOUSING_FULL_MESH.load()
|
|
92
|
+
|
|
93
|
+
# Create a new Comparer object. We will add values to this for regression testing.
|
|
94
|
+
comparer = Comparer()
|
|
95
|
+
|
|
96
|
+
for load_case in design.static_loads:
|
|
97
|
+
# For each load case, create a new group. Any values added to the comparer while
|
|
98
|
+
# indented inside the `with` statement will get added to the group. his will
|
|
99
|
+
# help organise our results.
|
|
100
|
+
with comparer.group("Load Case: " + load_case.name):
|
|
101
|
+
system_deflection = load_case.system_deflection
|
|
102
|
+
system_deflection.perform_analysis()
|
|
103
|
+
|
|
104
|
+
gear_sets = design.all_parts_of_type_cylindrical_gear_set()
|
|
105
|
+
mesh_groups = (gear_set.cylindrical_meshes for gear_set in gear_sets)
|
|
106
|
+
meshes = (mesh for group in mesh_groups for mesh in group)
|
|
107
|
+
|
|
108
|
+
for mesh in meshes:
|
|
109
|
+
sd = system_deflection.results_for_cylindrical_gear_mesh(
|
|
110
|
+
mesh
|
|
111
|
+
).cast_to.cylindrical_gear_mesh_system_deflection_with_ltca_results
|
|
112
|
+
altca_results = sd.advanced_ltca_results
|
|
113
|
+
|
|
114
|
+
# Once we have results, we can add them to our comparison
|
|
115
|
+
# structure. We must also decide how we want to configure
|
|
116
|
+
# our tolerances for the regression tests. We have opted for a
|
|
117
|
+
# relative tolerance, but other options are available.
|
|
118
|
+
comparer.add(
|
|
119
|
+
"Total Misalignment",
|
|
120
|
+
sd.misalignment_data.total_equivalent_misalignment_for_rating,
|
|
121
|
+
relative_tolerance=0.0000001,
|
|
122
|
+
)
|
|
123
|
+
|
|
124
|
+
flank_rating = altca_results.rating.cylindrical_mesh_single_flank_rating
|
|
125
|
+
flank_rating = flank_rating.gear_single_flank_ratings
|
|
126
|
+
|
|
127
|
+
# Add values for the gear bending stress.
|
|
128
|
+
comparer.add(
|
|
129
|
+
"Root Stress 0",
|
|
130
|
+
flank_rating[0].tooth_root_stress,
|
|
131
|
+
relative_tolerance=0.0000001,
|
|
132
|
+
)
|
|
133
|
+
comparer.add(
|
|
134
|
+
"Root Stress 1",
|
|
135
|
+
flank_rating[1].tooth_root_stress,
|
|
136
|
+
relative_tolerance=0.0000001,
|
|
137
|
+
)
|
|
138
|
+
|
|
139
|
+
# Add values for the gear contact stress.
|
|
140
|
+
comparer.add(
|
|
141
|
+
"Contact Stress 0",
|
|
142
|
+
flank_rating[0].calculated_contact_stress,
|
|
143
|
+
relative_tolerance=0.0000001,
|
|
144
|
+
)
|
|
145
|
+
comparer.add(
|
|
146
|
+
"Contact Stress 1",
|
|
147
|
+
flank_rating[1].calculated_contact_stress,
|
|
148
|
+
relative_tolerance=0.0000001,
|
|
149
|
+
)
|
|
150
|
+
|
|
151
|
+
# Once we are done, we must call `comparer.collect`. This will output our
|
|
152
|
+
# comparison structure for the regression plugin to read!
|
|
153
|
+
comparer.collect()
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
if __name__ == "__main__":
|
|
157
|
+
main()
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
Once the script has been modified to output a comparison structure, we are ready to launch it using the plugin. This is done from the command line.
|
|
161
|
+
|
|
162
|
+
For instance, to compare results between MASTA 14.0 and MASTA 15.0 and export results to Excel, assuming both versions of MASTA are installed in the default location, we could run:
|
|
163
|
+
|
|
164
|
+
```bash
|
|
165
|
+
python -m mastapy regression "path/to/script.py" 14.0 15.0 --export-excel
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
This will execute your script in both versions of the API and automatically compile test results, then export them to Excel. Alternatively, you can provide paths to your MASTA installations:
|
|
169
|
+
|
|
170
|
+
```bash
|
|
171
|
+
python -m mastapy regression "path/to/script.py" "path/to/MASTA 14.0" "path/to/MASTA 15.0" --export-excel
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
To view the full list of features, run:
|
|
175
|
+
|
|
176
|
+
```bash
|
|
177
|
+
python -m mastapy regression --help
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
### Troubleshooting
|
|
181
|
+
|
|
182
|
+
#### Version differences
|
|
183
|
+
|
|
184
|
+
If you are attempting to compare different major versions of the API (e.g. comparing 14.0 and 15.0), changes in the API might cause your script to work in one API but not the other. To work around this, you can import `__api_version__` from `mastapy` and branch on it:
|
|
185
|
+
|
|
186
|
+
```python
|
|
187
|
+
from mastapy import __api_version__
|
|
188
|
+
|
|
189
|
+
if __api_version__ == "14.0.0":
|
|
190
|
+
# Run code for MASTA 14.0
|
|
191
|
+
...
|
|
192
|
+
else:
|
|
193
|
+
# Run code for MASTA 15.0
|
|
194
|
+
...
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
You may also need to use different versions of Python, depending on what each version of `mastapy` supports. This can be configured in your launch command using `@VERSION` syntax (or `@PATH` if you have a path to the Python executable):
|
|
198
|
+
|
|
199
|
+
```bash
|
|
200
|
+
python -m mastapy regression "path/to/script.py" 14.0@3.10 15.0
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
This will launch MASTA 14.0 using Python 3.10. You must have the corresponding version of Python installed.
|
|
204
|
+
|
|
205
|
+
#### Package Installation
|
|
206
|
+
|
|
207
|
+
This plugin automatically creates virtual environments, then downloads and installs packages into them. Internally, `pip` is used for all package management. If you require SSL certification, you can optionally use the `--truststore` flag to install it into your virtual environments:
|
|
208
|
+
|
|
209
|
+
```bash
|
|
210
|
+
python -m mastapy regression --truststore ...
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
Everything else must be configured using `pip.ini` or environment variables.
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
<h1 align="center">
|
|
2
|
+
<img src="https://documentation.smartmt.com/MastaAPI/15.1.1/images/smt_logo.png" width="150" alt="SMT">
|
|
3
|
+
</h1><br>
|
|
4
|
+
|
|
5
|
+
[](https://github.com/astral-sh/uv) [](https://github.com/astral-sh/ruff) [](https://opensource.org/licenses/MIT) 
|
|
6
|
+
|
|
7
|
+
`mastapy-cli-regression` is a command-line plugin for [mastapy](https://pypi.org/project/mastapy/).
|
|
8
|
+
|
|
9
|
+
- **Website**: https://www.smartmt.com/
|
|
10
|
+
- **Support**: https://support.smartmt.com/
|
|
11
|
+
|
|
12
|
+

|
|
13
|
+
|
|
14
|
+
To install this plugin, run the following:
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
pip install mastapy[cli-regression]
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
This plugin is designed to be used on the command-line via the [mastapy](https://pypi.org/project/mastapy/) package using the following syntax:
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
python -m mastapy regression ...
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
### Features
|
|
27
|
+
|
|
28
|
+
- Compare results between different versions of the MASTA API and automatically identify regressions.
|
|
29
|
+
- Completely automated and parallelized virtual environment creation, installation and script execution for each specified version of the MASTA API.
|
|
30
|
+
- Fully customisable comparisons; choose your own tolerances, group values together and decide how you want them to be compared.
|
|
31
|
+
- Supports loading legacy `mastapy` packages using modern Python versions.
|
|
32
|
+
- Export results to an Excel workbook for further analysis.
|
|
33
|
+
|
|
34
|
+
### Release Information
|
|
35
|
+
|
|
36
|
+
This is the initial release of the package.
|
|
37
|
+
|
|
38
|
+
### Pre-Requisites
|
|
39
|
+
|
|
40
|
+
Note that these pre-requisites are only required for launching the plugin from the command-line.
|
|
41
|
+
|
|
42
|
+
- `mastapy>=15.1.3`
|
|
43
|
+
- An internet connection
|
|
44
|
+
|
|
45
|
+
### Usage
|
|
46
|
+
|
|
47
|
+
Before starting, prepare a Python script for the plugin to execute. This must be a self-contained script (i.e. does not rely on `@mastapy.masta_property`) that can be executed from the command-line.
|
|
48
|
+
|
|
49
|
+
There are two steps to using this plugin. Before executing your script, you must modify it to export a comparison structure, `mastapy_cli_regression.Comparer`, which the plugin will read to run your regression tests. The following is an example script demonstrating a modified script.
|
|
50
|
+
|
|
51
|
+
```python
|
|
52
|
+
from mastapy import Examples
|
|
53
|
+
|
|
54
|
+
# Import the Comparer from the regression package.
|
|
55
|
+
from mastapy_cli_regression import Comparer
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def main() -> None:
|
|
59
|
+
design = Examples.Components.SIMPLE_HOUSING_FULL_MESH.load()
|
|
60
|
+
|
|
61
|
+
# Create a new Comparer object. We will add values to this for regression testing.
|
|
62
|
+
comparer = Comparer()
|
|
63
|
+
|
|
64
|
+
for load_case in design.static_loads:
|
|
65
|
+
# For each load case, create a new group. Any values added to the comparer while
|
|
66
|
+
# indented inside the `with` statement will get added to the group. his will
|
|
67
|
+
# help organise our results.
|
|
68
|
+
with comparer.group("Load Case: " + load_case.name):
|
|
69
|
+
system_deflection = load_case.system_deflection
|
|
70
|
+
system_deflection.perform_analysis()
|
|
71
|
+
|
|
72
|
+
gear_sets = design.all_parts_of_type_cylindrical_gear_set()
|
|
73
|
+
mesh_groups = (gear_set.cylindrical_meshes for gear_set in gear_sets)
|
|
74
|
+
meshes = (mesh for group in mesh_groups for mesh in group)
|
|
75
|
+
|
|
76
|
+
for mesh in meshes:
|
|
77
|
+
sd = system_deflection.results_for_cylindrical_gear_mesh(
|
|
78
|
+
mesh
|
|
79
|
+
).cast_to.cylindrical_gear_mesh_system_deflection_with_ltca_results
|
|
80
|
+
altca_results = sd.advanced_ltca_results
|
|
81
|
+
|
|
82
|
+
# Once we have results, we can add them to our comparison
|
|
83
|
+
# structure. We must also decide how we want to configure
|
|
84
|
+
# our tolerances for the regression tests. We have opted for a
|
|
85
|
+
# relative tolerance, but other options are available.
|
|
86
|
+
comparer.add(
|
|
87
|
+
"Total Misalignment",
|
|
88
|
+
sd.misalignment_data.total_equivalent_misalignment_for_rating,
|
|
89
|
+
relative_tolerance=0.0000001,
|
|
90
|
+
)
|
|
91
|
+
|
|
92
|
+
flank_rating = altca_results.rating.cylindrical_mesh_single_flank_rating
|
|
93
|
+
flank_rating = flank_rating.gear_single_flank_ratings
|
|
94
|
+
|
|
95
|
+
# Add values for the gear bending stress.
|
|
96
|
+
comparer.add(
|
|
97
|
+
"Root Stress 0",
|
|
98
|
+
flank_rating[0].tooth_root_stress,
|
|
99
|
+
relative_tolerance=0.0000001,
|
|
100
|
+
)
|
|
101
|
+
comparer.add(
|
|
102
|
+
"Root Stress 1",
|
|
103
|
+
flank_rating[1].tooth_root_stress,
|
|
104
|
+
relative_tolerance=0.0000001,
|
|
105
|
+
)
|
|
106
|
+
|
|
107
|
+
# Add values for the gear contact stress.
|
|
108
|
+
comparer.add(
|
|
109
|
+
"Contact Stress 0",
|
|
110
|
+
flank_rating[0].calculated_contact_stress,
|
|
111
|
+
relative_tolerance=0.0000001,
|
|
112
|
+
)
|
|
113
|
+
comparer.add(
|
|
114
|
+
"Contact Stress 1",
|
|
115
|
+
flank_rating[1].calculated_contact_stress,
|
|
116
|
+
relative_tolerance=0.0000001,
|
|
117
|
+
)
|
|
118
|
+
|
|
119
|
+
# Once we are done, we must call `comparer.collect`. This will output our
|
|
120
|
+
# comparison structure for the regression plugin to read!
|
|
121
|
+
comparer.collect()
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
if __name__ == "__main__":
|
|
125
|
+
main()
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
Once the script has been modified to output a comparison structure, we are ready to launch it using the plugin. This is done from the command line.
|
|
129
|
+
|
|
130
|
+
For instance, to compare results between MASTA 14.0 and MASTA 15.0 and export results to Excel, assuming both versions of MASTA are installed in the default location, we could run:
|
|
131
|
+
|
|
132
|
+
```bash
|
|
133
|
+
python -m mastapy regression "path/to/script.py" 14.0 15.0 --export-excel
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
This will execute your script in both versions of the API and automatically compile test results, then export them to Excel. Alternatively, you can provide paths to your MASTA installations:
|
|
137
|
+
|
|
138
|
+
```bash
|
|
139
|
+
python -m mastapy regression "path/to/script.py" "path/to/MASTA 14.0" "path/to/MASTA 15.0" --export-excel
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
To view the full list of features, run:
|
|
143
|
+
|
|
144
|
+
```bash
|
|
145
|
+
python -m mastapy regression --help
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
### Troubleshooting
|
|
149
|
+
|
|
150
|
+
#### Version differences
|
|
151
|
+
|
|
152
|
+
If you are attempting to compare different major versions of the API (e.g. comparing 14.0 and 15.0), changes in the API might cause your script to work in one API but not the other. To work around this, you can import `__api_version__` from `mastapy` and branch on it:
|
|
153
|
+
|
|
154
|
+
```python
|
|
155
|
+
from mastapy import __api_version__
|
|
156
|
+
|
|
157
|
+
if __api_version__ == "14.0.0":
|
|
158
|
+
# Run code for MASTA 14.0
|
|
159
|
+
...
|
|
160
|
+
else:
|
|
161
|
+
# Run code for MASTA 15.0
|
|
162
|
+
...
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
You may also need to use different versions of Python, depending on what each version of `mastapy` supports. This can be configured in your launch command using `@VERSION` syntax (or `@PATH` if you have a path to the Python executable):
|
|
166
|
+
|
|
167
|
+
```bash
|
|
168
|
+
python -m mastapy regression "path/to/script.py" 14.0@3.10 15.0
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
This will launch MASTA 14.0 using Python 3.10. You must have the corresponding version of Python installed.
|
|
172
|
+
|
|
173
|
+
#### Package Installation
|
|
174
|
+
|
|
175
|
+
This plugin automatically creates virtual environments, then downloads and installs packages into them. Internally, `pip` is used for all package management. If you require SSL certification, you can optionally use the `--truststore` flag to install it into your virtual environments:
|
|
176
|
+
|
|
177
|
+
```bash
|
|
178
|
+
python -m mastapy regression --truststore ...
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
Everything else must be configured using `pip.ini` or environment variables.
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"""Run a single mastapy script in multiple APIs and compare results."""
|
|
2
|
+
|
|
3
|
+
__version__ = "0.1.0b1"
|
|
4
|
+
|
|
5
|
+
from .comparing.comparer import Comparer
|
|
6
|
+
|
|
7
|
+
__all__ = ("__version__", "Comparer")
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def run(args: list[str]) -> None:
|
|
11
|
+
"""Run the plugin.
|
|
12
|
+
|
|
13
|
+
Args:
|
|
14
|
+
args (list[str]): Arguments from the command line for the plugin to process.
|
|
15
|
+
"""
|
|
16
|
+
from .common.cli import Options
|
|
17
|
+
from .common.errors import ProcessError
|
|
18
|
+
from .common.print import print_panel
|
|
19
|
+
from .processing import runner
|
|
20
|
+
from rich import print
|
|
21
|
+
|
|
22
|
+
try:
|
|
23
|
+
options = Options.from_command_line(args)
|
|
24
|
+
print()
|
|
25
|
+
print_panel(str(options), title="Configuration", color="green")
|
|
26
|
+
|
|
27
|
+
runner.launch_processes(options)
|
|
28
|
+
except ProcessError as error:
|
|
29
|
+
print(f"[red]{error}[/]")
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Sub-package for modules shared across other sub-packages."""
|