Skip to content

data_mapper.aind_data_schema

AindDataSchemaDataMapper

AindDataSchemaDataMapper(*args, **kwargs)

Bases: DataMapper[_TAdsObject], ABC

Abstract base class for mapping data to aind-data-schema objects.

This class provides the foundation for mapping experimental data to AIND data schema formats, ensuring consistent structure and metadata handling across different data types.

Attributes:

Name Type Description
session_name str

The name of the session associated with the data

Example
# Example subclass implementing session_name
class MySessionMapper(AindDataSchemaDataMapper):
    @property
    def session_name(self) -> str:
        return "session_001"

Initializes the service.

Source code in src/clabe/services.py
28
29
30
def __init__(self, *args, **kwargs):
    """Initializes the service."""
    pass

session_name abstractmethod property

session_name: str

Abstract property that must be implemented to return the session name.

Subclasses must implement this property to provide the session name associated with the data being mapped.

Returns:

Name Type Description
str str

The name of the session

mapped property

mapped: TMapTo

Retrieves the mapped data object.

This property should return the successfully mapped data object. Implementations should ensure that mapping has been completed before returning the data.

Returns:

Name Type Description
TMapTo TMapTo

The mapped data object

Raises:

Type Description
ValueError

If the data has not been mapped yet.

build_runner

build_runner(*args, **kwargs) -> Callable[[Launcher], Any]

Builds a runner function for the service.

Subclasses must implement this method to return a callable that can be executed by the launcher.

Source code in src/clabe/services.py
32
33
34
35
36
37
38
def build_runner(self, *args, **kwargs) -> Callable[[Launcher], Any]:
    """
    Builds a runner function for the service.

    Subclasses must implement this method to return a callable that can be executed by the launcher.
    """
    return lambda launcher: None

map abstractmethod

map() -> TMapTo

Maps data to the target schema or format.

This method should contain the core logic for transforming input data into the target format specified by the TMapTo type parameter.

Returns:

Name Type Description
TMapTo TMapTo

The mapped data object

Source code in src/clabe/data_mapper/_base.py
56
57
58
59
60
61
62
63
64
65
66
67
@abc.abstractmethod
def map(self) -> TMapTo:
    """
    Maps data to the target schema or format.

    This method should contain the core logic for transforming input data
    into the target format specified by the TMapTo type parameter.

    Returns:
        TMapTo: The mapped data object
    """
    pass

is_mapped

is_mapped() -> bool

Checks if the data has been successfully mapped.

This method should verify whether the mapping operation has been completed and the data is available in the target format.

Returns:

Name Type Description
bool bool

True if the data is mapped, False otherwise

Source code in src/clabe/data_mapper/_base.py
69
70
71
72
73
74
75
76
77
78
79
def is_mapped(self) -> bool:
    """
    Checks if the data has been successfully mapped.

    This method should verify whether the mapping operation has been completed
    and the data is available in the target format.

    Returns:
        bool: True if the data is mapped, False otherwise
    """
    return self._mapped is not None

AindDataSchemaSessionDataMapper

AindDataSchemaSessionDataMapper(*args, **kwargs)

Bases: AindDataSchemaDataMapper[Session], ABC

Abstract base class for mapping session data to aind-data-schema Session objects.

This class specializes the generic data mapper for session-specific data, providing the interface for converting experimental session data to the AIND data schema Session format.

Initializes the service.

Source code in src/clabe/services.py
28
29
30
def __init__(self, *args, **kwargs):
    """Initializes the service."""
    pass

mapped property

mapped: TMapTo

Retrieves the mapped data object.

This property should return the successfully mapped data object. Implementations should ensure that mapping has been completed before returning the data.

Returns:

Name Type Description
TMapTo TMapTo

The mapped data object

Raises:

Type Description
ValueError

If the data has not been mapped yet.

session_name abstractmethod property

session_name: str

Abstract property that must be implemented to return the session name.

Subclasses must implement this property to provide the session name associated with the data being mapped.

Returns:

Name Type Description
str str

The name of the session

session_schema

session_schema() -> Session

Returns the session schema for the mapped session data.

This method should be implemented by subclasses to return the specific session schema that corresponds to the data being mapped.

Returns:

Type Description
Session

ads_session.Session: The session schema object

Source code in src/clabe/data_mapper/aind_data_schema.py
69
70
71
72
73
74
75
76
77
78
79
def session_schema(self) -> ads_session.Session:
    """
    Returns the session schema for the mapped session data.

    This method should be implemented by subclasses to return the specific
    session schema that corresponds to the data being mapped.

    Returns:
        ads_session.Session: The session schema object
    """
    raise NotImplementedError("Subclasses must implement this method to return the session schema.")

build_runner

build_runner(*args, **kwargs) -> Callable[[Launcher], Any]

Builds a runner function for the service.

Subclasses must implement this method to return a callable that can be executed by the launcher.

