Skip to content

prefect.blocks.system

DateTime

Bases: Block

A block that represents a datetime

Attributes:

Name Type Description
value pendulum.DateTime

An ISO 8601-compatible datetime value.

Example

Load a stored JSON value:

from prefect.blocks.system import DateTime

data_time_block = DateTime.load("BLOCK_NAME")

Source code in prefect/blocks/system.py
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
class DateTime(Block):
    """
    A block that represents a datetime

    Attributes:
        value: An ISO 8601-compatible datetime value.

    Example:
        Load a stored JSON value:
        ```python
        from prefect.blocks.system import DateTime

        data_time_block = DateTime.load("BLOCK_NAME")
        ```
    """

    _block_type_name = "Date Time"
    _logo_url = "https://images.ctfassets.net/gm98wzqotmnx/1gmljt5UBcAwEXHPnIofcE/0f3cf1da45b8b2df846e142ab52b1778/image21.png?h=250"
    _documentation_url = "https://docs.prefect.io/api-ref/prefect/blocks/system/#prefect.blocks.system.DateTime"

    value: pendulum.DateTime = Field(
        default=...,
        description="An ISO 8601-compatible datetime value.",
    )

JSON

Bases: Block

A block that represents JSON

Attributes:

Name Type Description
value Any

A JSON-compatible value.

Example

Load a stored JSON value:

from prefect.blocks.system import JSON

json_block = JSON.load("BLOCK_NAME")

Source code in prefect/blocks/system.py
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
class JSON(Block):
    """
    A block that represents JSON

    Attributes:
        value: A JSON-compatible value.

    Example:
        Load a stored JSON value:
        ```python
        from prefect.blocks.system import JSON

        json_block = JSON.load("BLOCK_NAME")
        ```
    """

    _logo_url = "https://images.ctfassets.net/gm98wzqotmnx/19W3Di10hhb4oma2Qer0x6/764d1e7b4b9974cd268c775a488b9d26/image16.png?h=250"
    _documentation_url = "https://docs.prefect.io/api-ref/prefect/blocks/system/#prefect.blocks.system.JSON"

    value: Any = Field(default=..., description="A JSON-compatible value.")

Secret

Bases: Block

A block that represents a secret value. The value stored in this block will be obfuscated when this block is logged or shown in the UI.

Attributes:

Name Type Description
value SecretStr

A string value that should be kept secret.

Example
from prefect.blocks.system import Secret

secret_block = Secret.load("BLOCK_NAME")

# Access the stored secret
secret_block.get()
Source code in prefect/blocks/system.py
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
class Secret(Block):
    """
    A block that represents a secret value. The value stored in this block will be obfuscated when
    this block is logged or shown in the UI.

    Attributes:
        value: A string value that should be kept secret.

    Example:
        ```python
        from prefect.blocks.system import Secret

        secret_block = Secret.load("BLOCK_NAME")

        # Access the stored secret
        secret_block.get()
        ```
    """

    _logo_url = "https://images.ctfassets.net/gm98wzqotmnx/5uUmyGBjRejYuGTWbTxz6E/3003e1829293718b3a5d2e909643a331/image8.png?h=250"
    _documentation_url = "https://docs.prefect.io/api-ref/prefect/blocks/system/#prefect.blocks.system.Secret"

    value: SecretStr = Field(
        default=..., description="A string value that should be kept secret."
    )

    def get(self):
        return self.value.get_secret_value()

String

Bases: Block

A block that represents a string

Attributes:

Name Type Description
value str

A string value.

Example

Load a stored string value:

from prefect.blocks.system import String

string_block = String.load("BLOCK_NAME")

Source code in prefect/blocks/system.py
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
class String(Block):
    """
    A block that represents a string

    Attributes:
        value: A string value.

    Example:
        Load a stored string value:
        ```python
        from prefect.blocks.system import String

        string_block = String.load("BLOCK_NAME")
        ```
    """

    _logo_url = "https://images.ctfassets.net/gm98wzqotmnx/4zjrZmh9tBrFiikeB44G4O/2ce1dbbac1c8e356f7c429e0f8bbb58d/image10.png?h=250"
    _documentation_url = "https://docs.prefect.io/api-ref/prefect/blocks/system/#prefect.blocks.system.String"

    value: str = Field(default=..., description="A string value.")