Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DM-39434: Move QBB factory to a separate class #241

Merged
merged 2 commits into from
May 31, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
45 changes: 35 additions & 10 deletions python/lsst/ctrl/mpexec/cmdLineFwk.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
import getpass
import logging
import shutil
from collections.abc import Iterable, Sequence
from collections.abc import Iterable, Mapping, Sequence
from types import SimpleNamespace
from typing import TYPE_CHECKING, Optional, Tuple

Expand Down Expand Up @@ -66,7 +66,15 @@
from .singleQuantumExecutor import SingleQuantumExecutor

if TYPE_CHECKING:
from lsst.daf.butler import DatastoreRecordData, LimitedButler, Quantum, Registry
from lsst.daf.butler import (

Check warning on line 69 in python/lsst/ctrl/mpexec/cmdLineFwk.py

View check run for this annotation

Codecov / codecov/patch

python/lsst/ctrl/mpexec/cmdLineFwk.py#L69

Added line #L69 was not covered by tests
andy-slac marked this conversation as resolved.
Show resolved Hide resolved
Config,
DatasetType,
DatastoreRecordData,
DimensionUniverse,
LimitedButler,
Quantum,
Registry,
)
from lsst.pipe.base import TaskDef, TaskFactory


Expand Down Expand Up @@ -460,6 +468,26 @@
"""


class _QBBFactory:
"""Class which is a callable for making QBB instances."""

def __init__(
self, butler_config: Config, dimensions: DimensionUniverse, dataset_types: Mapping[str, DatasetType]
):
self.butler_config = butler_config
self.dimensions = dimensions
self.dataset_types = dataset_types

Check warning on line 479 in python/lsst/ctrl/mpexec/cmdLineFwk.py

View check run for this annotation

Codecov / codecov/patch

python/lsst/ctrl/mpexec/cmdLineFwk.py#L477-L479

Added lines #L477 - L479 were not covered by tests

def __call__(self, quantum: Quantum) -> LimitedButler:
"""Factory method to create QuantumBackedButler instances."""
return QuantumBackedButler.initialize(

Check warning on line 483 in python/lsst/ctrl/mpexec/cmdLineFwk.py

View check run for this annotation

Codecov / codecov/patch

python/lsst/ctrl/mpexec/cmdLineFwk.py#L483

Added line #L483 was not covered by tests
config=self.butler_config,
quantum=quantum,
dimensions=self.dimensions,
dataset_types=self.dataset_types,
)


# ------------------------
# Exported definitions --
# ------------------------
Expand Down Expand Up @@ -874,14 +902,11 @@

dataset_types = {dstype.name: dstype for dstype in qgraph.registryDatasetTypes()}

def _butler_factory(quantum: Quantum) -> LimitedButler:
"""Factory method to create QuantumBackedButler instances."""
return QuantumBackedButler.initialize(
config=args.butler_config,
quantum=quantum,
dimensions=qgraph.universe,
dataset_types=dataset_types,
)
_butler_factory = _QBBFactory(

Check warning on line 905 in python/lsst/ctrl/mpexec/cmdLineFwk.py

View check run for this annotation

Codecov / codecov/patch

python/lsst/ctrl/mpexec/cmdLineFwk.py#L905

Added line #L905 was not covered by tests
butler_config=args.butler_config,
dimensions=qgraph.universe,
dataset_types=dataset_types,
)

# make special quantum executor
quantumExecutor = SingleQuantumExecutor(
Expand Down