Skip to content

Commit

Permalink
Remove redundant global args from remote commands.
Browse files Browse the repository at this point in the history
  • Loading branch information
riga committed May 8, 2024
1 parent 62d4576 commit ab5bb48
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 10 deletions.
2 changes: 1 addition & 1 deletion law/contrib/arc/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def create_job_file(self, job_num, branches):
proxy_cmd = ProxyCommand(
task.as_branch(branches[0]),
exclude_task_args=exclude_args,
exclude_global_args=["workers", "local-scheduler"],
exclude_global_args=["workers", "local-scheduler", task.task_family + "-*"],
)
if task.arc_use_local_scheduler():
proxy_cmd.add_arg("--local-scheduler", "True", overwrite=True)
Expand Down
2 changes: 1 addition & 1 deletion law/contrib/cms/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def create_job_file(self, submit_jobs):
proxy_cmd = ProxyCommand(
task.as_branch(),
exclude_task_args=exclude_args,
exclude_global_args=["workers"],
exclude_global_args=["workers", task.task_family + "-*"],
)
proxy_cmd.add_arg("--local-scheduler", "True", overwrite=True)
for key, value in OrderedDict(task.crab_cmdline_args()).items():
Expand Down
2 changes: 1 addition & 1 deletion law/contrib/glite/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def create_job_file(self, job_num, branches):
proxy_cmd = ProxyCommand(
task.as_branch(branches[0]),
exclude_task_args=exclude_args,
exclude_global_args=["workers", "local-scheduler"],
exclude_global_args=["workers", "local-scheduler", task.task_family + "-*"],
)
if task.glite_use_local_scheduler():
proxy_cmd.add_arg("--local-scheduler", "True", overwrite=True)
Expand Down
2 changes: 1 addition & 1 deletion law/contrib/htcondor/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def create_job_file(self, job_num, branches):
proxy_cmd = ProxyCommand(
task.as_branch(branches[0]),
exclude_task_args=exclude_args,
exclude_global_args=["workers", "local-scheduler"],
exclude_global_args=["workers", "local-scheduler", task.task_family + "-*"],
)
if task.htcondor_use_local_scheduler():
proxy_cmd.add_arg("--local-scheduler", "True", overwrite=True)
Expand Down
2 changes: 1 addition & 1 deletion law/contrib/lsf/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def create_job_file(self, job_num, branches):
proxy_cmd = ProxyCommand(
task.as_branch(branches[0]),
exclude_task_args=exclude_args,
exclude_global_args=["workers", "local-scheduler"],
exclude_global_args=["workers", "local-scheduler", task.task_family + "-*"],
)
if task.lsf_use_local_scheduler():
proxy_cmd.add_arg("--local-scheduler", "True", overwrite=True)
Expand Down
2 changes: 1 addition & 1 deletion law/contrib/slurm/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def create_job_file(self, job_num, branches):
proxy_cmd = ProxyCommand(
task.as_branch(branches[0]),
exclude_task_args=exclude_args,
exclude_global_args=["workers", "local-scheduler"],
exclude_global_args=["workers", "local-scheduler", task.task_family + "-*"],
)
if task.slurm_use_local_scheduler():
proxy_cmd.add_arg("--local-scheduler", "True", overwrite=True)
Expand Down
10 changes: 6 additions & 4 deletions law/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import luigi

from law.logger import get_logger
from law.util import multi_match


logger = get_logger(__name__)
Expand Down Expand Up @@ -152,10 +153,11 @@ def global_cmdline_args(exclude=None):
if exclude:
args = OrderedDict(args)

for key in exclude:
if not key.startswith("--"):
key = "--" + key.lstrip("-")
args.pop(key, None)
# treat arguments in exclude as patterns
_exclude = ["--" + pattern.lstrip("-") for pattern in exclude]
for arg in list(args.keys()):
if multi_match(arg, _exclude, mode=any):
args.pop(arg)

return args

Expand Down

0 comments on commit ab5bb48

Please sign in to comment.