Skip to content

[Fix] Rename run_time_limit to run_time_max#953

Open
jan-janssen wants to merge 2 commits intomainfrom
run_time_max
Open

[Fix] Rename run_time_limit to run_time_max#953
jan-janssen wants to merge 2 commits intomainfrom
run_time_max

Conversation

@jan-janssen
Copy link
Member

@jan-janssen jan-janssen commented Mar 24, 2026

Primarily for consistency with pysqa.

Summary by CodeRabbit

  • Refactor
    • Renamed the runtime parameter from run_time_limit to run_time_max across executors, spawners, command generation, validation, and docs.
    • Validation and command/submit interfaces now accept run_time_max; resource dictionaries and tests updated accordingly.
    • Behavior unchanged: value still denotes the maximum allowed execution time (seconds) for submitted jobs.
Primarily for consistency with pysqa.
@jan-janssen jan-janssen linked an issue Mar 24, 2026 that may be closed by this pull request
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 24, 2026

📝 Walkthrough

Walkthrough

The pull request renames the resource dictionary key and related parameters from run_time_limit to run_time_max across docs, executors, spawners, command generation, validation, and tests. No runtime control flow or behavior changes were introduced.

Changes

Cohort / File(s) Summary
Documentation
docs/trouble_shooting.md
Updated documentation to reference run_time_max instead of run_time_limit.
Core Executors
src/executorlib/executor/flux.py, src/executorlib/executor/single.py, src/executorlib/executor/slurm.py
Docstrings and default resource dict keys renamed from run_time_limitrun_time_max (no signature changes).
Standalone CLI & Validation
src/executorlib/standalone/command.py, src/executorlib/standalone/validate.py
generate_slurm_command parameter renamed to run_time_max; ResourceDictValidation schema field renamed to run_time_max (signature change for command).
Task Scheduler Spawners
src/executorlib/task_scheduler/file/spawner_pysqa.py, src/executorlib/task_scheduler/interactive/spawner_flux.py, src/executorlib/task_scheduler/interactive/spawner_pysqa.py, src/executorlib/task_scheduler/interactive/spawner_slurm.py
Constructor parameters, instance attributes, and resource-dict lookups updated to use run_time_max instead of run_time_limit; command generation calls wired to new name.
Tests
tests/unit/executor/test_flux_job.py, tests/unit/standalone/test_slurm_command.py, tests/unit/standalone/test_validate.py
Unit tests updated to use run_time_max in inputs and expectations.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • #930 — Renames and wires the runtime resource key (run_time_limit) across executors and spawners; directly related to this rename.
  • #797 — Introduced/moved generate_slurm_command and its usages; relevant due to the signature change to run_time_max.
  • #936 — Touches executor resource handling for the same runtime key; overlaps with this rename.

Poem

🐇 I hopped through code with a carrot and a max,
run_time_limit trimmed—now run_time_max.
Executors, spawners, validators sing,
A tidy key for every scheduling thing.
Hop, hop—consistency bites the flax! 🥕

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 72.73% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely summarizes the main change: renaming run_time_limit to run_time_max across the codebase.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch run_time_max

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov
Copy link

codecov bot commented Mar 24, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.14%. Comparing base (1d13f5c) to head (a16b126).

Additional details and impacted files
@@ Coverage Diff @@ ## main #953 +/- ## ======================================= Coverage 94.14% 94.14% ======================================= Files 39 39 Lines 2082 2082 ======================================= Hits 1960 1960 Misses 122 122 

☔ View full report in Codecov by Sentry.
📢 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.
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
src/executorlib/standalone/validate.py (1)

26-26: Add a deprecation bridge for run_time_limit to avoid abrupt API breakage.

Right now, callers still sending run_time_limit can fail validation or propagate an unrecognized key downstream. Consider normalizing it to run_time_max with a deprecation warning for one transition window.

