Skip to content

129 replace psutil - #174

Merged
sy-cui merged 5 commits into
mainfrom
129-replace-psutil
Apr 3, 2026
Merged

129 replace psutil#174
sy-cui merged 5 commits into
mainfrom
129-replace-psutil

Conversation

@sy-cui

@sy-cui sy-cui commented Apr 3, 2026

Copy link
Copy Markdown
Collaborator

Replace psutil.cpu_count(logical=False) with a pytest fixture which invokes os.cpu_count() and fall back to 1. This allows us to remove psutil from the dependency list.

One caveat here is that the logical=False flag allows psutil to return the physical core count, while os.cpu_count and may include hyperthreads. However, this is not a big issue because most uses case have users prescribe a thread count. Furthermore, psutil is so far only used in test cases. Therefore we can safely make this change.

@sy-cui sy-cui self-assigned this Apr 3, 2026
@sy-cui sy-cui added prio:low Low priority refactor Refactor existing codebase dependencies Pull requests that update a dependency file labels Apr 3, 2026
@sy-cui
sy-cui requested a review from Copilot April 3, 2026 05:31

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Removes the psutil dependency by switching test-time CPU thread sizing from psutil.cpu_count(logical=False) to the standard library’s multiprocessing.cpu_count().

Changes:

  • Drop psutil from the test dependency set and lockfile.
  • Update numeric/FFT-related tests to use multiprocessing.cpu_count() for num_threads.
  • Remove psutil imports across the touched tests.

Reviewed changes