Source code in src/clabe/services.py
32
33
34
35
36
37
38
def build_runner(self, *args, **kwargs) -> Callable[[Launcher], Any]:
    """
    Builds a runner function for the service.

    Subclasses must implement this method to return a callable that can be executed by the launcher.
    """
    return lambda launcher: None

map abstractmethod

map() -> TMapTo

Maps data to the target schema or format.

This method should contain the core logic for transforming input data into the target format specified by the TMapTo type parameter.

Returns:

Name Type Description
TMapTo TMapTo

The mapped data object

Source code in src/clabe/data_mapper/_base.py
56
57
58
59
60
61
62
63
64
65
66
67
@abc.abstractmethod
def map(self) -> TMapTo:
    """
    Maps data to the target schema or format.

    This method should contain the core logic for transforming input data
    into the target format specified by the TMapTo type parameter.

    Returns:
        TMapTo: The mapped data object
    """
    pass

is_mapped

is_mapped() -> bool

Checks if the data has been successfully mapped.

This method should verify whether the mapping operation has been completed and the data is available in the target format.

Returns:

Name Type Description
bool bool

True if the data is mapped, False otherwise

Source code in src/clabe/data_mapper/_base.py
69
70
71
72
73
74
75
76
77
78
79
def is_mapped(self) -> bool:
    """
    Checks if the data has been successfully mapped.

    This method should verify whether the mapping operation has been completed
    and the data is available in the target format.

    Returns:
        bool: True if the data is mapped, False otherwise
    """
    return self._mapped is not None

AindDataSchemaRigDataMapper

AindDataSchemaRigDataMapper(*args, **kwargs)

Bases: AindDataSchemaDataMapper[Rig], ABC

Abstract base class for mapping rig data to aind-data-schema Rig objects.

This class specializes the generic data mapper for rig-specific data, providing the interface for converting experimental rig configurations to the AIND data schema Rig format.

Initializes the service.

Source code in src/clabe/services.py
28
29
30
def __init__(self, *args, **kwargs):
    """Initializes the service."""
    pass

mapped property

mapped: TMapTo

Retrieves the mapped data object.

This property should return the successfully mapped data object. Implementations should ensure that mapping has been completed before returning the data.

Returns:

Name Type Description
TMapTo TMapTo

The mapped data object

Raises:

Type Description
ValueError

If the data has not been mapped yet.

session_name abstractmethod property

session_name: str

Abstract property that must be implemented to return the session name.

Subclasses must implement this property to provide the session name associated with the data being mapped.

Returns:

Name Type Description
str str

The name of the session

rig_schema

rig_schema() -> Rig

Returns the rig schema for the mapped rig data.

This method should be implemented by subclasses to return the specific rig schema that corresponds to the data being mapped.

Returns:

Type Description
Rig

ads_rig.Rig: The rig schema object

Source code in src/clabe/data_mapper/aind_data_schema.py
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
def rig_schema(self) -> ads_rig.Rig:
    """
    Returns the rig schema for the mapped rig data.

    This method should be implemented by subclasses to return the specific
    rig schema that corresponds to the data being mapped.

    Returns:
        ads_rig.Rig: The rig schema object
    """
    raise NotImplementedError("Subclasses must implement this method to return the rig schema.")

build_runner

build_runner(*args, **kwargs) -> Callable[[Launcher], Any]

Builds a runner function for the service.

Subclasses must implement this method to return a callable that can be executed by the launcher.

Source code in src/clabe/services.py
32
33
34
35
36
37
38
def build_runner(self, *args, **kwargs) -> Callable[[Launcher], Any]:
    """
    Builds a runner function for the service.

    Subclasses must implement this method to return a callable that can be executed by the launcher.
    """
    return lambda launcher: None

map abstractmethod

map() -> TMapTo

Maps data to the target schema or format.

This method should contain the core logic for transforming input data into the target format specified by the TMapTo type parameter.

Returns:

Name Type Description
TMapTo TMapTo

The mapped data object

Source code in src/clabe/data_mapper/_base.py
56
57
58
59
60
61
62
63
64
65
66
67
@abc.abstractmethod
def map(self) -> TMapTo:
    """
    Maps data to the target schema or format.

    This method should contain the core logic for transforming input data
    into the target format specified by the TMapTo type parameter.

    Returns:
        TMapTo: The mapped data object
    """
    pass

is_mapped

is_mapped() -> bool

Checks if the data has been successfully mapped.

This method should verify whether the mapping operation has been completed and the data is available in the target format.

Returns:

Name Type Description
bool bool

True if the data is mapped, False otherwise

Source code in src/clabe/data_mapper/_base.py
69
70
71
72
73
74
75
76
77
78
79
def is_mapped(self) -> bool:
    """
    Checks if the data has been successfully mapped.

    This method should verify whether the mapping operation has been completed
    and the data is available in the target format.

    Returns:
        bool: True if the data is mapped, False otherwise
    """
    return self._mapped is not None