♻️ Proposed compatibility shim
 import warnings from typing import Optional @@ class ResourceDictValidation(BaseModel): @@ run_time_max: Optional[int] = None @@ def _get_accepted_keys(class_type) -> list[str]: @@ raise TypeError("Unsupported class type for validation") + + +def _normalize_runtime_key(resource_dict: dict) -> None: + if "run_time_limit" in resource_dict and "run_time_max" not in resource_dict: + warnings.warn( + "`run_time_limit` is deprecated; use `run_time_max`.", + stacklevel=2, + ) + resource_dict["run_time_max"] = resource_dict.pop("run_time_limit") @@ def validate_resource_dict(resource_dict: dict) -> None: + _normalize_runtime_key(resource_dict=resource_dict) _ = ResourceDictValidation(**resource_dict) @@ def validate_resource_dict_with_optional_keys(resource_dict: dict) -> None: + _normalize_runtime_key(resource_dict=resource_dict) accepted_keys = _get_accepted_keys(class_type=ResourceDictValidation)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/executorlib/standalone/validate.py` at line 26, Add a short compatibility shim that accepts the legacy key run_time_limit and maps it to the new field run_time_max during validation: in validate.py add a normalization step (before the existing schema/dataclass validation) that checks for run_time_limit in the incoming params dict, if run_time_max is not already set copy run_time_limit -> run_time_max, emit a DeprecationWarning or a logged warning calling warnings.warn("run_time_limit is deprecated; use run_time_max", DeprecationWarning) and then remove run_time_limit from the dict so downstream code only sees run_time_max; place this logic near the existing validation entrypoint that currently defines run_time_max: Optional[int] = None so callers keep working during the transition. 
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed. Nitpick comments: In `@src/executorlib/standalone/validate.py`: - Line 26: Add a short compatibility shim that accepts the legacy key run_time_limit and maps it to the new field run_time_max during validation: in validate.py add a normalization step (before the existing schema/dataclass validation) that checks for run_time_limit in the incoming params dict, if run_time_max is not already set copy run_time_limit -> run_time_max, emit a DeprecationWarning or a logged warning calling warnings.warn("run_time_limit is deprecated; use run_time_max", DeprecationWarning) and then remove run_time_limit from the dict so downstream code only sees run_time_max; place this logic near the existing validation entrypoint that currently defines run_time_max: Optional[int] = None so callers keep working during the transition. 

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: c521fc42-604c-4e10-a37d-1c307eaaf795

📥 Commits

Reviewing files that changed from the base of the PR and between 463c0a3 and 7e5958f.

📒 Files selected for processing (13)
  • docs/trouble_shooting.md
  • src/executorlib/executor/flux.py
  • src/executorlib/executor/single.py
  • src/executorlib/executor/slurm.py
  • src/executorlib/standalone/command.py
  • src/executorlib/standalone/validate.py
  • src/executorlib/task_scheduler/file/spawner_pysqa.py
  • src/executorlib/task_scheduler/interactive/spawner_flux.py
  • src/executorlib/task_scheduler/interactive/spawner_pysqa.py
  • src/executorlib/task_scheduler/interactive/spawner_slurm.py
  • tests/unit/executor/test_flux_job.py
  • tests/unit/standalone/test_slurm_command.py
  • tests/unit/standalone/test_validate.py
@jan-janssen jan-janssen requested a review from pmrv March 24, 2026 07:14
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed. Inline comments: In `@src/executorlib/executor/flux.py`: - Line 420: Add a deprecation shim that detects the old key "run_time_limit" in resource dicts before validation and maps it to the new "run_time_max" while emitting a deprecation warning: modify the code path used by FluxJobExecutor and FluxClusterExecutor to check incoming resource dicts (e.g., inside the place that calls validate_resource_dict_with_optional_keys) for "run_time_limit", log a clear deprecation warning, copy its value to "run_time_max" (if "run_time_max" not already present) and remove "run_time_limit" so the existing validate_resource_dict_with_optional_keys behavior continues to work without silently dropping the limit. 

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: ecf7c9ad-8969-49d2-b9d6-b861fb5b3519

📥 Commits

Reviewing files that changed from the base of the PR and between 7e5958f and a16b126.

📒 Files selected for processing (3)
  • src/executorlib/executor/flux.py
  • src/executorlib/executor/slurm.py
  • src/executorlib/task_scheduler/interactive/spawner_pysqa.py
✅ Files skipped from review due to trivial changes (1)
  • src/executorlib/executor/slurm.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/executorlib/task_scheduler/interactive/spawner_pysqa.py
"openmpi_oversubscribe": openmpi_oversubscribe,
"slurm_cmd_args": [],
"run_time_limit": None,
"run_time_max": None,
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash # Check if there's any deprecation handling for run_time_limit elsewhere in the codebase rg -n 'run_time_limit' --type py # Check if there are migration notes or changelog entries fd -e md -e rst -e txt | xargs rg -l 'run_time_limit\|run_time_max' 2>/dev/null || echo "No migration docs found"

Repository: pyiron/executorlib

Length of output: 85


🏁 Script executed:

# First, let's see the actual lines around 420 in flux.py head -430 src/executorlib/executor/flux.py | tail -30

Repository: pyiron/executorlib

Length of output: 1849


🏁 Script executed:

# Check the validation functions referenced in the comment rg -A 10 'def validate_resource_dict' --type py

Repository: pyiron/executorlib

Length of output: 1986


🏁 Script executed:

# Check if there are any tests that demonstrate the breaking behavior fd -e py -path '*/test*' | xargs rg -l 'run_time' 2>/dev/null

Repository: pyiron/executorlib

Length of output: 833


🏁 Script executed:

# Look for any migration or deprecation related code rg -i 'deprecat|migrat|compat' --type py | head -20

Repository: pyiron/executorlib

Length of output: 2848


🏁 Script executed:

# Check FluxJobExecutor's __init__ around lines 155-165 to see which validation it uses sed -n '140,170p' src/executorlib/executor/flux.py

Repository: pyiron/executorlib

Length of output: 3374


🏁 Script executed:

# Find ResourceDictValidation schema definition rg -B 3 'class ResourceDictValidation' --type py -A 15

Repository: pyiron/executorlib

Length of output: 1351


🏁 Script executed:

# Check if tests exist for run_time_limit behavior with both executors cat tests/unit/executor/test_flux_job.py | head -200

Repository: pyiron/executorlib

Length of output: 6240


Breaking change: users passing run_time_limit will have it silently ignored.

The rename from run_time_limit to run_time_max is a breaking change. Both FluxJobExecutor and FluxClusterExecutor use validate_resource_dict_with_optional_keys, which issues a warning for unrecognized keys but silently filters them out. Existing users passing run_time_limit will see a warning and the key will be ignored—meaning the time limit won't be applied.

Consider adding a deprecation shim that detects run_time_limit, issues a deprecation warning, and maps it to run_time_max for a smoother migration path.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/executorlib/executor/flux.py` at line 420, Add a deprecation shim that detects the old key "run_time_limit" in resource dicts before validation and maps it to the new "run_time_max" while emitting a deprecation warning: modify the code path used by FluxJobExecutor and FluxClusterExecutor to check incoming resource dicts (e.g., inside the place that calls validate_resource_dict_with_optional_keys) for "run_time_limit", log a clear deprecation warning, copy its value to "run_time_max" (if "run_time_max" not already present) and remove "run_time_limit" so the existing validate_resource_dict_with_optional_keys behavior continues to work without silently dropping the limit. 
@pmrv
Copy link

pmrv commented Mar 24, 2026

It seems to work in the sense that using now run_time_max instead of limit gives the same behavior as in #952.

However, when I don't pass it (or actually I left it as limit because I forgot to change it), then the executor just runs directly in the notebook without submitting, which is very strange.

@jan-janssen
Copy link
Member Author

However, when I don't pass it (or actually I left it as limit because I forgot to change it), then the executor just runs directly in the notebook without submitting, which is very strange.

This should not be the case, are you sure it is not just reloading the result from the cache folder?

@pmrv
Copy link

pmrv commented Mar 24, 2026

However, when I don't pass it (or actually I left it as limit because I forgot to change it), then the executor just runs directly in the notebook without submitting, which is very strange.

This should not be the case, are you sure it is not just reloading the result from the cache folder?

I thought I avoided that by renaming the cache folder between runs, but I'll try to set up a clean reproducer. It may well be I mixing something up, since I was trying a few thing on the go.

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

Labels

None yet

2 participants