Skip to content

Commit 24164d0

Browse files
committed
feat(campaing): use diffefrent namespaced names in steps and scripts
1 parent f07539b commit 24164d0

File tree

4 files changed

+40
-31
lines changed

4 files changed

+40
-31
lines changed

examples/example_standard_elements.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@
8383
output: "{step_public_output}"
8484
child_config:
8585
spec_block: group
86-
# Campagin Template, runs a campaign
86+
# Campaign Template, runs a campaign
8787
# This will tag the input data, create the ancillary collection, run the steps and then collect the outputs
8888
# Note that the steps are not defined here.
8989
- SpecBlock:
@@ -147,7 +147,7 @@
147147
data:
148148
lsst_version: MUST_OVERRIDE
149149
lsst_distrib_dir: /cvmfs/sw.lsst.eu/linux-x86_64/lsst_distrib
150-
# Campagin Template for fixed inputs
150+
# Campaign Template for fixed inputs
151151
# This assumes that the input data is already set, it will run the steps and then collect the outputs
152152
# Note that the steps are not defined here.
153153
- SpecBlock:

src/lsst/cmservice/client/loaders.py

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,21 +143,41 @@ def _upsert_spec_block(
143143
},
144144
)
145145

146+
# scripts and steps are lists, not mappings
146147
if "scripts" in block_data:
147-
# scripts and steps are lists, not mappings
148+
# the 'name' of the script should be namespaced; the 'spec_block'
149+
# of the script is a key to its specification alias within the
150+
# campaign, which itself references a namespaced spec_block.
148151
block_data["scripts"] = [
149152
deep_update(
150153
s,
151-
{"Script": {"spec_block": str(uuid5(namespace, s["Script"]["spec_block"]))}},
154+
{
155+
"Script": {
156+
"name": str(uuid5(namespace, s["Script"]["name"])),
157+
"spec_block": s["Script"]["spec_block"],
158+
}
159+
},
152160
)
153161
for s in block_data["scripts"]
154162
]
155163

156164
if "steps" in block_data:
165+
# steps are found in a campaign spec_block; the 'spec_block' should
166+
# be namespaced but the 'name' is a descriptor not used to refer-
167+
# ence other objects. Any names used in a prerequisites should be
168+
# namespaced.
157169
block_data["steps"] = [
158170
deep_update(
159171
s,
160-
{"Step": {"spec_block": str(uuid5(namespace, s["Step"]["spec_block"]))}},
172+
{
173+
"Step": {
174+
"name": s["Step"]["name"], # str(uuid5(namespace, s["Step"]["name"])),
175+
"spec_block": str(uuid5(namespace, s["Step"]["spec_block"])),
176+
"prerequisites": [
177+
str(uuid5(namespace, prereq)) for prereq in s["Step"].get("prerequisites", [])
178+
],
179+
}
180+
},
161181
)
162182
for s in block_data["steps"]
163183
]

src/lsst/cmservice/db/node.py

Lines changed: 13 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -137,12 +137,10 @@ async def get_handler(
137137
self,
138138
session: async_scoped_session,
139139
) -> Handler:
140-
"""Get the Handler object associated to a particular row
140+
"""Get the Handler object associated with a particular row
141141
142-
This will check if the handler class is defined
143-
for that particular row, if it is not, it
144-
will use the class as defined in the associated
145-
`SpecBlock`
142+
Check if a handler class is defined for a particular row; if not, use
143+
the class as defined in the associated `SpecBlock`.
146144
147145
Parameters
148146
----------
@@ -382,13 +380,10 @@ async def get_spec_aliases(
382380
self,
383381
session: async_scoped_session,
384382
) -> dict:
385-
"""Get the spec_alises
386-
associated to a particular node
383+
"""Get the spec_aliases associated with a particular node
387384
388-
This will start with the spec_aliases
389-
configuration in the associated `SpecBlock`
390-
and override it with with the data
391-
configuration in the row
385+
This will start with the spec_aliases configuration in the associated
386+
`SpecBlock` and override it with with the data configuration in the row
392387
393388
Parameters
394389
----------
@@ -463,8 +458,7 @@ async def update_collections(
463458
session: async_scoped_session,
464459
**kwargs: Any,
465460
) -> NodeMixin:
466-
"""Update the collection configuration
467-
associated to this Node
461+
"""Update the collection configuration associated with this Node
468462
469463
Parameters
470464
----------
@@ -506,8 +500,7 @@ async def update_spec_aliases(
506500
session: async_scoped_session,
507501
**kwargs: Any,
508502
) -> NodeMixin:
509-
"""Update the spec_alisases configuration
510-
associated to this Node
503+
"""Update the spec_alisases configuration associated with this Node
511504
512505
Parameters
513506
----------
@@ -550,8 +543,7 @@ async def update_data_dict(
550543
session: async_scoped_session,
551544
**kwargs: Any,
552545
) -> NodeMixin:
553-
"""Update the data configuration
554-
associated to this Node
546+
"""Update the data configuration associated with this Node
555547
556548
Parameters
557549
----------
@@ -593,9 +585,8 @@ async def check_prerequisites(
593585
self,
594586
session: async_scoped_session,
595587
) -> bool:
596-
"""Check if the prerequisties
597-
for processing a particular row
598-
are completed
588+
"""Check if the prerequisties for processing a particular node are
589+
completed.
599590
600591
Parameters
601592
----------
@@ -719,8 +710,7 @@ async def process(
719710
) -> tuple[bool, StatusEnum]:
720711
"""Process this `Node` as much as possible
721712
722-
This will create a `Handler` and
723-
pass this node to it for processing
713+
This will create a `Handler` and pass this node to it for processing
724714
725715
Parameters
726716
----------
@@ -745,8 +735,7 @@ async def run_check(
745735
) -> tuple[bool, StatusEnum]:
746736
"""Check on this Nodes's status
747737
748-
This will create a `Handler` and
749-
pass this node to it for checking
738+
This will create a `Handler` and pass this node to it for checking
750739
751740
Parameters
752741
----------

src/lsst/cmservice/handlers/element_handler.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,7 @@ async def prepare(
129129
) -> tuple[bool, StatusEnum]:
130130
"""Prepare `Element` for processing
131131
132-
This means creating database entries for scripts and
133-
dependencies between them
132+
Creates database entries for scripts and their inter-dependencies
134133
135134
Parameters
136135
----------
@@ -164,6 +163,7 @@ async def prepare(
164163
script_name = script_vals.pop("name")
165164
except KeyError as msg:
166165
raise CMYamlParseError(f"Unnnamed Script block {script_vals}") from msg
166+
167167
script_spec_block_name = script_vals.get("spec_block", None)
168168
if script_spec_block_name is None: # pragma: no cover
169169
raise CMYamlParseError(f"Script block {script_name} does not contain spec_block")

0 commit comments

Comments
 (0)