Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ffmpeg version retrieval and update environment information #651

Merged
merged 1 commit into from
Feb 1, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions pde/tools/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import contextlib
import importlib
import re
import subprocess as sp
import sys
import warnings
from pathlib import Path
Expand Down Expand Up @@ -261,6 +262,22 @@ def packages_from_requirements(requirements_file: Path | str) -> list[str]:
return result


def get_ffmpeg_version() -> str | None:
"""Read version number of ffmpeg program."""
# run ffmpeg to get its version
try:
version_bytes = sp.check_output(["ffmpeg", "-version"])
except:
return None

# extract the version number from the output
version_string = version_bytes.splitlines()[0].decode("utf-8")
match = re.search(r"version\s+([\w\.]+)\s+copyright", version_string, re.IGNORECASE)
if match:
return match.group(1)
return None


def environment() -> dict[str, Any]:
"""Obtain information about the compute environment.

Expand All @@ -282,6 +299,11 @@ def environment() -> dict[str, Any]:
result["python version"] = sys.version
result["platform"] = sys.platform

# add ffmpeg version if available
ffmpeg_version = get_ffmpeg_version()
if ffmpeg_version:
result["ffmpeg version"] = ffmpeg_version

# add the package configuration
result["config"] = config.to_dict()

Expand Down
5 changes: 3 additions & 2 deletions scripts/performance_laplace.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,11 @@ def custom_laplace_2d(shape, periodic, dx=1):


def optimized_laplace_2d(bcs):
"""Make an optimized laplace operator
"""Make an optimized laplace operator.

The main optimization is that we expect the input to be a full array containing
virtual boundary points. This avoids memory allocation and a copy of the data."""
virtual boundary points. This avoids memory allocation and a copy of the data.
"""
set_ghost_cells = bcs.make_ghost_cell_setter()
apply_laplace = bcs.grid.make_operator_no_bc("laplace")
shape = bcs.grid.shape
Expand Down
15 changes: 7 additions & 8 deletions scripts/profile_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,15 @@
"""

import sys
from pathlib import Path

sys.path.append("..")
PACKAGE_PATH = Path(__file__).resolve().parents[1]
sys.path.insert(0, str(PACKAGE_PATH))

from pyinstrument import Profiler

profiler = Profiler()
profiler.start()

import pde
from pyinstrument import Profiler

profiler.stop()
with Profiler() as profiler:
import pde

print(profiler.output_text(unicode=True, color=True))
print(profiler.open_in_browser())
Loading