File size: 2,215 Bytes
9c6594c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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
66
67
68
69
70
71
72
73
74
import wandb
from wandb._pydantic import IS_PYDANTIC_V2

from .actions import ActionType, DoNothing, SendNotification, SendWebhook
from .automations import Automation, NewAutomation
from .events import (
    ArtifactEvent,
    EventType,
    MetricChangeFilter,
    MetricThresholdFilter,
    OnAddArtifactAlias,
    OnCreateArtifact,
    OnLinkArtifact,
    OnRunMetric,
    RunEvent,
)
from .integrations import Integration, SlackIntegration, WebhookIntegration
from .scopes import ArtifactCollectionScope, ProjectScope, ScopeType

# ----------------------------------------------------------------------------
# WARNINGS on import
if not IS_PYDANTIC_V2:
    # Raises an error in Pydantic v1 environments, where the Automations API
    # has not been tested and is unlikely to work as expected.
    #
    # Remove this when we either:
    # - Drop support for Pydantic v1
    # - Are able to implement (limited) Pydantic v1 support
    raise ImportError(
        "The W&B Automations API requires Pydantic v2. "
        "We recommend upgrading `pydantic` to use this feature."
    )

else:
    # If Pydantic v2 is available, we can use the full Automations API
    # but communicate to users that the API is still experimental and
    # may change rapidly.
    wandb.termwarn(
        "The W&B Automations API is experimental and the implementation is subject to change."
        "Review the release notes before upgrading. We recommend pinning your "
        f"package version to `{wandb.__package__}=={wandb.__version__}` to reduce the risk of disruption.",
        repeat=False,
    )
# ----------------------------------------------------------------------------

__all__ = [
    # Scopes
    "ScopeType",
    "ArtifactCollectionScope",
    "ProjectScope",
    # Events
    "EventType",
    "OnAddArtifactAlias",
    "OnCreateArtifact",
    "OnLinkArtifact",
    "OnRunMetric",
    "ArtifactEvent",
    "RunEvent",
    "MetricThresholdFilter",
    "MetricChangeFilter",
    # Actions
    "ActionType",
    "SendNotification",
    "SendWebhook",
    "DoNothing",
    # Automations
    "Automation",
    "NewAutomation",
    # Integrations
    "Integration",
    "SlackIntegration",
    "WebhookIntegration",
]