Skip to content

Commit ed69840

Browse files
committed
bugfix(config): add config.bps.artifact_path
- removes "prod_area" from scope of campaign configuration, set via application config instead.
1 parent 80bf00d commit ed69840

8 files changed

Lines changed: 20 additions & 20 deletions

File tree

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ test: PGPORT=$(shell docker compose port postgresql 5432 | cut -d: -f2)
107107
test: export DB__URL=postgresql://cm-service@localhost:${PGPORT}/cm-service
108108
test: export DB__PASSWORD=INSECURE-PASSWORD
109109
test: export DB__TABLE_SCHEMA=cm_service_test
110+
test: export BPS__ARTIFACT_PATH=$(PWD)/output
110111
test: run-compose
111112
alembic upgrade head
112113
pytest -vvv --asyncio-mode=auto --cov=lsst.cmservice --cov-branch --cov-report=term --cov-report=html ${PYTEST_ARGS}

src/lsst/cmservice/config.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@ class BpsConfiguration(BaseModel):
6060
default=16,
6161
)
6262

63+
artifact_path: str = Field(
64+
description="Filesystem path location for writing artifacts (`prod_area`)",
65+
default="/prod_area",
66+
)
67+
6368

6469
class ButlerConfiguration(BaseModel):
6570
"""Configuration settings for butler client operations.

src/lsst/cmservice/handlers/jobs.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,11 @@ async def _write_script(
7575
await session.refresh(parent, attribute_names=["c_"])
7676
data_dict = await script.data_dict(session)
7777
resolved_cols = await script.resolve_collections(session)
78+
prod_area = os.path.expandvars(config.bps.artifact_path)
7879

7980
# Resolve mandatory data element inputs. All of these values must be
8081
# provided somewhere along the SpecBlock chain.
8182
try:
82-
prod_area = os.path.expandvars(data_dict["prod_area"])
8383
butler_repo = os.path.expandvars(data_dict["butler_repo"])
8484
lsst_version = os.path.expandvars(data_dict.get("lsst_version", "w_latest"))
8585
lsst_distrib_dir = os.path.expandvars(data_dict["lsst_distrib_dir"])
@@ -572,7 +572,7 @@ async def _write_script(
572572
if TYPE_CHECKING:
573573
assert isinstance(parent, Job)
574574
data_dict = await script.data_dict(session)
575-
prod_area = await Path(os.path.expandvars(data_dict["prod_area"])).resolve()
575+
prod_area = await Path(os.path.expandvars(config.bps.artifact_path)).resolve()
576576
resolved_cols = await script.resolve_collections(session)
577577
script_url = await self._set_script_files(session, script, prod_area)
578578
butler_repo = data_dict["butler_repo"]
@@ -623,8 +623,7 @@ async def _do_prepare(
623623
) -> StatusEnum:
624624
if TYPE_CHECKING:
625625
assert isinstance(parent, Job)
626-
data_dict = await script.data_dict(session)
627-
prod_area = await Path(os.path.expandvars(data_dict["prod_area"])).resolve()
626+
prod_area = await Path(os.path.expandvars(config.bps.artifact_path)).resolve()
628627

629628
report_url = parent.metadata_.get("report_url") or (
630629
prod_area / parent.fullname / "manifest_report.yaml"

src/lsst/cmservice/handlers/scripts.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ async def _write_script(
4040
data_dict = await script.data_dict(session)
4141
try:
4242
output_coll = resolved_cols["output"]
43-
script_url = await self._set_script_files(session, script, data_dict["prod_area"])
43+
script_url = await self._set_script_files(session, script, config.bps.artifact_path)
4444
butler_repo = data_dict["butler_repo"]
4545
except KeyError as e:
4646
raise CMMissingScriptInputError(f"{script.fullname} missing an input: {e}") from e
@@ -92,7 +92,7 @@ async def _write_script(
9292
try:
9393
output_coll = resolved_cols["output"]
9494
input_colls = resolved_cols["inputs"]
95-
script_url = await self._set_script_files(session, script, data_dict["prod_area"])
95+
script_url = await self._set_script_files(session, script, config.bps.artifact_path)
9696
butler_repo = data_dict["butler_repo"]
9797
except KeyError as msg:
9898
logger.exception()
@@ -158,7 +158,7 @@ async def _write_script(
158158
try:
159159
output_coll = resolved_cols["output"]
160160
input_coll = resolved_cols["input"]
161-
script_url = await self._set_script_files(session, script, data_dict["prod_area"])
161+
script_url = await self._set_script_files(session, script, config.bps.artifact_path)
162162
butler_repo = data_dict["butler_repo"]
163163
except KeyError as msg:
164164
raise CMMissingScriptInputError(f"{script.fullname} missing an input: {msg}") from msg
@@ -238,7 +238,7 @@ async def _write_script(
238238
raise CMMissingScriptInputError(
239239
"Must specify what to collect in ChainCollectScriptHandler, jobs or steps",
240240
)
241-
script_url = await self._set_script_files(session, script, data_dict["prod_area"])
241+
script_url = await self._set_script_files(session, script, config.bps.artifact_path)
242242
butler_repo = data_dict["butler_repo"]
243243
command = f"{config.butler.butler_bin} collection-chain {butler_repo} {output_coll}"
244244
for collect_coll_ in collect_colls:
@@ -298,7 +298,7 @@ async def _write_script(
298298
try:
299299
output_coll = resolved_cols["output"]
300300
input_coll = resolved_cols["input"]
301-
script_url = await self._set_script_files(session, script, data_dict["prod_area"])
301+
script_url = await self._set_script_files(session, script, config.bps.artifact_path)
302302
butler_repo = data_dict["butler_repo"]
303303
data_query = data_dict.get("data_query")
304304
except KeyError as msg:
@@ -354,7 +354,7 @@ async def _write_script(
354354
data_dict = await script.data_dict(session)
355355
try:
356356
output_coll = resolved_cols["output"]
357-
script_url = await self._set_script_files(session, script, data_dict["prod_area"])
357+
script_url = await self._set_script_files(session, script, config.bps.artifact_path)
358358
butler_repo = data_dict["butler_repo"]
359359
except KeyError as msg:
360360
raise CMMissingScriptInputError(f"{script.fullname} missing an input: {msg}") from msg
@@ -410,7 +410,7 @@ async def _write_script(
410410
try:
411411
input_coll = resolved_cols["input"]
412412
output_coll = resolved_cols["output"]
413-
script_url = await self._set_script_files(session, script, data_dict["prod_area"])
413+
script_url = await self._set_script_files(session, script, config.bps.artifact_path)
414414
butler_repo = data_dict["butler_repo"]
415415
except KeyError as msg:
416416
raise CMMissingScriptInputError(f"{script.fullname} missing an input: {msg}") from msg
@@ -474,7 +474,7 @@ async def _write_script(
474474
resolved_cols = await script.resolve_collections(session)
475475
data_dict = await script.data_dict(session)
476476
try:
477-
script_url = await self._set_script_files(session, script, data_dict["prod_area"])
477+
script_url = await self._set_script_files(session, script, config.bps.artifact_path)
478478
butler_repo = data_dict["butler_repo"]
479479
output_coll = resolved_cols["output"]
480480
except KeyError as msg:
@@ -534,7 +534,7 @@ async def _write_script(
534534
) -> StatusEnum:
535535
resolved_cols = await script.resolve_collections(session)
536536
data_dict = await script.data_dict(session)
537-
prod_area = os.path.expandvars(data_dict["prod_area"])
537+
prod_area = os.path.expandvars(config.bps.artifact_path)
538538
script_url = await self._set_script_files(session, script, prod_area)
539539
butler_repo = data_dict["butler_repo"]
540540
usage_graph_url = os.path.expandvars(f"{prod_area}/{parent.fullname}/resource_usage.qgraph")
@@ -591,7 +591,7 @@ async def _write_script(
591591
) -> StatusEnum:
592592
resolved_cols = await script.resolve_collections(session)
593593
data_dict = await script.data_dict(session)
594-
prod_area = os.path.expandvars(data_dict["prod_area"])
594+
prod_area = os.path.expandvars(config.bps.artifact_path)
595595
script_url = await self._set_script_files(session, script, prod_area)
596596
butler_repo = data_dict["butler_repo"]
597597
hips_maps_graph_url = os.path.expandvars(f"{prod_area}/{parent.fullname}/hips_maps.qgraph")
@@ -693,7 +693,7 @@ async def _write_script(
693693
try:
694694
input_coll = resolved_cols["input"]
695695
output_coll = resolved_cols["output"]
696-
script_url = await self._set_script_files(session, script, data_dict["prod_area"])
696+
script_url = await self._set_script_files(session, script, config.bps.artifact_path)
697697
butler_repo = data_dict["butler_repo"]
698698
except KeyError as msg:
699699
raise CMMissingScriptInputError(f"{script.fullname} missing an input: {msg}") from msg

tests/fixtures/seeds/empty_config.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ Campaign:
2929
campaign_validation: "{out}/validate"
3030
data:
3131
butler_repo: "/repo/main"
32-
prod_area: "output/archive"
3332
data_query: "instrument = 'HSC'"
3433
lsst_version: "${WEEKLY}"
3534
- Specification:

tests/fixtures/seeds/start_trivial.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,5 @@ Campaign:
66
campaign_source: HSC/raw/RC2
77
data:
88
lsst_version: w_2024_38
9-
prod_area: /tmp/trivial
109
butler_repo: "/repo/main"
1110
data_query: "instrument = 'HSC' AND exposure in (30504, 30502) AND detector in (45, 46, 47, 48)"

tests/fixtures/seeds/test_hsc_micro.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
split_min_groups: 2
2424
data:
2525
butler_repo: "/repo/main"
26-
prod_area: "output/archive"
2726
data_query: "instrument = 'HSC' AND exposure in (30504, 30502) AND detector in (45, 46, 47, 48)"
2827
lsst_version: w_2025_01
2928
bps_wms_clustering_file: "${DRP_PIPE_DIR}/bps/clustering/HSC/DRP-RC2-clustering.yaml"
@@ -65,7 +64,6 @@
6564
campaign_validation: "{out}/validate"
6665
data:
6766
butler_repo: "/repo/main"
68-
prod_area: "output/archive"
6967
data_query: "instrument = 'HSC'"
7068
lsst_version: "${WEEKLY}"
7169
- Specification:

tests/fixtures/seeds/test_trivial.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
split_method: no_split
1717
data:
1818
butler_repo: "/repo/main"
19-
prod_area: "output/archive"
2019
data_query: "instrument = 'HSC' AND exposure in (30504, 30502) AND detector in (45, 46, 47, 48)"
2120
lsst_version: w_2023_46
2221
- Specification:

0 commit comments

Comments
 (0)