Skip to content

Commit

Permalink
Updated pdf export in paraview_hello_world.ipynb to match current Par…
Browse files Browse the repository at this point in the history
…aview API (#1408)

Co-authored-by: Sylwester Arabas <[email protected]>
  • Loading branch information
olastrz and slayoo authored Nov 6, 2024
1 parent 4c0f146 commit 48ea037
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 30 deletions.
36 changes: 24 additions & 12 deletions .github/workflows/tests+artifacts+pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ jobs:
- uses: actions/[email protected]
with:
submodules: recursive
fetch-depth: 0
fetch-depth: 0
- name: Set up Python 3.9
uses: actions/[email protected]
with:
Expand Down Expand Up @@ -114,7 +114,7 @@ jobs:
steps:
- uses: actions/[email protected]
- uses: notiz-dev/github-action-json-property@release
with:
with:
path: '.zenodo.json'
prop_path: 'creators'

Expand Down Expand Up @@ -165,7 +165,7 @@ jobs:
# install devops_tests for tutorials_tests
- if: matrix.test-suite == 'tutorials_tests'
run: pip install -r tests/devops_tests/requirements.txt
run: pip install -r tests/devops_tests/requirements.txt

# https://github.com/numba/numba/issues/6350#issuecomment-728174860
- if: startsWith(matrix.platform, 'ubuntu-')
Expand All @@ -188,7 +188,7 @@ jobs:
needs: [nojit_and_codecov]
strategy:
matrix:
platform: [ubuntu-22.04, macos-12, windows-latest]
platform: [ubuntu-24.04, macos-12, windows-latest]
python-version: ["3.9", "3.11"]
runs-on: ${{ matrix.platform }}
steps:
Expand Down Expand Up @@ -224,7 +224,7 @@ jobs:
needs: [examples-setup]
strategy:
matrix:
platform: [ubuntu-22.04, macos-12, windows-latest]
platform: [ubuntu-24.04, macos-12, windows-latest]
python-version: ["3.9", "3.11"]
test-suite: [ "chemistry_freezing_isotopes", "condensation_a", "condensation_b", "coagulation", "breakup", "multi-process_a", "multi-process_b"]
fail-fast: false
Expand Down Expand Up @@ -255,16 +255,28 @@ jobs:
- if: startsWith(matrix.platform, 'ubuntu-')
run: echo NUMBA_THREADING_LAYER=omp >> $GITHUB_ENV

- if: startsWith(matrix.platform, 'ubuntu-')
- if: startsWith(matrix.platform, 'ubuntu-') && matrix.test-suite == 'multi-process_a'
run: |
sudo apt-get update
sudo apt-get install python3-paraview
- if: startsWith(matrix.platform, 'macos-')
sudo apt-get install libegl1 libopengl0 ghostscript
wget -nv "https://paraview.org/paraview-downloads/download.php?submit=Download&version=v5.13&type=binary&os=Linux&downloadFile=ParaView-5.13.1-egl-MPI-Linux-Python3.10-x86_64.tar.gz" -O paraview.tar.gz
tar xzf paraview.tar.gz
echo `pwd`/`dirname ParaView*/bin/pvpython` >> $GITHUB_PATH
- if: startsWith(matrix.platform, 'macos-') && matrix.test-suite == 'multi-process_a'
run: |
brew install --cask paraview
echo `dirname /Applications/ParaView-*.app/Contents/bin/pvpython | head -1` >> $GITHUB_PATH
- if: matrix.platform != 'windows-latest'
run: pvpython --version
- if: startsWith(matrix.platform, 'windows-') && matrix.test-suite == 'multi-process_a'
run: |
curl "https://www.paraview.org/paraview-downloads/download.php?submit=Download&version=v5.13&type=binary&os=Windows&downloadFile=ParaView-5.13.1-Windows-Python3.10-msvc2017-AMD64.msi" -o paraview.msi
msiexec //i paraview.msi //quiet //qn //norestart
echo "C:\\Program Files\\ParaView 5.13.1\\bin\\" >> $GITHUB_PATH
- if: matrix.test-suite == 'multi-process_a'
run: |
pvpython --version
pvpython -c "from paraview import simple"
- env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down Expand Up @@ -331,7 +343,7 @@ jobs:
with:
pattern: dist-*
merge-multiple: true
path: dist
path: dist
- run: python -m pip install $PIP_INSTALL_ARGS dist/*.whl
- run: python -c "import PySDM; print(PySDM.__version__)"
- run: python -c "import PySDM_examples; print(PySDM_examples.__version__)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
"from PySDM import products as PySDM_products\n",
"import subprocess\n",
"import glob\n",
"import os\n",
"import platform"
]
},
Expand Down Expand Up @@ -145,7 +144,7 @@
"colorbar_attr.TitleFontSize = 30\n",
"colorbar_attr.LabelFontSize = 30\n",
"colorbar_attr.Visibility = True\n",
"colorbar_attr.WindowLocation = 'AnyLocation'\n",
"colorbar_attr.WindowLocation = 'Any Location'\n",
"colorbar_attr.Position = [.1, .333]\n",
"colorbar_attr.RangeLabelFormat = '%g'\n",
"\n",
Expand Down Expand Up @@ -178,7 +177,7 @@
"colorbar_prod.LabelFontSize = 30\n",
"colorbar_prod.Visibility = True\n",
"colorbar_prod.Position = [.92, .333]\n",
"colorbar_prod.WindowLocation = 'AnyLocation'\n",
"colorbar_prod.WindowLocation = 'Any Location'\n",
"colorbar_prod.RangeLabelFormat = '%g'\n",
"\n",
"# compose the scene\n",
Expand All @@ -196,17 +195,16 @@
"pvs.SaveAnimation('output/anim.ogv', view, FrameRate=10)\n",
"\n",
"# save animation frame as pdfs\n",
"exporters = pvs.servermanager.createModule('exporters')\n",
"exporter = exporters.GL2PSRenderViewExporterPDF()\n",
"exporter.Rasterize3Dgeometry = False\n",
"exporter.GL2PSdepthsortmethod = 'BSP sorting (slow, best)'\n",
"for t in reader_prod.TimestepValues:\n",
" view.ViewTime = t\n",
" for reader in (reader_prod, reader_attr):\n",
" reader.UpdatePipeline(t)\n",
" exporter.SetView(view)\n",
" exporter.FileName = f'output/anim_frame_{t}.pdf'\n",
" exporter.Write()"
" reader.UpdatePipeline(t) \n",
" pvs.ExportView(\n",
" filename=f'output/anim_frame_{t}.pdf',\n",
" view=view,\n",
" Rasterize3Dgeometry= False,\n",
" GL2PSdepthsortmethod= 'BSP sorting (slow, best)',\n",
" )"
]
},
{
Expand All @@ -223,10 +221,7 @@
"id": "79477d3d",
"metadata": {},
"outputs": [],
"source": [
"if not ('CI' in os.environ and platform.system() == 'Windows'):\n",
" subprocess.check_output(['pvpython', 'pvscript.py'], shell=True)"
]
"source": "subprocess.run(['pvpython', '--force-offscreen-rendering', 'pvscript.py'], check=platform.system() != 'Windows')"
},
{
"cell_type": "markdown",
Expand All @@ -243,9 +238,10 @@
"metadata": {},
"outputs": [],
"source": [
"for file in glob.glob('output/anim_frame_*.pdf'):\n",
" subprocess.run(['ps2pdf', file, file+'_'], capture_output=True, check=True)\n",
" subprocess.call(['mv', file+'_', file])"
"if platform.system() != 'Windows':\n",
" for file in glob.glob('output/anim_frame_*.pdf'):\n",
" subprocess.run(['ps2pdf', file, file+'_'], capture_output=True, check=True)\n",
" subprocess.run(['mv', file+'_', file], check=True)"
]
},
{
Expand Down

0 comments on commit 48ea037

Please sign in to comment.