Skip to content

Commit

Permalink
Merge branch 'tickets/DM-40647'
Browse files Browse the repository at this point in the history
  • Loading branch information
leeskelvin committed Sep 7, 2023
2 parents 7d1162e + 29c4707 commit 73631a3
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
8 changes: 8 additions & 0 deletions python/lsst/source/injection/bin/make_injection_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,14 @@ def build_argparser():
help="Do not update pipeline subsets to include the injection task.",
action="store_true",
)
parser.add_argument(
"-x",
"--excluded-tasks",
type=str,
help="Comma-separated set of task labels to exclude from the pipeline.",
metavar="task",
default="jointcal,gbdesAstrometricFit,fgcmBuildFromIsolatedStars,fgcmFitCycle,fgcmOutputProducts",
)
parser.add_argument(
"-f",
"--filename",
Expand Down
29 changes: 29 additions & 0 deletions python/lsst/source/injection/utils/make_injection_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,14 @@ def make_injection_pipeline(
reference_pipeline: str,
injection_pipeline: str | None = None,
exclude_subsets: bool = False,
excluded_tasks: set[str]
| str = {
"jointcal",
"gbdesAstrometricFit",
"fgcmBuildFromIsolatedStars",
"fgcmFitCycle",
"fgcmOutputProducts",
},
prefix: str = "injected_",
instrument: str | None = None,
log_level: int = logging.INFO,
Expand All @@ -67,6 +75,9 @@ def make_injection_pipeline(
Location of an injection pipeline definition YAML file.
exclude_subsets : `bool`, optional
If True, do not update pipeline subsets to include the injection task.
excluded_tasks : `set` [`str`] | `str`
Set or comma-separated string of task labels to exclude from the
injection pipeline.
prefix : `str`, optional
Prefix to prepend to each affected post-injection dataset type name.
instrument : `str`, optional
Expand All @@ -89,6 +100,24 @@ def make_injection_pipeline(
if instrument:
pipeline.addInstrument(instrument)

# Remove all tasks which are not to be included in the injection pipeline.
if isinstance(excluded_tasks, str):
excluded_tasks = set(excluded_tasks.split(","))
for task_label in excluded_tasks:
# First remove tasks from their host subsets, if present.
try:
host_subsets = pipeline.findSubsetsWithLabel(task_label)
except ValueError:
pass
else:
for host_subset in host_subsets:
pipeline.removeLabelFromSubset(host_subset, task_label)
# Then remove the task from the pipeline.
try:
pipeline.removeTask(task_label)
except KeyError:
logger.warning("Task '%s' not found in pipeline; nothing to exclude.", task_label)

# Determine the set of dataset type names affected by source injection
injected_types = {dataset_type_name}
precursor_injection_task_labels = set()
Expand Down

0 comments on commit 73631a3

Please sign in to comment.