Skip to content

Commit 79f4de0

Browse files
authored
Do not transfer of output files if destination is given (#38)
1 parent 2be7eeb commit 79f4de0

File tree

7 files changed

+32
-13
lines changed

7 files changed

+32
-13
lines changed

CHANGELOG.md

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

3+
## Version 2.0.3
4+
5+
- Fixing `job_submitter`: Do not transfer any output files, when the `output_destination` is given.
6+
37
## Version 2.0.2
48

59
- Fixing `job_submitter`: Discovers more invalid URIs.

pylhc_submitter/__init__.py

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

pylhc_submitter/constants/htcondor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@
2121
"nextweek", # 1 w
2222
)
2323

24-
NOTIFICATIONS = ("always", "complete", "error", "never")
24+
NOTIFICATIONS = ("always", "complete", "error", "never")

pylhc_submitter/job_submitter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ def check_opts(opt):
394394

395395
creation = CreationOpts(**{f.name: opt[f.name] for f in fields(CreationOpts)})
396396
runner = RunnerOpts(**{f.name: opt[f.name] for f in fields(RunnerOpts)})
397-
runner.output_dir = None if opt.output_destination else opt.output_dir
397+
runner.output_dir = '""' if opt.output_destination else opt.output_dir # empty string stops htc transfer of files
398398
return creation, runner
399399

400400

pylhc_submitter/submitter/htc_utils.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ def create_multijob_for_bashfiles(job_df: DataFrame, **kwargs) -> str:
107107
108108
Keyword Args:
109109
output_dir (str): output directory that will be transferred. Defaults to ``None``.
110-
duration (str): max duration of the job. Needs to be one of the ``HTCondor`` Jobflavours.
110+
jobflavour (str): max duration of the job. Needs to be one of the ``HTCondor`` Jobflavours.
111111
Defaults to ``workday``.
112112
group (str): force use of accounting group. Defaults to ``None``.
113113
retries (int): maximum amount of retries. Default to ``3``.
@@ -257,8 +257,8 @@ def map_kwargs(add_dict: Dict[str, Any]) -> Dict[str, Any]:
257257

258258
# Predefined mappings
259259
htc_map = { # name: mapped_name, choices, default
260-
"duration": ("+JobFlavour", JOBFLAVOURS, "workday"),
261-
"output_dir": ("transfer_output_files", None, None),
260+
"jobflavour": ("+JobFlavour", JOBFLAVOURS, "workday"),
261+
"output_dir": ("transfer_output_files", None, '""'),
262262
"accounting_group": ("+AccountingGroup", None, None),
263263
"max_retries": ("max_retries", None, 3),
264264
"notification": ("notification", NOTIFICATIONS, "error"),

pylhc_submitter/submitter/runners.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import logging
88
import multiprocessing
99
import subprocess
10-
from dataclasses import dataclass
10+
from dataclasses import dataclass, field
1111
from pathlib import Path
1212
from typing import Any, Dict, Optional, Tuple
1313

@@ -31,7 +31,7 @@ class RunnerOpts:
3131
output_dir: Optional[str] = None # Name of the output directory, where jobs store data
3232
ssh: Optional[str] = None # SSH command
3333
dryrun: Optional[bool] = False # Perform only a dry-run, i.e. do all but submit to HTC
34-
htc_arguments: Optional[Dict[str, Any]] = None # Arguments to pass on to htc as keywords
34+
htc_arguments: Optional[Dict[str, Any]] = field(default_factory=dict) # Arguments to pass on to htc as keywords
3535
run_local: Optional[bool] = False # Run jobs locally
3636
num_processes: Optional[int] = 4 # Number of processes to run in parallel (locally)
3737

@@ -83,7 +83,7 @@ def run_htc(job_df: tfs.TfsDataFrame, opt: RunnerOpts) -> None:
8383
subfile = htc_utils.make_subfile(
8484
opt.working_directory, job_df,
8585
output_dir=opt.output_dir,
86-
duration=opt.jobflavour,
86+
jobflavour=opt.jobflavour,
8787
**opt.htc_arguments
8888
)
8989

tests/unit/test_job_submitter.py

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import pytest
88

99
from pylhc_submitter.job_submitter import main as job_submit
10-
from pylhc_submitter.submitter.iotools import get_server_from_uri, is_eos_uri, uri_to_path
10+
from pylhc_submitter.submitter.iotools import uri_to_path
1111
from pylhc_submitter.utils.environment import on_linux, on_windows
1212

1313
SUBFILE = "queuehtc.sub"
@@ -41,7 +41,6 @@ def test_output_directory(tmp_path):
4141
)
4242
setup.create_mask()
4343
job_submit(**asdict(setup))
44-
_test_output(setup)
4544

4645

4746
def test_detects_wrong_uri(tmp_path):
@@ -62,7 +61,6 @@ def test_detects_wrong_uri(tmp_path):
6261
assert "EOS-URI" in str(e)
6362

6463

65-
6664
@run_only_on_linux
6765
def test_job_creation_and_localrun_with_multiline_maskstring(tmp_path):
6866
""" Tests that the jobs are created and can be run locally from a multiline mask-string. """
@@ -84,6 +82,23 @@ def test_job_creation_and_dryrun(tmp_path, maskfile):
8482
_test_output(setup, post_run=False)
8583

8684

85+
@run_only_on_linux
86+
@pytest.mark.parametrize("maskfile", [True, False])
87+
@pytest.mark.parametrize("destination", [True, False])
88+
def test_more_subfile_content(tmp_path, maskfile, destination):
89+
""" Tests that the jobs are created as dry-run from mask-file and from mask-string. """
90+
setup = InputParameters(
91+
jobflavour="espresso", # change from default
92+
working_directory=tmp_path,
93+
dryrun=True,
94+
output_destination= tmp_path / "my_new_output" / "long_path" if destination else None,
95+
job_output_dir="MyOutputDataHere", # change from default
96+
)
97+
setup.create_mask(as_file=maskfile)
98+
job_submit(**asdict(setup))
99+
_test_subfile_content(setup)
100+
101+
87102
@run_only_on_linux
88103
@pytest.mark.parametrize("maskfile", [True, False])
89104
def test_find_errorneous_percentage_signs(tmp_path, maskfile):
@@ -243,7 +258,7 @@ def _test_subfile_content(setup: InputParameters):
243258
if setup.output_destination is None:
244259
assert filecontents["transfer_output_files"] == setup.job_output_dir
245260
else:
246-
assert "transfer_output_files" not in filecontents
261+
assert filecontents["transfer_output_files"] == '""'
247262

248263
for key in setup.htc_arguments.keys():
249264
assert filecontents[key] == setup.htc_arguments[key]

0 commit comments

Comments
 (0)