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 6564243 commit dbbbbf5
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 11 deletions.
2 changes: 1 addition & 1 deletion law/contrib/arc/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def create_job_file(
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", f"{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 @@ -108,7 +108,7 @@ def create_job_file_group(
proxy_cmd = ProxyCommand(
task.as_branch(),
exclude_task_args=exclude_args,
exclude_global_args=["workers"],
exclude_global_args=["workers", f"{task.task_family}-*"],
)
proxy_cmd.add_arg("--local-scheduler", "True", overwrite=True)
for key, value in dict(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 @@ -102,7 +102,7 @@ def create_job_file(
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", f"{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 @@ -78,7 +78,7 @@ def create_job_file(
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", f"{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 @@ -78,7 +78,7 @@ def create_job_file(
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", f"{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 @@ -77,7 +77,7 @@ def create_job_file(
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", f"{task.task_family}-*"],
)
if task.slurm_use_local_scheduler():
proxy_cmd.add_arg("--local-scheduler", "True", overwrite=True)
Expand Down
11 changes: 6 additions & 5 deletions law/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import luigi # type: ignore[import-untyped]

from law.logger import get_logger
from law.util import multi_match
from law._types import Sequence, Any


Expand Down Expand Up @@ -159,12 +160,12 @@ def global_cmdline_args(exclude: Sequence[str] | None = None) -> dict[str, str]
global_args = _global_cmdline_args

if exclude:
# create a copy and remove excluded keys
# create a copy and remove excluded keys, which can be patterns
global_args = dict(global_args)
for key in exclude:
if not key.startswith("--"):
key = "--" + key.lstrip("-")
global_args.pop(key, None)
_exclude = ["--" + pattern.lstrip("-") for pattern in exclude]
for arg in list(global_args.keys()):
if multi_match(arg, _exclude, mode=any):
global_args.pop(arg)

return global_args

Expand Down

0 comments on commit dbbbbf5

Please sign in to comment.