Skip to content

Commit 9c7ac8e

Browse files
anslpaLea Paradis
andauthored
Update DPF-Post module (0.2.0) regarding the DPF-Core upgrade (0.3.0) (#21)
* First part of the unit tests have been updated and works now. * More tests are now succeding. * All tests are succeeding. * op_average removed (not necessary anymore because ElectricField have been fixed) * Tests added (compare result_objects values to dpf.core operators outputs) * Enhancement of tests using dpf comparison operator * Enhancement of unit testing. * Fix plotting with labels helpers * Templates and script to build doc added to the .ci * Permission set up for Linux build * ansys-dpf-post relies on ansys-dpf-core 0.3.0 only * .ci for DPF-Post (DPF-Core 0.3.0 have been published) * Add pytest-reruns to test_requirements and fix the docs/_build folder for documentation * Don't start server before testing anymore * Linux chmod added * Add session fixture to close server at the end of the tests * Remove check server log step for Windows .ci * .ci of Documentation enabled * Reset azure-pipelines.yml and fix ci-build.yml * Remove ci-build.yml (doc is now generated under .ci/azure-pipelines.yml) * Template for kill-server-linux step * Add template for kill-server-linux * Remove the copying example files step * Splitting test that were plotting (specific plotting test have been added) * Use of np.isclose Co-authored-by: Lea Paradis <[email protected]>
1 parent 8325879 commit 9c7ac8e

26 files changed

+666
-397
lines changed

.ci/azure-pipelines.yml

100644100755
Lines changed: 132 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -26,76 +26,58 @@ jobs:
2626
python.version: '3.8'
2727
DISPLAY: ':99.0'
2828
PYANSYS_OFF_SCREEN: True
29-
DPF_PORT: 32772
30-
DPF_START_SERVER: False
3129
pool:
3230
vmImage: 'windows-2019'
3331

3432
steps:
35-
- powershell: |
36-
powershell .ci/install_opengl.ps1
37-
.ci/setup_headless_display.sh
38-
pip install -r .ci/requirements_test_xvfb.txt
39-
python .ci/display_test.py
40-
displayName: Install and start a virtual framebuffer
41-
42-
- task: UsePythonVersion@0
43-
inputs:
44-
versionSpec: $(python.version)
45-
addToPath: true
46-
47-
- task: PipAuthenticate@1
33+
- template: templates\prepare-environment-windows.yml
34+
35+
- task: PublishBuildArtifacts@1
36+
displayName: 'WHEEL: publish artifacts'
4837
inputs:
49-
artifactFeeds: 'pyansys'
50-
onlyAddExtraIndex: true
51-
52-
- script: |
53-
pip install -r requirements_build.txt
54-
python setup.py bdist_wheel
55-
pip install --find-links=dist ansys_dpf_post
56-
cd tests
57-
python -c "from ansys.dpf import post; print(post.Report(gpu=False))"
58-
displayName: Install ansys-dpf-post
59-
60-
- task: UniversalPackages@0
61-
inputs:
62-
command: 'download'
63-
downloadDirectory: '$(System.DefaultWorkingDirectory)'
64-
feedsToUse: 'internal'
65-
vstsFeed: '705e121a-9631-49f5-8aaf-c7142856f923'
66-
vstsFeedPackage: 'f913c1d3-1fe4-404c-8c28-15a234e56803'
67-
vstsPackageVersion: '21.1.4'
68-
69-
- script: |
70-
@echo on
71-
dir $(System.DefaultWorkingDirectory)
72-
set THISDIR=$(System.DefaultWorkingDirectory)
73-
set PATH=%THISDIR%\server\v211\tp\IntelMKL\2020.0.166\winx64\;%THISDIR%\server\v211\tp\hdf5\1.8.14\winx64\;%THISDIR%\server\v211\tp\CFFSDK\lib\winx64;%THISDIR%\res_files\;%PATH%
74-
cd %THISDIR%\server\v211\aisol\bin\winx64
75-
START /B Ans.Dpf.Grpc.exe --address 127.0.0.1 --port %DPF_PORT% > log.txt 2>&1
76-
python -c "from ansys.dpf import core; core.connect_to_server(port=$(DPF_PORT)); print('Python Connected')"
77-
displayName: Start DPF Server
38+
PathtoPublish: '$(System.DefaultWorkingDirectory)\dist'
39+
ArtifactName: 'ansys_dpf_post_wheel'
40+
enabled: true
7841

7942
- script: |
8043
pip install -r requirements_test.txt
81-
cd tests
82-
pytest -v --junitxml=junit/test-results.xml --cov ansys.dpf.post --cov-report=xml
44+
set THISDIR=$(System.DefaultWorkingDirectory)
45+
cd tests=$(System.DefaultWorkingDirectory)
46+
set AWP_ROOT212=%THISDIR%\server\v212
47+
pytest -v --junitxml=junit/test-results.xml --cov ansys.dpf.post --cov-report=xml --reruns 3
48+
echo %PATH%
49+
8350
displayName: Test Post API
84-
85-
- script: |
86-
type $(System.DefaultWorkingDirectory)\server\v211\aisol\bin\winx64\log.txt
87-
displayName: 'Show DPF Server Logs'
51+
52+
- task: PublishTestResults@2
53+
inputs:
54+
testResultsFormat: 'JUnit'
55+
testResultsFiles: 'junit/test-results.xml'
56+
testRunTitle: 'windowsTests'
57+
publishRunAttachments: true
8858
condition: always()
59+
60+
- script: |
61+
pip install twine
62+
python setup.py sdist
63+
twine upload --skip-existing dist/*
64+
displayName: 'Upload to PyPi'
65+
condition: contains(variables['Build.SourceBranch'], 'refs/tags/')
66+
env:
67+
TWINE_USERNAME: __token__
68+
TWINE_PASSWORD: $(PYPI_TOKEN)
69+
TWINE_REPOSITORY_URL: "https://upload.pypi.org/legacy/"
70+
71+
- template: templates\kill-servers-windows.yml
72+
8973

9074
- job: Linux
9175
variables:
9276
python.version: '3.7' # due to VTK 8.1.2 requirement for docbuild
9377
DISPLAY: ':99.0'
9478
PYANSYS_OFF_SCREEN: True
95-
DPF_PORT: 32772
96-
DPF_START_SERVER: False
97-
DPF_IMAGE: docker.pkg.github.com/pyansys/dpf-core/dpf:v2021.1
98-
DPF_DOCKER: True
79+
TEMP: $(System.DefaultWorkingDirectory)/temp
80+
9981
pool:
10082
vmImage: 'ubuntu-20.04'
10183
steps:
@@ -104,6 +86,11 @@ jobs:
10486
versionSpec: '$(python.version)'
10587
displayName: 'Use Python $(python.version)'
10688

89+
- task: PipAuthenticate@1
90+
inputs:
91+
artifactFeeds: 'pyansys'
92+
onlyAddExtraIndex: true
93+
10794
- script: |
10895
ls -lh .ci
10996
chmod +x .ci/setup_headless_display.sh
@@ -115,43 +102,107 @@ jobs:
115102
- script: |
116103
pip install -r requirements_build.txt
117104
python setup.py bdist_wheel
118-
pip install --find-links=dist ansys_dpf_post
105+
export WHEELNAME=`ls dist/*.whl`
106+
echo ${WHEELNAME}
107+
pip install ${WHEELNAME}
119108
cd tests
120109
python -c "from ansys.dpf import post; print(post.Report())"
121110
displayName: Install ansys-dpf-post
122111
123-
# this step is necessary as we're running in docker and the
124-
# examples directory must be local to the docker enviornment
125-
- script: |
126-
EXAMPLES_DIR=$(python -c "from ansys.dpf.core import examples; import os; print(os.path.dirname(examples.__file__))")
127-
mkdir -p ansys/dpf/core
128-
cp -r $EXAMPLES_DIR ansys/dpf/core
129-
displayName: Copy ansys.dpf.core examples to local directory
130-
112+
- task: UniversalPackages@0
113+
inputs:
114+
command: 'download'
115+
downloadDirectory: '$(System.DefaultWorkingDirectory)'
116+
feedsToUse: 'internal'
117+
vstsFeed: '705e121a-9631-49f5-8aaf-c7142856f923'
118+
vstsFeedPackage: 'dpf-linux' #TODO: update hash of packages
119+
vstsPackageVersion: '21.2.5'
120+
121+
- template: templates\kill-servers-linux.yml
122+
131123
- script: |
132-
set -ex
133-
echo $(PAT) | docker login -u $(GH_USERNAME) --password-stdin docker.pkg.github.com
134-
docker pull $(DPF_IMAGE)
135-
touch log.txt
136-
docker run --restart always --name dpf -v `pwd`:/dpf -v /tmp:/dpf/_cache -p $(DPF_PORT):50054 $(DPF_IMAGE) > log.txt &
137-
grep -q 'server started on ip' <(timeout 60 tail -f log.txt)
138-
python -c "from ansys.dpf import core as dpf; dpf.connect_to_server(port=$(DPF_PORT)); print('Python Connected')"
139-
displayName: Pull, launch, and validate DPF service
124+
env
125+
displayName: Display env
140126
141127
- script: |
142128
pip install -r requirements_test.txt
143-
pip install pytest-azurepipelines
129+
pip install pytest-azurepipelines
130+
export AWP_ROOT212=${SYSTEM_DEFAULTWORKINGDIRECTORY}/server/v212
131+
chmod 755 ${AWP_ROOT212}/aisol/bin/linx64/Ans.Dpf.Grpc.sh
132+
chmod 755 ${AWP_ROOT212}/aisol/bin/linx64/Ans.Dpf.Grpc.exe
144133
cd tests
145-
pytest -v --junitxml=junit/test-results.xml --cov ansys.dpf.post --cov-report=xml --cov-report=html
134+
pytest -v --junitxml=junit/test-results.xml --cov ansys.dpf.post --cov-report=xml --reruns 3
135+
export PATH=`pwd`
136+
echo ${PATH}
146137
displayName: Test Post API
138+
139+
- task: PublishTestResults@2
140+
inputs:
141+
testResultsFormat: 'JUnit'
142+
testResultsFiles: 'junit/test-results.xml'
143+
testRunTitle: 'linuxTests'
144+
publishRunAttachments: true
145+
searchFolder: 'tests/'
146+
condition: always()
147+
148+
149+
- template: templates\kill-servers-linux.yml
150+
151+
- job: DocumentationWindows
152+
variables:
153+
python.version: '3.8'
154+
DISPLAY: ':99.0'
155+
PYANSYS_OFF_SCREEN: True
156+
DPF_PORT: 32772
157+
GH_DOC_BRANCH: 'gh-pages'
158+
pool:
159+
vmImage: 'windows-2019'
147160

161+
steps:
162+
- template: templates\prepare-environment-windows.yml
163+
148164
- script: |
149-
pip install twine
150-
python setup.py sdist
151-
twine upload --skip-existing dist/*
152-
displayName: 'Upload to PyPi'
165+
pip install -r requirements_docs.txt
166+
cd .ci
167+
dir
168+
set THISDIR=$(System.DefaultWorkingDirectory)
169+
set AWP_ROOT212=%THISDIR%\server\v212
170+
ECHO %AWP_ROOT212%
171+
build_doc.bat
172+
displayName: Build Documentation
173+
174+
- task: ArchiveFiles@2
175+
inputs:
176+
rootFolderOrFile: '$(System.DefaultWorkingDirectory)\docs\_build'
177+
includeRootFolder: false
178+
archiveType: 'zip'
179+
archiveFile: '$(System.DefaultWorkingDirectory)\docs\archive\doc-ansys-dpf-post.zip'
180+
replaceExistingArchive: true
181+
displayName: 'DOCUMENTATION: zip artifacts'
182+
183+
- task: PublishBuildArtifacts@1
184+
displayName: 'DOCUMENTATION: publish artifacts'
185+
inputs:
186+
PathtoPublish: '$(System.DefaultWorkingDirectory)\docs\archive'
187+
ArtifactName: doc-ansys-dpf-post
188+
enabled: true
189+
190+
- powershell: |
191+
git init
192+
git checkout -b $(GH_DOC_BRANCH)
193+
git config --global user.name "pyansys-ci-bot"
194+
git config --global user.email "$(GH_EMAIL)"
195+
New-Item -ItemType file .nojekyll
196+
git add .
197+
git commit -m "Documentation generated by $(Build.DefinitionName)"
198+
displayName: "Init git and add docs"
199+
workingDirectory: docs\_build\html
200+
201+
- script: |
202+
git remote add origin https://$(GH_PAT)@github.com/pyansys/DPF-Post-docs
203+
git push -u origin $(GH_DOC_BRANCH) --force
204+
displayName: "Publish GitHub Pages merge commit"
205+
workingDirectory: docs\_build\html
153206
condition: contains(variables['Build.SourceBranch'], 'refs/tags/')
154-
env:
155-
TWINE_USERNAME: __token__
156-
TWINE_PASSWORD: $(PYPI_TOKEN)
157-
TWINE_REPOSITORY_URL: "https://upload.pypi.org/legacy/"
207+
208+
- template: templates\kill-servers-windows.yml

.ci/build_doc.bat

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
ECHO %AWP_ROOT212%
2+
set SPHINX_APIDOC_OPTIONS=inherited-members
3+
call sphinx-apidoc -o ../docs/source/api ../ansys -f --implicit-namespaces --separate --no-headings
4+
pushd .
5+
cd ../docs/
6+
call make clean
7+
call make html
8+
popd
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
steps:
2+
- script : |
3+
echo $0
4+
if pgrep -x "Ans.Dpf.Grpc" > /dev/null
5+
then
6+
pkill -f Ans.Dpf.Grpc.exe
7+
fi
8+
displayName: 'Kill all servers'
9+
condition: always()
10+
continueOnError: true
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
steps:
2+
- script : |
3+
tasklist /FI "IMAGENAME eq Ans.Dpf.Grpc.exe" 2>NUL | find /I /N "Ans.Dpf.Grpc.exe">NUL
4+
ECHO %ERRORLEVEL%
5+
if "%ERRORLEVEL%"=="0"(taskkill /f /im Ans.Dpf.Grpc.exe)
6+
displayName: 'Kill all servers'
7+
condition: always()
8+
continueOnError: true
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
steps:
2+
- powershell: |
3+
Set-StrictMode -Version Latest
4+
$ErrorActionPreference = "Stop"
5+
$PSDefaultParameterValues['*:ErrorAction']='Stop'
6+
git clone --depth 1 git://github.com/pyvista/gl-ci-helpers.git
7+
powershell gl-ci-helpers/appveyor/install_opengl.ps1
8+
displayName: 'Install OpenGL'
9+
10+
- powershell: |
11+
.ci/setup_headless_display.sh
12+
pip install -r .ci/requirements_test_xvfb.txt
13+
python .ci/display_test.py
14+
displayName: Install test offscreen rendering
15+
16+
- task: UsePythonVersion@0
17+
inputs:
18+
versionSpec: $(python.version)
19+
addToPath: true
20+
21+
- task: PipAuthenticate@1
22+
inputs:
23+
artifactFeeds: 'pyansys'
24+
onlyAddExtraIndex: true
25+
26+
- script: |
27+
pip install -r requirements_build.txt
28+
python setup.py bdist_wheel
29+
FOR /F %%a in ('dir /s/b dist\*.whl') do SET WHEELPATH=%%a
30+
ECHO %WHEELPATH%
31+
pip install %WHEELPATH%
32+
cd tests
33+
python -c "from ansys.dpf import post; print(post.Report(gpu=False))"
34+
35+
displayName: Install ansys-dpf-post
36+
37+
- task: UniversalPackages@0
38+
inputs:
39+
command: 'download'
40+
downloadDirectory: '$(System.DefaultWorkingDirectory)'
41+
feedsToUse: 'internal'
42+
vstsFeed: '705e121a-9631-49f5-8aaf-c7142856f923'
43+
vstsFeedPackage: 'dpf-windows'
44+
vstsPackageVersion: '21.2.3'

0 commit comments

Comments
 (0)