Skip to content

Commit 9c511a3

Browse files
authored
HTCondor v25 Fix (#44)
1 parent d6173a3 commit 9c511a3

File tree

6 files changed

+64
-22
lines changed

6 files changed

+64
-22
lines changed

CHANGELOG.md

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# `pylhc-submitter` Changelog
22

3+
## Version 2.0.5
4+
5+
- Implemented compatibility with the recently released `htcondor 25.0` which brought breaking changes.
6+
- Fixed the display of the quick stats summary message shown right after submitting to HTCondor.
7+
38
## Version 2.0.4
49

510
- Fixed use of `np.NaN` to ensure compatibility with `numpy 2.0`.
@@ -21,12 +26,12 @@
2126
- General code cleanup/refactoring/documentation:
2227
- Partly breaks backward compatibility, if individual methods of the `job_submitter`-functionality have been used.
2328
- Does not affect any setups simply calling the `main()` function of `job_submitter.py` or calling the `job_submitter` as a module.
24-
- Apart from some fixed imports, following the new structure, the `autosix` module has been untouched.
29+
- Apart from some fixed imports, following the new structure, the `autosix` module has been untouched.
2530

2631

2732
- New Feature of `job_submitter`:
28-
- `output_destination` input parameter, which sets an output directory in which the folder-stucture
29-
for the jobs will be replicated and the job's `job_output_dir` will be copied into "manually" at the end of the job,
33+
- `output_destination` input parameter, which sets an output directory in which the folder-stucture
34+
for the jobs will be replicated and the job's `job_output_dir` will be copied into "manually" at the end of the job,
3035
instead of having the directory transferred back to the `working directory` by htcondor.
3136

3237
## Version 1.1.1
@@ -38,15 +43,15 @@
3843
This release adds some changes the `autosix` module:
3944

4045
- New Features:
41-
- Added `sixdesk_directory` option, which allows the user to choose their own
46+
- Added `sixdesk_directory` option, which allows the user to choose their own
4247
sixdesk environment (default is PRO on AFS).
4348
- Added `max_materialize` option, which allows the user to specify the amount of jobs that
4449
materialize at once per SixDesk Workspace (i.e. one realization in the `replace_dict`).
4550
This enables the user to send more jobs to HTCondor than are allowed within their user limit.
4651
See the HTCondor API for details. This option requires writing rights in the `sixdesk_directory`.
47-
- Allow `ENERGY` and `EMITTANCE` to be set via `replace_dict`, which are then
52+
- Allow `ENERGY` and `EMITTANCE` to be set via `replace_dict`, which are then
4853
passed to the `sixdeskenv` (`GAMMA` is calculated from the `EMITTANCE` automatically).
49-
54+
5055
- Changes:
5156
- Big object-oriented restructuring of the Stages and increased use of Dataclasses.
5257
- Some other small changes to improve readablity.

pylhc_submitter/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
__title__ = "pylhc_submitter"
1212
__description__ = "pylhc-submitter contains scripts to simplify the creation and submission of jobs to HTCondor at CERN"
1313
__url__ = "https://github.com/pylhc/submitter"
14-
__version__ = "2.0.4"
14+
__version__ = "2.0.5"
1515
__author__ = "pylhc"
1616
__author_email__ = "pylhc@github.com"
1717
__license__ = "MIT"

pylhc_submitter/job_submitter.py

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -181,16 +181,29 @@
181181

182182
LOG = logging.getLogger(__name__)
183183

184+
# ------------------------------------------------------------------ #
185+
# Importing htcondor is tricky because they broke the API in v25 LTS #
186+
# ------------------------------------------------------------------ #
184187

185188
try:
186-
import htcondor
189+
# First, try HTCondor 25.x API
190+
import htcondor2 as htcondor
191+
192+
LOG.debug("Using htcondor2 bindings (HTCondor 25.x+).")
187193
except ImportError:
188-
platform = "macOS" if sys.platform == "darwin" else "windows"
189-
LOG.warning(
190-
f"htcondor python bindings are linux-only. You can still use job_submitter on {platform}, "
191-
"but only for local runs."
192-
)
193-
htcondor = None
194+
try:
195+
# Fallback to previous LTS HTCondor API
196+
import htcondor
197+
198+
LOG.debug("Using htcondor bindings (HTCondor <25).")
199+
except ImportError:
200+
# Neither available: must be macOS or Windows
201+
platform = "macOS" if sys.platform == "darwin" else "windows"
202+
LOG.warning(
203+
f"htcondor python bindings are linux-only. You can still use job_submitter on {platform}, "
204+
"but only for local runs."
205+
)
206+
htcondor = None
194207

195208

196209
def get_params():

pylhc_submitter/submitter/htc_utils.py

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,24 @@
4141
from pylhc_submitter.submitter.mask import is_mask_file
4242
from pylhc_submitter.utils.environment import on_windows
4343

44-
try:
45-
import htcondor # noqa: N801
46-
except ImportError: # will be handled by job_submitter
47-
48-
class htcondor: # noqa: N801
49-
"""Dummy HTCondor module. To satisfy the typing."""
44+
# ------------------------------------------------------------------ #
45+
# Importing htcondor is tricky because they broke the API in v25 LTS #
46+
# ------------------------------------------------------------------ #
5047

51-
Submit: Any = None
48+
try:
49+
# First, try HTCondor 25.x API
50+
import htcondor2 as htcondor # noqa: N801
51+
except ImportError:
52+
try:
53+
# Fallback to previous LTS HTCondor API
54+
import htcondor # noqa: N801
55+
except ImportError: # will be handled by job_submitter
56+
# Neither API is available – define dummy stubs for typing
57+
58+
class htcondor: # noqa: N801
59+
"""Dummy HTCondor module to satisfy typing."""
60+
61+
Submit: Any = None
5262

5363

5464
if TYPE_CHECKING:

pylhc_submitter/submitter/iotools.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ def get_server_from_uri(path: Path | str) -> str:
247247
def print_stats(new_jobs: JobNamesType, finished_jobs: JobNamesType):
248248
"""Print some quick statistics."""
249249
text = [
250-
"\n------------- QUICK STATS ----------------"
250+
"\n------------- QUICK STATS ----------------",
251251
f"Jobs total:{len(new_jobs) + len(finished_jobs):d}",
252252
f"Jobs to run: {len(new_jobs):d}",
253253
f"Jobs already finished: {len(finished_jobs):d}",

pyproject.toml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,24 @@ changelog = "https://github.com/pylhc/submitter/blob/master/CHANGELOG.md"
7979
markers = [
8080
"cern_network: tests that require access to afs or the technical network",
8181
]
82+
83+
addopts = [
84+
"--import-mode=importlib",
85+
]
86+
8287
# Helpful for pytest-debugging (leave commented out on commit):
8388
# log_cli=true
8489
# log_level=DEBUG
8590

91+
[tool.coverage.run]
92+
relative_files = true
93+
94+
[tool.coverage.report]
95+
exclude_also = [
96+
"if TYPE_CHECKING:", # do not count type checking imports (ignored at runtime) for coverage
97+
"except ImportError:", # do not count missing optional dependencies set to None, we monkeypatch and test that
98+
]
99+
86100
# ----- Dev Tools Configuration ----- #
87101

88102
[tool.ruff]

0 commit comments

Comments
 (0)