Skip to content

Commit f608955

Browse files
authored
Add linux doc build (#122)
* Add linux doc build * Add sphinx-apidoc
1 parent 19350d5 commit f608955

File tree

4 files changed

+115
-99
lines changed

4 files changed

+115
-99
lines changed

.ci/azure-pipelines.yml

Lines changed: 37 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333
vmImage: 'windows-2019'
3434

3535
steps:
36-
- template: templates\prepare-environment-windows.yml
36+
- template: templates\prepare-environment-windows.yml
3737

3838
- task: PublishBuildArtifacts@1
3939
displayName: 'WHEEL: publish artifacts'
@@ -114,80 +114,20 @@ jobs:
114114
PYANSYS_OFF_SCREEN: True
115115
DPF_PORT: 50055
116116
TEMP: $(System.DefaultWorkingDirectory)/temp
117+
AWP_ROOT212: $(System.DefaultWorkingDirectory)/server/v212
117118

118119
pool:
119120
vmImage: 'ubuntu-20.04'
120121
steps:
121-
- task: UsePythonVersion@0
122-
inputs:
123-
versionSpec: '$(python.version)'
124-
displayName: 'Use Python $(python.version)'
125-
126-
- task: PipAuthenticate@1
127-
inputs:
128-
artifactFeeds: 'pyansys'
129-
onlyAddExtraIndex: true
130-
131-
- script: |
132-
.ci/setup_headless_display.sh
133-
pip install -r .ci/requirements_test_xvfb.txt
134-
python .ci/display_test.py
135-
displayName: Install and start a virtual framebuffer
136-
137-
- script: |
138-
pip install -r requirements_build.txt
139-
python setup.py bdist_wheel
140-
export WHEELNAME=`ls dist/*.whl`
141-
echo ${WHEELNAME}
142-
pip install ${WHEELNAME}
143-
cd tests
144-
python -c "from ansys.dpf import core; print(core.Report())"
145-
displayName: Install ansys-dpf-core
122+
- template: templates\prepare-environment-linux.yml
146123

147-
- task: UniversalPackages@0
148-
inputs:
149-
command: 'download'
150-
downloadDirectory: '$(System.DefaultWorkingDirectory)'
151-
feedsToUse: 'internal'
152-
vstsFeed: '705e121a-9631-49f5-8aaf-c7142856f923'
153-
vstsFeedPackage: 'dpf-linux' #TODO: update hash of packages
154-
vstsPackageVersion: '21.2.5'
155-
156-
- script : |
157-
echo $0
158-
if pgrep -x "Ans.Dpf.Grpc" > /dev/null
159-
then
160-
pkill -f Ans.Dpf.Grpc.exe
161-
fi
162-
displayName: 'Kill all servers'
163-
condition: always()
164-
continueOnError: true
165-
166-
- script: |
167-
env
168-
displayName: Display env
169-
170-
- script: |
171-
echo $0
172-
export THISDIR=${SYSTEM_DEFAULTWORKINGDIRECTORY}
173-
echo ${THISDIR}
174-
export AWP_ROOT212=${THISDIR}/server/v212
175-
cd ${THISDIR}/server/v212/aisol/bin/linx64
176-
pwd
177-
chmod 755 Ans.Dpf.Grpc.sh
178-
chmod 755 Ans.Dpf.Grpc.exe
179-
./Ans.Dpf.Grpc.sh --port 50054 & > log.txt
180-
export DPF_IP=$(hostname -i)
181-
python -c "from ansys.dpf import core; core.connect_to_server(ip= '${DPF_IP}', port=50054); print('Python Connected')"
182-
displayName: Start DPF Server
183-
184124
- script: |
185125
pip install -r requirements_test.txt
186126
pip install pytest-azurepipelines
187127
export AWP_ROOT212=${SYSTEM_DEFAULTWORKINGDIRECTORY}/server/v212
188128
cd tests
189129
export DPF_IP=$(hostname -i)
190-
pytest -v --junitxml=junit/test-results.xml --cov ansys.dpf.core --cov-report=xml --reruns 3
130+
xvfb-run pytest -v --junitxml=junit/test-results.xml --cov ansys.dpf.core --cov-report=xml --reruns 3
191131
export PATH=`pwd`
192132
echo ${PATH}
193133
displayName: Test Core API
@@ -212,46 +152,45 @@ jobs:
212152
condition: always()
213153
continueOnError: true
214154
215-
216-
- job: DocumentationWindows
155+
- job: DocumentationLinux
217156
variables:
218-
python.version: '3.8'
219-
DISPLAY: ':99.0'
157+
python.version: '3.7' # due to VTK 8.1.2 requirement for docbuild
220158
PYANSYS_OFF_SCREEN: True
221-
DPF_PORT: 32772
159+
DPF_PORT: 50055
160+
TEMP: $(System.DefaultWorkingDirectory)/temp
161+
AWP_ROOT212: $(System.DefaultWorkingDirectory)/server/v212
222162
GH_DOC_BRANCH: 'gh-pages'
163+
223164
pool:
224-
vmImage: 'windows-2019'
165+
vmImage: 'ubuntu-20.04'
166+
steps:
167+
- template: templates\prepare-environment-linux.yml
225168

226-
steps:
227-
- template: templates\prepare-environment-windows.yml
228-
229169
- script: |
230-
pip install -r requirements_docs.txt
231-
cd .ci
232-
dir
233-
set THISDIR=$(System.DefaultWorkingDirectory)
234-
set AWP_ROOT212=%THISDIR%\server\v212
235-
ECHO %AWP_ROOT212%
236-
build_doc.bat
170+
pip install -r requirements_docs.txt
171+
displayName: Install documentation packages for Python
172+
173+
- script: |
174+
sphinx-apidoc -o docs/source/api ansys ansys/dpf/core/aeneid.py -f --implicit-namespaces --separate --no-headings
175+
xvfb-run make -C docs html SPHINXOPTS="-w build_errors.txt -N"
237176
displayName: Build Documentation
238-
177+
239178
- task: ArchiveFiles@2
240179
inputs:
241-
rootFolderOrFile: '$(System.DefaultWorkingDirectory)\docs\build'
180+
rootFolderOrFile: '$(System.DefaultWorkingDirectory)/docs/build'
242181
includeRootFolder: false
243182
archiveType: 'zip'
244-
archiveFile: '$(System.DefaultWorkingDirectory)\docs\archive\doc-ansys-dpf-core.zip'
183+
archiveFile: '$(System.DefaultWorkingDirectory)/docs/archive/doc-ansys-dpf-core.zip'
245184
replaceExistingArchive: true
246185
displayName: 'DOCUMENTATION: zip artifacts'
247186

248187
- task: PublishBuildArtifacts@1
249188
displayName: 'DOCUMENTATION: publish artifacts'
250189
inputs:
251-
PathtoPublish: '$(System.DefaultWorkingDirectory)\docs\archive'
190+
PathtoPublish: '$(System.DefaultWorkingDirectory)/docs/archive'
252191
ArtifactName: doc-ansys-dpf-core
253-
enabled: true
254-
192+
enabled: true
193+
255194
- powershell: |
256195
git init
257196
git checkout -b $(GH_DOC_BRANCH)
@@ -261,15 +200,21 @@ jobs:
261200
git add .
262201
git commit -m "Documentation generated by $(Build.DefinitionName)"
263202
displayName: "Init git and add docs"
264-
workingDirectory: docs\build\html
203+
workingDirectory: docs/build/html
265204
266205
- script: |
267206
git remote add origin https://$(GH_PAT)@github.com/pyansys/DPF-Core-docs
268207
git push -u origin $(GH_DOC_BRANCH) --force
269208
displayName: "Publish GitHub Pages merge commit"
270-
workingDirectory: docs\build\html
209+
workingDirectory: docs/build/html
271210
condition: contains(variables['Build.SourceBranch'], 'refs/tags/')
272-
273-
- template: templates\kill-servers-windows.yml
274-
275-
211+
212+
- script : |
213+
echo $0
214+
if pgrep -x "Ans.Dpf.Grpc" > /dev/null
215+
then
216+
pkill -f Ans.Dpf.Grpc.exe
217+
fi
218+
displayName: 'Kill all servers'
219+
condition: always()
220+
continueOnError: true
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
steps:
2+
- task: UsePythonVersion@0
3+
inputs:
4+
versionSpec: "$(python.version)"
5+
displayName: "Use Python $(python.version)"
6+
7+
- task: PipAuthenticate@1
8+
inputs:
9+
artifactFeeds: "pyansys"
10+
onlyAddExtraIndex: true
11+
12+
- script: |
13+
sudo apt update
14+
sudo apt install zip pandoc libgl1-mesa-glx xvfb
15+
displayName: Install OS packages
16+
17+
- script: |
18+
pip install -r .ci/requirements_test_xvfb.txt
19+
xvfb-run python .ci/display_test.py
20+
displayName: Test virtual framebuffer
21+
22+
- script: |
23+
pip install -r requirements_build.txt
24+
python setup.py bdist_wheel
25+
export WHEELNAME=`ls dist/*.whl`
26+
echo ${WHEELNAME}
27+
pip install ${WHEELNAME}
28+
cd tests
29+
xvfb-run python -c "from ansys.dpf import core; print(core.Report())"
30+
displayName: Install ansys-dpf-core
31+
32+
- task: UniversalPackages@0
33+
inputs:
34+
command: "download"
35+
downloadDirectory: "$(System.DefaultWorkingDirectory)"
36+
feedsToUse: "internal"
37+
vstsFeed: "705e121a-9631-49f5-8aaf-c7142856f923"
38+
vstsFeedPackage: "dpf-linux" #TODO: update hash of packages
39+
vstsPackageVersion: "21.2.5"
40+
displayName: Download DPF linux package
41+
42+
- script: |
43+
echo $0
44+
if pgrep -x "Ans.Dpf.Grpc" > /dev/null
45+
then
46+
pkill -f Ans.Dpf.Grpc.exe
47+
fi
48+
displayName: "Kill all servers"
49+
condition: always()
50+
continueOnError: true
51+
52+
- script: |
53+
env
54+
displayName: Display env
55+
56+
- script: |
57+
cd ${AWP_ROOT212}/aisol/bin/linx64
58+
pwd
59+
chmod 755 Ans.Dpf.Grpc.sh
60+
chmod 755 Ans.Dpf.Grpc.exe
61+
./Ans.Dpf.Grpc.sh --port 50054 & > log.txt
62+
export DPF_IP=$(hostname -i)
63+
python -c "from ansys.dpf import core; core.connect_to_server(ip= '${DPF_IP}', port=50054); print('Python Connected')"
64+
displayName: Start DPF Server

examples/00-basic/06-load_plugin.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,17 @@
88
"""
99

1010
###############################################################################
11-
# Import DPF-Core:
11+
import os
1212

13+
# Import DPF-Core:
1314
from ansys.dpf import core as dpf
1415

1516
###############################################################################
1617
# Create a base service for loading a plugin:
17-
18-
dpf.core.load_library("Ans.Dpf.Math.dll", "math_operators")
18+
if os.name == "posix":
19+
dpf.core.load_library("libAns.Dpf.Math.so", "math_operators")
20+
else:
21+
dpf.core.load_library("Ans.Dpf.Math.dll", "math_operators")
1922

2023
###############################################################################
2124
# Math operators are now loaded and accessible in ``ansys.dpf.core.operators``:

examples/04-specific-requests/00-hdf5_double_float_comparison.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,20 +56,24 @@
5656
###############################################################################
5757
# Export with simple precision
5858

59-
h5op.inputs.file_path.connect(os.path.join(tmpdir, "c:/temp/dpf_float.h5"))
59+
directory = "c:/temp/"
60+
if os.name == "posix":
61+
directory = "/tmp/"
62+
63+
h5op.inputs.file_path.connect(os.path.join(tmpdir, directory, "dpf_float.h5"))
6064
h5op.run()
6165

6266
###############################################################################
6367
# Export with simple precision
6468

6569
h5op.inputs.export_floats.connect(False)
66-
h5op.inputs.file_path.connect(os.path.join(tmpdir, "c:/temp/dpf_double.h5"))
70+
h5op.inputs.file_path.connect(os.path.join(tmpdir, directory, "dpf_double.h5"))
6771
h5op.run()
6872

6973
###############################################################################
7074
# Comparison
71-
float_precision = os.stat(os.path.join(tmpdir, "c:/temp/dpf_float.h5")).st_size
72-
double_precision = os.stat(os.path.join(tmpdir, "c:/temp/dpf_double.h5")).st_size
75+
float_precision = os.stat(os.path.join(tmpdir, directory, "dpf_float.h5")).st_size
76+
double_precision = os.stat(os.path.join(tmpdir, directory, "dpf_double.h5")).st_size
7377
print(
7478
f"size with float precision: {float_precision}\n"
7579
f"size with double precision: {double_precision}"

0 commit comments

Comments
 (0)