Copilot reviewed 31 out of 32 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
uv.lock Removes the locked psutil package entry and references from test dependency groups.
pyproject.toml Removes psutil from the tests dependency extra/group.
tests/test_numeric/test_immersed_boundary_ops/test_virtual_boundary_forcing.py Replaces psutil.cpu_count(logical=False) with multiprocessing.cpu_count() and drops psutil import.
tests/test_numeric/test_eulerian_grid_ops/test_stencil_ops_3d/test_vorticity_stretching_timestep_3d.py Replaces psutil CPU counting with multiprocessing.cpu_count() and drops psutil import.
tests/test_numeric/test_eulerian_grid_ops/test_stencil_ops_3d/test_vorticity_stretching_flux_3d.py Replaces psutil CPU counting with multiprocessing.cpu_count() and drops psutil import.
tests/test_numeric/test_eulerian_grid_ops/test_stencil_ops_3d/test_update_vorticity_from_velocity_forcing_3d.py Replaces psutil CPU counting with multiprocessing.cpu_count() and drops psutil import.
tests/test_numeric/test_eulerian_grid_ops/test_stencil_ops_3d/test_penalise_field_boundary_3d.py Replaces psutil CPU counting with multiprocessing.cpu_count() and drops psutil import.
tests/test_numeric/test_eulerian_grid_ops/test_stencil_ops_3d/test_laplacian_filter_3d.py Replaces psutil CPU counting with multiprocessing.cpu_count() and drops psutil import.
tests/test_numeric/test_eulerian_grid_ops/test_stencil_ops_3d/test_elementwise_ops_3d.py Replaces psutil CPU counting with multiprocessing.cpu_count() and drops psutil import.
tests/test_numeric/test_eulerian_grid_ops/test_stencil_ops_3d/test_divergence_3d.py Replaces psutil CPU counting with multiprocessing.cpu_count() and drops psutil import.
tests/test_numeric/test_eulerian_grid_ops/test_stencil_ops_3d/test_diffusion_timestep_3d.py Replaces psutil CPU counting with multiprocessing.cpu_count() and drops psutil import.
tests/test_numeric/test_eulerian_grid_ops/test_stencil_ops_3d/test_diffusion_flux_3d.py Replaces psutil CPU counting with multiprocessing.cpu_count() and drops psutil import.
tests/test_numeric/test_eulerian_grid_ops/test_stencil_ops_3d/test_curl_3d.py Replaces psutil CPU counting with multiprocessing.cpu_count() and drops psutil import.
tests/test_numeric/test_eulerian_grid_ops/test_stencil_ops_3d/test_char_func_from_level_set_3d.py Replaces psutil CPU counting with multiprocessing.cpu_count() and drops psutil import.
tests/test_numeric/test_eulerian_grid_ops/test_stencil_ops_3d/test_brinkmann_penalise_3d.py Replaces psutil CPU counting with multiprocessing.cpu_count() and drops psutil import.
tests/test_numeric/test_eulerian_grid_ops/test_stencil_ops_3d/test_advection_timestep_3d.py Replaces psutil CPU counting with multiprocessing.cpu_count() and drops psutil import.
tests/test_numeric/test_eulerian_grid_ops/test_stencil_ops_3d/test_advection_flux_3d.py Replaces psutil CPU counting with multiprocessing.cpu_count() and drops psutil import.
tests/test_numeric/test_eulerian_grid_ops/test_stencil_ops_2d/test_update_vorticity_from_velocity_forcing_2d.py Replaces psutil CPU counting with multiprocessing.cpu_count() and drops psutil import.
tests/test_numeric/test_eulerian_grid_ops/test_stencil_ops_2d/test_penalise_field_boundary_2d.py Replaces psutil CPU counting with multiprocessing.cpu_count() and drops psutil import.
tests/test_numeric/test_eulerian_grid_ops/test_stencil_ops_2d/test_outplane_field_curl_2d.py Replaces psutil CPU counting with multiprocessing.cpu_count() and drops psutil import.
tests/test_numeric/test_eulerian_grid_ops/test_stencil_ops_2d/test_inplane_field_curl_2d.py Replaces psutil CPU counting with multiprocessing.cpu_count() and drops psutil import.
tests/test_numeric/test_eulerian_grid_ops/test_stencil_ops_2d/test_elementwise_ops_2d.py Replaces psutil CPU counting with multiprocessing.cpu_count() and drops psutil import.
tests/test_numeric/test_eulerian_grid_ops/test_stencil_ops_2d/test_diffusion_timestep_2d.py Replaces psutil CPU counting with multiprocessing.cpu_count() and drops psutil import.
tests/test_numeric/test_eulerian_grid_ops/test_stencil_ops_2d/test_diffusion_flux_2d.py Replaces psutil CPU counting with multiprocessing.cpu_count() and drops psutil import.
tests/test_numeric/test_eulerian_grid_ops/test_stencil_ops_2d/test_char_func_from_level_set_2d.py Replaces psutil CPU counting with multiprocessing.cpu_count() and drops psutil import.
tests/test_numeric/test_eulerian_grid_ops/test_stencil_ops_2d/test_brinkmann_penalise_2d.py Replaces psutil CPU counting with multiprocessing.cpu_count() and drops psutil import.
tests/test_numeric/test_eulerian_grid_ops/test_stencil_ops_2d/test_advection_timestep_2d.py Replaces psutil CPU counting with multiprocessing.cpu_count() and drops psutil import.
tests/test_numeric/test_eulerian_grid_ops/test_stencil_ops_2d/test_advection_flux_2d.py Replaces psutil CPU counting with multiprocessing.cpu_count() and drops psutil import.
tests/test_numeric/test_eulerian_grid_ops/test_poisson_solver_3d/test_unbounded_poisson_solver_3d.py Replaces psutil CPU counting with multiprocessing.cpu_count() and drops psutil import.
tests/test_numeric/test_eulerian_grid_ops/test_poisson_solver_3d/test_fft_kernel_3d.py Replaces psutil CPU counting with multiprocessing.cpu_count() and drops psutil import.
tests/test_numeric/test_eulerian_grid_ops/test_poisson_solver_2d/test_unbounded_poisson_solver_2d.py Replaces psutil CPU counting with multiprocessing.cpu_count() and drops psutil import.
tests/test_numeric/test_eulerian_grid_ops/test_poisson_solver_2d/test_fft_kernel_2d.py Replaces psutil CPU counting with multiprocessing.cpu_count() and drops psutil import.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/test_numeric/test_immersed_boundary_ops/test_virtual_boundary_forcing.py Outdated

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 32 out of 33 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/conftest.py Outdated
Comment thread tests/conftest.py Outdated

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 32 out of 33 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/conftest.py Outdated
@sy-cui
sy-cui merged commit 9376483 into main Apr 3, 2026
4 checks passed
@sy-cui
sy-cui deleted the 129-replace-psutil branch April 3, 2026 17:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Pull requests that update a dependency file prio:low Low priority refactor Refactor existing codebase

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants