Skip to content

prefect_monte_carlo.utilities

Module to define Monte Carlo utility functions.

Classes

Functions

rule_uuid_from_name async

Get the UUID of a Monte Carlo monitor rule from its name.

Parameters:

Name Type Description Default
rule_name str

Name of the Monte Carlo monitor rule.

required
monte_carlo_credentials MonteCarloCredentials

Credentials to authenticate with the Monte Carlo GraphQL API.

required
Source code in prefect_monte_carlo/utilities.py
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
async def rule_uuid_from_name(
    rule_name: str,
    monte_carlo_credentials: MonteCarloCredentials,
) -> UUID:
    """Get the UUID of a Monte Carlo monitor rule from its name.


    Args:
        rule_name: Name of the Monte Carlo monitor rule.
        monte_carlo_credentials: Credentials
            to authenticate with the Monte Carlo GraphQL API.
    """
    query = f"""
        query {{
            getCustomRule (
                descriptionContains: "{rule_name}"
        ) {{ uuid }}
    }}
    """
    client = monte_carlo_credentials.get_client()
    return client(query).get_custom_rule.uuid

validate_tags

Validate that Monte Carlo lineage node tags are in the correct format.

Parameters:

Name Type Description Default
tags List[Dict[str, str]]

List of user-defined tags to validate.

required

Raises:

Type Description
MonteCarloIncorrectTagsFormatException

If the tags are not well-formatted.

Source code in prefect_monte_carlo/utilities.py
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
def validate_tags(tags: List[Dict[str, str]]):
    """Validate that Monte Carlo lineage node tags are in the correct format.

    Args:
        tags: List of user-defined tags to validate.

    Raises:
        MonteCarloIncorrectTagsFormatException: If the tags are not well-formatted.

    """
    for tag in tags:
        if tag.keys() != {"propertyName", "propertyValue"}:
            raise MonteCarloIncorrectTagsFormatException(
                "Must provide tags as a list of dicts like "
                '[{"propertyName": "tag_name", "propertyValue": "tag_value"}].',
                "You provided: ",
                tag,
            )