Skip to content

Commit c7f29e4

Browse files
authored
Feature/run on docker (#580)
1 parent 5aed41d commit c7f29e4

27 files changed

+1259
-588
lines changed

.github/workflows/ci.yml

Lines changed: 108 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -85,34 +85,7 @@ jobs:
8585
- name: "Separate long Core tests"
8686
shell: pwsh
8787
run: |
88-
New-Item -Path ".\" -Name "test_launcher" -ItemType "directory"
89-
New-Item -Path ".\" -Name "test_server" -ItemType "directory"
90-
New-Item -Path ".\" -Name "test_local_server" -ItemType "directory"
91-
New-Item -Path ".\" -Name "test_multi_server" -ItemType "directory"
92-
New-Item -Path ".\" -Name "test_workflow" -ItemType "directory"
93-
New-Item -Path ".\" -Name "test_remote_workflow" -ItemType "directory"
94-
New-Item -Path ".\" -Name "test_remote_operator" -ItemType "directory"
95-
Copy-Item -Path "tests\conftest.py" -Destination ".\test_launcher\"
96-
Copy-Item -Path "tests\conftest.py" -Destination ".\test_server\"
97-
Copy-Item -Path "tests\conftest.py" -Destination ".\test_local_server\"
98-
Copy-Item -Path "tests\conftest.py" -Destination ".\test_multi_server\"
99-
Copy-Item -Path "tests\conftest.py" -Destination ".\test_workflow\"
100-
Copy-Item -Path "tests\conftest.py" -Destination ".\test_remote_workflow\"
101-
Copy-Item -Path "tests\conftest.py" -Destination ".\test_remote_operator\"
102-
Copy-Item -Path "tests\test_launcher.py" -Destination ".\test_launcher\"
103-
Copy-Item -Path "tests\test_server.py" -Destination ".\test_server\"
104-
Copy-Item -Path "tests\test_local_server.py" -Destination ".\test_local_server\"
105-
Copy-Item -Path "tests\test_multi_server.py" -Destination ".\test_multi_server\"
106-
Copy-Item -Path "tests\test_workflow.py" -Destination ".\test_workflow\"
107-
Copy-Item -Path "tests\test_remote_workflow.py" -Destination ".\test_remote_workflow\"
108-
Copy-Item -Path "tests\test_remote_operator.py" -Destination ".\test_remote_operator\"
109-
Remove-Item -Path "tests\test_server.py"
110-
Remove-Item -Path "tests\test_launcher.py"
111-
Remove-Item -Path "tests\test_local_server.py"
112-
Remove-Item -Path "tests\test_multi_server.py"
113-
Remove-Item -Path "tests\test_workflow.py"
114-
Remove-Item -Path "tests\test_remote_workflow.py"
115-
Remove-Item -Path "tests\test_remote_operator.py"
88+
.github\workflows\scripts\separate_long_core_tests.ps1
11689
11790
- name: "Test API"
11891
shell: bash
@@ -129,7 +102,7 @@ jobs:
129102
working-directory: test_launcher
130103
run: |
131104
pytest $DEBUG --cov=ansys.dpf.core --cov-report=xml --cov-report=html --cov-append --log-level=ERROR --junitxml=../tests/junit/test-results2.xml --reruns 2 .
132-
if: always()
105+
133106
134107
- name: "Kill all servers"
135108
uses: pyansys/pydpf-actions/[email protected]
@@ -211,6 +184,110 @@ jobs:
211184
- name: "Upload coverage to Codecov"
212185
uses: codecov/codecov-action@v3
213186

187+
docker_tests:
188+
name: "Build and Test On Docker"
189+
runs-on: ${{ matrix.os }}
190+
strategy:
191+
fail-fast: false
192+
matrix:
193+
python-version: ["3.8"]
194+
os: ["ubuntu-latest"]
195+
196+
steps:
197+
- uses: actions/checkout@v3
198+
199+
- name: "Build Docker Package"
200+
uses: pyansys/pydpf-actions/[email protected]
201+
with:
202+
python-version: ${{ matrix.python-version }}
203+
ANSYS_VERSION: ${{env.ANSYS_VERSION}}
204+
PACKAGE_NAME: ${{env.PACKAGE_NAME}}
205+
MODULE: ${{env.MODULE}}
206+
dpf-standalone-TOKEN: ${{secrets.DPF_PIPELINE}}
207+
install_extras: plotting
208+
wheelhouse: false
209+
extra-pip-args: ${{ env.extra }}
210+
211+
- name: "Prepare Testing Environment"
212+
uses: pyansys/pydpf-actions/[email protected]
213+
with:
214+
DEBUG: true
215+
216+
- name: "Separate long Core tests"
217+
shell: pwsh
218+
run: |
219+
.github\workflows\scripts\separate_long_core_tests.ps1
220+
221+
- name: "Test API"
222+
shell: bash
223+
working-directory: tests
224+
run: |
225+
pytest $DEBUG --cov=ansys.dpf.${{env.MODULE}} --cov-report=xml --cov-report=html --log-level=ERROR --junitxml=junit/test-results.xml --reruns 2 .
226+
timeout-minutes: 20
227+
228+
- name: "Test API test_launcher"
229+
shell: bash
230+
working-directory: test_launcher
231+
run: |
232+
pytest $DEBUG --cov=ansys.dpf.core --cov-report=xml --cov-report=html --cov-append --log-level=ERROR --junitxml=../tests/junit/test-results2.xml --reruns 2 .
233+
if: always()
234+
timeout-minutes: 20
235+
236+
- name: "Test API test_server"
237+
shell: bash
238+
working-directory: test_server
239+
run: |
240+
pytest $DEBUG --cov=ansys.dpf.core --cov-report=xml --cov-report=html --cov-append --log-level=ERROR --junitxml=../tests/junit/test-results4.xml --reruns 2 .
241+
if: always()
242+
timeout-minutes: 10
243+
244+
- name: "Test API test_local_server"
245+
shell: bash
246+
working-directory: test_local_server
247+
run: |
248+
pytest $DEBUG --cov=ansys.dpf.core --cov-report=xml --cov-report=html --cov-append --log-level=ERROR --junitxml=../tests/junit/test-results5.xml --reruns 2 .
249+
if: always()
250+
timeout-minutes: 20
251+
252+
- name: "Test API test_multi_server"
253+
shell: bash
254+
working-directory: test_multi_server
255+
run: |
256+
pytest $DEBUG --cov=ansys.dpf.core --cov-report=xml --cov-report=html --cov-append --log-level=ERROR --junitxml=../tests/junit/test-results6.xml --reruns 2 .
257+
timeout-minutes: 20
258+
259+
- name: "Test API test_remote_workflow"
260+
shell: bash
261+
working-directory: test_remote_workflow
262+
run: |
263+
pytest $DEBUG --cov=ansys.dpf.core --cov-report=xml --cov-report=html --cov-append --log-level=ERROR --junitxml=../tests/junit/test-results7.xml --reruns 2 .
264+
timeout-minutes: 20
265+
266+
- name: "Test API test_remote_operator"
267+
shell: bash
268+
working-directory: test_remote_operator
269+
run: |
270+
pytest $DEBUG --cov=ansys.dpf.core --cov-report=xml --cov-report=html --cov-append --log-level=ERROR --junitxml=../tests/junit/test-results8.xml --reruns 2 .
271+
timeout-minutes: 5
272+
273+
- name: "Test API test_workflow"
274+
shell: bash
275+
working-directory: test_workflow
276+
run: |
277+
pytest $DEBUG --cov=ansys.dpf.core --cov-report=xml --cov-report=html --cov-append --log-level=ERROR --junitxml=../tests/junit/test-results3.xml --reruns 3 .
278+
if: always()
279+
timeout-minutes: 20
280+
281+
- name: "Upload Test Results"
282+
uses: actions/upload-artifact@v2
283+
with:
284+
name: ${{ env.PACKAGE_NAME }}_${{ matrix.python-version }}_${{ matrix.os }}_pytest_${{ env.ANSYS_VERSION }}_docker
285+
path: tests/junit/test-results.xml
286+
if: always()
287+
288+
- name: "Upload coverage to Codecov"
289+
uses: codecov/codecov-action@v3
290+
214291
docs:
215292
name: "Documentation"
216293
runs-on: windows-latest
@@ -403,6 +480,7 @@ jobs:
403480
retro:
404481
name: "Retro-compatibility"
405482
runs-on: ${{ matrix.os }}
483+
406484
strategy:
407485
fail-fast: false
408486
matrix:
@@ -471,7 +549,7 @@ jobs:
471549
shell: bash
472550
working-directory: tests
473551
run: |
474-
pytest $DEBUG --cov=ansys.dpf.${{env.MODULE}} --cov-report=xml --cov-report=html --log-level=ERROR --junitxml=junit/test-results.xml --reruns 2 .
552+
pytest $DEBUG --cov=ansys.dpf.${{env.MODULE}} --cov-report=xml --cov-report=html --log-level=ERROR --junitxml=junit/test-results.xml --reruns 2 --ignore test_examples.py .
475553
476554
- name: "Kill all servers"
477555
uses: pyansys/pydpf-actions/[email protected]
@@ -482,7 +560,6 @@ jobs:
482560
working-directory: test_launcher
483561
run: |
484562
pytest $DEBUG --cov=ansys.dpf.core --cov-report=xml --cov-report=html --cov-append --log-level=ERROR --junitxml=../tests/junit/test-results2.xml --reruns 2 .
485-
if: always()
486563
487564
- name: "Kill all servers"
488565
uses: pyansys/pydpf-actions/[email protected]
@@ -493,7 +570,6 @@ jobs:
493570
working-directory: test_server
494571
run: |
495572
pytest $DEBUG --cov=ansys.dpf.core --cov-report=xml --cov-report=html --cov-append --log-level=ERROR --junitxml=../tests/junit/test-results4.xml --reruns 2 .
496-
if: always()
497573
498574
- name: "Kill all servers"
499575
uses: pyansys/pydpf-actions/[email protected]
@@ -504,7 +580,6 @@ jobs:
504580
working-directory: test_local_server
505581
run: |
506582
pytest $DEBUG --cov=ansys.dpf.core --cov-report=xml --cov-report=html --cov-append --log-level=ERROR --junitxml=../tests/junit/test-results5.xml --reruns 2 .
507-
if: always()
508583
509584
- name: "Kill all servers"
510585
uses: pyansys/pydpf-actions/[email protected]
@@ -515,7 +590,6 @@ jobs:
515590
working-directory: test_multi_server
516591
run: |
517592
pytest $DEBUG --cov=ansys.dpf.core --cov-report=xml --cov-report=html --cov-append --log-level=ERROR --junitxml=../tests/junit/test-results6.xml --reruns 2 .
518-
if: always()
519593
520594
- name: "Kill all servers"
521595
uses: pyansys/pydpf-actions/[email protected]
@@ -526,7 +600,6 @@ jobs:
526600
working-directory: test_remote_workflow
527601
run: |
528602
pytest $DEBUG --cov=ansys.dpf.core --cov-report=xml --cov-report=html --cov-append --log-level=ERROR --junitxml=../tests/junit/test-results7.xml --reruns 2 .
529-
if: always()
530603
531604
- name: "Kill all servers"
532605
uses: pyansys/pydpf-actions/[email protected]
@@ -537,7 +610,6 @@ jobs:
537610
working-directory: test_remote_operator
538611
run: |
539612
pytest $DEBUG --cov=ansys.dpf.core --cov-report=xml --cov-report=html --cov-append --log-level=ERROR --junitxml=../tests/junit/test-results8.xml --reruns 2 .
540-
if: always()
541613
542614
- name: "Kill all servers"
543615
uses: pyansys/pydpf-actions/[email protected]
@@ -548,7 +620,6 @@ jobs:
548620
working-directory: test_workflow
549621
run: |
550622
pytest $DEBUG --cov=ansys.dpf.core --cov-report=xml --cov-report=html --cov-append --log-level=ERROR --junitxml=../tests/junit/test-results3.xml --reruns 3 .
551-
if: always()
552623
553624
- name: "Kill all servers"
554625
uses: pyansys/pydpf-actions/[email protected]
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
New-Item -Path ".\" -Name "test_launcher" -ItemType "directory"
2+
New-Item -Path ".\" -Name "test_server" -ItemType "directory"
3+
New-Item -Path ".\" -Name "test_local_server" -ItemType "directory"
4+
New-Item -Path ".\" -Name "test_multi_server" -ItemType "directory"
5+
New-Item -Path ".\" -Name "test_workflow" -ItemType "directory"
6+
New-Item -Path ".\" -Name "test_remote_workflow" -ItemType "directory"
7+
New-Item -Path ".\" -Name "test_remote_operator" -ItemType "directory"
8+
Copy-Item -Path "tests\conftest.py" -Destination ".\test_launcher\"
9+
Copy-Item -Path "tests\conftest.py" -Destination ".\test_server\"
10+
Copy-Item -Path "tests\conftest.py" -Destination ".\test_local_server\"
11+
Copy-Item -Path "tests\conftest.py" -Destination ".\test_multi_server\"
12+
Copy-Item -Path "tests\conftest.py" -Destination ".\test_workflow\"
13+
Copy-Item -Path "tests\conftest.py" -Destination ".\test_remote_workflow\"
14+
Copy-Item -Path "tests\conftest.py" -Destination ".\test_remote_operator\"
15+
Copy-Item -Path "tests\test_launcher.py" -Destination ".\test_launcher\"
16+
Copy-Item -Path "tests\test_server.py" -Destination ".\test_server\"
17+
Copy-Item -Path "tests\test_local_server.py" -Destination ".\test_local_server\"
18+
Copy-Item -Path "tests\test_multi_server.py" -Destination ".\test_multi_server\"
19+
Copy-Item -Path "tests\test_workflow.py" -Destination ".\test_workflow\"
20+
Copy-Item -Path "tests\test_remote_workflow.py" -Destination ".\test_remote_workflow\"
21+
Copy-Item -Path "tests\test_remote_operator.py" -Destination ".\test_remote_operator\"
22+
Remove-Item -Path "tests\test_server.py"
23+
Remove-Item -Path "tests\test_launcher.py"
24+
Remove-Item -Path "tests\test_local_server.py"
25+
Remove-Item -Path "tests\test_multi_server.py"
26+
Remove-Item -Path "tests\test_workflow.py"
27+
Remove-Item -Path "tests\test_remote_workflow.py"
28+
Remove-Item -Path "tests\test_remote_operator.py"

ansys/dpf/core/__init__.py

Lines changed: 17 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,23 @@
33

44
from ansys.dpf.core._version import __version__
55

6-
# environment variables for pyansys.com
7-
if "jupyter" in socket.gethostname():
8-
if "ANSYS_DPF_PATH" not in os.environ:
9-
os.environ["ANSYS_DPF_PATH"] = "/mnt/ansys_inc/v212/"
10-
if "DPF_PATH" not in os.environ:
11-
os.environ["DPF_PATH"] = (
12-
"/mnt/ansys_inc/dpf/bin_v%s/Ans.dpf.core.Grpc.exe" % __version__
13-
)
14-
if "AWP_UNIT_TEST_FILES" not in os.environ:
15-
os.environ["AWP_UNIT_TEST_FILES"] = "/mnt/ansys_inc/dpf/test_files/"
166

7+
# Setup data directory
8+
USER_DATA_PATH = None
9+
LOCAL_DOWNLOADED_EXAMPLES_PATH = None
10+
try:
11+
import pkgutil
12+
13+
spec = pkgutil.get_loader("ansys.dpf.core")
14+
USER_DATA_PATH = os.path.dirname(spec.get_filename())
15+
if not os.path.exists(USER_DATA_PATH): # pragma: no cover
16+
os.makedirs(USER_DATA_PATH)
17+
18+
LOCAL_DOWNLOADED_EXAMPLES_PATH = os.path.join(USER_DATA_PATH, "examples")
19+
if not os.path.exists(LOCAL_DOWNLOADED_EXAMPLES_PATH): # pragma: no cover
20+
os.makedirs(LOCAL_DOWNLOADED_EXAMPLES_PATH)
21+
except: # pragma: no cover
22+
pass
1723

1824
from ansys.dpf.core.dpf_operator import Operator, Config
1925
from ansys.dpf.core.model import Model
@@ -32,6 +38,7 @@
3238
connect_to_server,
3339
has_local_server,
3440
)
41+
from ansys.dpf.core.server import _global_server as global_server
3542
from ansys.dpf.core.data_sources import DataSources
3643
from ansys.dpf.core.scoping import Scoping
3744
from ansys.dpf.core.common import (
@@ -80,22 +87,6 @@
8087
# solves "QApplication: invalid style override passed, ignoring it."
8188
os.environ["QT_STYLE_OVERRIDE"] = ""
8289

83-
# Setup data directory
84-
USER_DATA_PATH = None
85-
LOCAL_DOWNLOADED_EXAMPLES_PATH = None
86-
try:
87-
import pkgutil
88-
89-
spec = pkgutil.get_loader("ansys.dpf.core")
90-
USER_DATA_PATH = os.path.dirname(spec.get_filename())
91-
if not os.path.exists(USER_DATA_PATH): # pragma: no cover
92-
os.makedirs(USER_DATA_PATH)
93-
94-
LOCAL_DOWNLOADED_EXAMPLES_PATH = os.path.join(USER_DATA_PATH, "examples")
95-
if not os.path.exists(LOCAL_DOWNLOADED_EXAMPLES_PATH): # pragma: no cover
96-
os.makedirs(LOCAL_DOWNLOADED_EXAMPLES_PATH)
97-
except: # pragma: no cover
98-
pass
9990

10091
SERVER = None
10192
SERVER_CONFIGURATION = None

0 commit comments

Comments
 (0)