luminal.interfaces.photon

Module Contents

Classes

IPhotonMeta

The metaclass for the abstract base class IPhoton that enables the specification of authorship, version, tags, and a description for the derived classes.

IPhoton

Base class for all Luminal photons.

class IPhotonMeta(*args, **kwargs)

Bases: abc.ABCMeta, luminal.interfaces.metadata.MetaProperties

The metaclass for the abstract base class IPhoton that enables the specification of authorship, version, tags, and a description for the derived classes.

This metaclass is used to define several class attributes for any class that derives from the base class IPhoton. The attributes are used to provide metadata about the derived class. The metaclass is created by inheriting from ABCMeta and MetaProperties and includes multiple attributes.

Usage

  • This metaclass is typically used by inheriting it from an IPhoton base class.

  • To specify values for the metadata attributes in a derived class, simply define the corresponding attributes inside the class definition with appropriate values.

Examples

>>> class MyPhotonInterface(metaclass=IPhotonMeta):
>>> ...

Here, a new class named MyPhotonInterface is created with the photon-specific metadata.

__photon_name__: str
__photon_author__: str
__photon_version__: str
__photon_description__: str
__photon_tags__: list[str]
Parameters:
class IPhoton(*args, **kwargs)

Base class for all Luminal photons.

Important

This class provides several other utility functions and properties that can be used by Luminal photons.

Parameters:
property photon_name: str

Returns the name of the IPhoton.

Parameters:

cls (Type[Self@IPhoton]) – The base class itself.

Returns:

The name of the photon.

Return type:

str

property photon_author: str

Returns the author of the IPhoton.

Parameters:

cls (Type[Self@IPhoton]) – The base class itself.

Returns:

The author of the photon, as a string.

Return type:

str

property photon_version: str

Returns the version of the IPhoton.

Parameters:

cls (Type[Self@IPhoton]) – The base class itself.

Returns:

The version of the photon, as a string.

Return type:

str

property photon_description: str

Returns the description of the IPhoton.

Parameters:

cls (Type[Self@IPhoton]) – The base class itself.

Returns:

The description of the photon, as a string.

Return type:

str

property photon_tags: list[str]

Returns the list of tags associated with the IPhoton.

Parameters:

cls (Type[Self@IPhoton]) – The base class itself.

Returns:

The list of tags associated with the photon, as a list of strings.

Return type:

list

__photon_name__: str
__photon_author__: str
__photon_version__: str
__photon_description__: str
__photon_tags__: list[str]
_print(message, print_output=True, file=sys.stdout, **kwargs)

Prints the given message to the console or a file.

Parameters:
  • message (str) – The message to print to the console.

  • file (Optional[TextIO]) – The IO stream that should be written to.

  • **kwargs (Optional[dict[str, Any]]) – The keyword arguments of the print() call.

  • print_output (bool) –

Return type:

None

print(message, print_output=True, file=sys.stdout, **kwargs)

Prints the given message to the console or a file.

Parameters:
  • message (str) – The message to print to the console.

  • file (Optional[TextIO]) – The IO stream that should be written to.

  • **kwargs (Optional[dict[str, Any]]) – The keyword arguments of the print() call.

  • print_output (bool) –

Return type:

None

eprint(message, print_output=True, file=sys.stderr, **kwargs)

Prints the given error message to the console or a file.

Parameters:
  • message (str) – The error message to print to the console.

  • file (Optional[TextIO]) – The IO stream that should be written to.

  • **kwargs (Optional[dict[str, Any]]) – The keyword arguments of the print() call.

  • print_output (bool) –

Return type:

None

async finalize()

A method that can, and should, be overridden to perform finalization tasks when the photon is unloaded.

Returns:

A flag which returns True if the finalization method completed successfully, else False.

Return type:

bool

Raises:

FinalizerNotImplementedError – If this method is not implemented by the subclass.