Skip to content

Commit

Permalink
fix: Allow mock butler in addtional butler calls
Browse files Browse the repository at this point in the history
fix: Allow alias paths in condor submit files
  • Loading branch information
tcjennings committed Jan 30, 2025
1 parent b0bf7e0 commit fe7859e
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
./.github/workflows/rebase_checker.yaml

lint:
runs-on: ubuntu-24.04-arm
runs-on: ubuntu-24.04
needs:
- rebase-checker
steps:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/rebase_checker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ name: Rebase Checker

"on":
workflow_call:
pull_request:

jobs:
call-workflow:
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ repos:

- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.9.1
rev: v0.9.2
hooks:
- id: ruff
- id: ruff
Expand Down
5 changes: 5 additions & 0 deletions src/lsst/cmservice/common/butler.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from lsst.daf.butler import Butler, MissingCollectionError

from ..common import errors
from ..config import config


async def remove_run_collections(
Expand All @@ -28,6 +29,7 @@ async def remove_run_collections(
fake_reset: bool
Allow for missing butler
"""
fake_reset = fake_reset or config.butler.mock
try:
butler_f = partial(
Butler.from_config,
Expand Down Expand Up @@ -68,6 +70,7 @@ async def remove_non_run_collections(
fake_reset: bool
Allow for missing butler
"""
fake_reset = fake_reset or config.butler.mock
try:
butler_f = partial(
Butler.from_config,
Expand Down Expand Up @@ -109,6 +112,7 @@ async def remove_collection_from_chain(
fake_reset: bool
Allow for missing butler
"""
fake_reset = fake_reset or config.butler.mock
if fake_reset:
return
raise NotImplementedError
Expand Down Expand Up @@ -137,6 +141,7 @@ async def remove_datasets_from_collections(
fake_reset: bool
Allow for missing butler
"""
fake_reset = fake_reset or config.butler.mock
if fake_reset:
return
raise NotImplementedError
27 changes: 17 additions & 10 deletions src/lsst/cmservice/common/htcondor.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,26 +21,26 @@


async def write_htcondor_script(
htcondor_script_path: str | Path,
htcondor_log: str | Path,
script_url: str | Path,
log_url: str | Path,
htcondor_script_path: Path,
htcondor_log: Path,
script_url: Path,
log_url: Path,
**kwargs: Any,
) -> Path:
"""Write a submit wrapper script for htcondor
Parameters
----------
htcondor_script_path: str | anyio.Path
htcondor_script_path: anyio.Path
Path for the wrapper file written by this function
htcondor_log: str | anyio.Path
htcondor_log: anyio.Path
Path for the wrapper log
script_url: str | anyio.Path
script_url: anyio.Path
Script to submit
log_url: str | anyio.Path
log_url: anyio.Path
Location of job log file to write
Returns
Expand All @@ -58,6 +58,13 @@ async def write_htcondor_script(
)
options.update(**kwargs)

if config.htcondor.alias_path is not None:
_alias = Path(config.htcondor.alias_path)
# FIXME can we use the actual campaign prod_area here
script_url = _alias / script_url.relative_to("/output")
htcondor_log = _alias / htcondor_log.relative_to("/output")
log_url = _alias / log_url.relative_to("/output")

htcondor_script_contents = [
f"executable = {script_url}",
f"log = {htcondor_log}",
Expand All @@ -66,7 +73,7 @@ async def write_htcondor_script(
]
for key, val in options.items():
htcondor_script_contents.append(f"{key} = {val}")
htcondor_script_contents.append("queue")
htcondor_script_contents.append("queue\n")

await Path(htcondor_script_path).write_text("\n".join(htcondor_script_contents))
return Path(htcondor_log)
Expand All @@ -93,7 +100,7 @@ async def submit_htcondor_job(

try:
async with await open_process(
[config.htcondor.condor_submit_bin, htcondor_script_path]
[config.htcondor.condor_submit_bin, "-disable", "-file", htcondor_script_path]
) as condor_submit:
if await condor_submit.wait() != 0: # pragma: no cover
assert condor_submit.stderr
Expand Down
6 changes: 6 additions & 0 deletions src/lsst/cmservice/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,12 @@ class HTCondorConfiguration(BaseModel):
description="...", default=True, serialization_alias="_condor_DAGMAN_MANAGER_JOB_APPEND_GETENV"
)

alias_path: str | None = Field(
description="The alias path to use in htcondor submission files instead of a campaign's prod_area",
default=None,
exclude=True,
)


class SlurmConfiguration(BaseModel):
"""Configuration settings for slurm client operations.
Expand Down
8 changes: 4 additions & 4 deletions tests/common/test_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,10 @@ async def test_common_htcondor() -> None:
"""Test common.htcondor functions"""

_ht_condor_log = await write_htcondor_script(
"htcondor_temp.sh",
"htcondor_temp.log",
"script_temp.sh",
"script_temp.log",
Path("htcondor_temp.sh"),
Path("htcondor_temp.log"),
Path("script_temp.sh"),
Path("script_temp.log"),
)

with pytest.raises(CMHTCondorSubmitError):
Expand Down

0 comments on commit fe7859e

Please sign in to comment.