Skip to content

Fix mypy type errors in mpi_resources.py#1759

Open
jlnav wants to merge 1 commit into
developfrom
feature/flux_misc
Open

Fix mypy type errors in mpi_resources.py#1759
jlnav wants to merge 1 commit into
developfrom
feature/flux_misc

Conversation

@jlnav

@jlnav jlnav commented Jul 8, 2026

Copy link
Copy Markdown
Member

No description provided.

- get_MPI_variant: return type str -> str | None (function already returned None)
- get_MPI_runner: add explicit str | None parameter and return type annotations
- task_partition: rename local vars to num_procs_int/num_nodes_int/procs_per_node_int
  to satisfy mypy narrowing; add assert guards for None after rassert calls
- get_resources: mark num_procs/num_nodes/procs_per_node params as int | None;
  guard num_procs is not None before comparison; unpack task_partition result via
  named variables with type-narrowing asserts; rename output vars for clarity
- create_machinefile: mark num_procs param as int | None; fix return type annotation;
  use (procs_per_node or 1) to avoid None * str error
- get_resources, create_machinefile, get_hostlist: assert worker_resources is not None
@codecov

codecov Bot commented Jul 8, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 86.66667% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 77.06%. Comparing base (555e85a) to head (47484eb).
⚠️ Report is 5 commits behind head on develop.

Files with missing lines Patch % Lines
libensemble/resources/mpi_resources.py 86.66% 2 Missing and 2 partials ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1759      +/-   ##
===========================================
+ Coverage    77.04%   77.06%   +0.02%     
===========================================
  Files           79       79              
  Lines         8325     8334       +9     
  Branches      1282     1283       +1     
===========================================
+ Hits          6414     6423       +9     
  Misses        1666     1666              
  Partials       245      245              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

with open(machinefile, "w") as f:
for node in node_list[:num_nodes]:
f.write((node + "\n") * procs_per_node)
f.write((node + "\n") * (procs_per_node or 1))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

check this is right. As procs_per_node is not always set by user. Is it filled in at this point. Is this default correct.

num_procs = int(num_procs) if num_procs else None
num_nodes = int(num_nodes) if num_nodes else None
procs_per_node = int(procs_per_node) if procs_per_node else None
num_procs_int: int | None = int(num_procs) if num_procs else None

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

why _int?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants