Skip to content

Tensorflow

Initialization for TensorFlow integration.

TensorflowIntegration

Bases: Integration

Definition of Tensorflow integration for ZenML.

Source code in src/zenml/integrations/tensorflow/__init__.py
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
class TensorflowIntegration(Integration):
    """Definition of Tensorflow integration for ZenML."""

    NAME = TENSORFLOW
    REQUIREMENTS = []
    REQUIREMENTS_IGNORED_ON_UNINSTALL = ["typing-extensions"]

    @classmethod
    def activate(cls) -> None:
        """Activates the integration."""
        # need to import this explicitly to load the Tensorflow file IO support
        # for S3 and other file systems
        if not platform.system() == "Darwin" or not platform.machine() == "arm64":
            import tensorflow_io  # type: ignore

        from zenml.integrations.tensorflow import materializers  # noqa

    @classmethod
    def get_requirements(cls, target_os: Optional[str] = None) -> List[str]:
        """Defines platform specific requirements for the integration.

        Args:
            target_os: The target operating system.

        Returns:
            A list of requirements.
        """
        target_os = target_os or platform.system()
        if target_os == "Darwin" and platform.machine() == "arm64":
            requirements = [
                "tensorflow-macos>=2.12,<2.15",
            ]
        else:
            requirements = [
                "tensorflow>=2.12,<2.15",
                "tensorflow_io>=0.24.0",
            ]
        if sys.version_info.minor == 8:
            requirements.append("typing-extensions>=4.6.1")
        return requirements

activate() classmethod

Activates the integration.

Source code in src/zenml/integrations/tensorflow/__init__.py
33
34
35
36
37
38
39
40
41
@classmethod
def activate(cls) -> None:
    """Activates the integration."""
    # need to import this explicitly to load the Tensorflow file IO support
    # for S3 and other file systems
    if not platform.system() == "Darwin" or not platform.machine() == "arm64":
        import tensorflow_io  # type: ignore

    from zenml.integrations.tensorflow import materializers  # noqa

get_requirements(target_os=None) classmethod

Defines platform specific requirements for the integration.

Parameters:

Name Type Description Default
target_os Optional[str]

The target operating system.

None

Returns:

Type Description
List[str]

A list of requirements.

Source code in src/zenml/integrations/tensorflow/__init__.py
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
@classmethod
def get_requirements(cls, target_os: Optional[str] = None) -> List[str]:
    """Defines platform specific requirements for the integration.

    Args:
        target_os: The target operating system.

    Returns:
        A list of requirements.
    """
    target_os = target_os or platform.system()
    if target_os == "Darwin" and platform.machine() == "arm64":
        requirements = [
            "tensorflow-macos>=2.12,<2.15",
        ]
    else:
        requirements = [
            "tensorflow>=2.12,<2.15",
            "tensorflow_io>=0.24.0",
        ]
    if sys.version_info.minor == 8:
        requirements.append("typing-extensions>=4.6.1")
    return requirements