Skip to content

provider

Provider

Full-scope provider — assembles schema, database, and account resources.

Entry point for CLI and CI/CD pipelines. Never use inside a stored procedure (imports the full resource graph including account-level objects).

The manifest's scope selects which sub-provider runs. Only account scope is wired in this first slice; schema and database follow.

Example

.. code-block:: python

from pinky_provider import Provider

provider = Provider(session)
provider.plan(source="manifest.yml", env="SANDBOX")
provider.apply(source="manifest.yml", env="SANDBOX")

Parameters:

Name Type Description Default
session Any

Active Snowpark Session.

required
Source code in src/pinky_provider/provider.py
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
75
76
77
78
79
80
81
82
83
84
85
86
87
class Provider:
    """Full-scope provider — assembles schema, database, and account resources.

    Entry point for CLI and CI/CD pipelines. Never use inside a stored procedure
    (imports the full resource graph including account-level objects).

    The manifest's ``scope`` selects which sub-provider runs. Only ``account`` scope is wired in
    this first slice; ``schema`` and ``database`` follow.

    Example:
        .. code-block:: python

            from pinky_provider import Provider

            provider = Provider(session)
            provider.plan(source="manifest.yml", env="SANDBOX")
            provider.apply(source="manifest.yml", env="SANDBOX")

    Args:
        session: Active Snowpark ``Session``.
    """

    def __init__(self, session: Any) -> None:
        self._session = session
        self.schema = SchemaProvider(session)
        self.database = DatabaseProvider(session)
        self.account = AccountProvider(session)

    def _route(self, manifest: Manifest) -> AccountProvider:
        if manifest.scope == "account":
            return self.account
        raise NotImplementedError(
            f"scope {manifest.scope!r} not implemented yet — only 'account' is wired"
        )

    def plan(
        self,
        source: str,
        target: str | None = None,
        env: str = "SANDBOX",
        vars: dict[str, str] | None = None,
    ) -> list[ResourceDiff]:
        """Compute the full change plan without applying anything.

        Args:
            source: Path to ``manifest.yml``.
            target: Target schema as ``DATABASE.SCHEMA`` (schema scope) — unused at account scope.
            env: Environment selecting ``vars/<env>.yml`` (e.g. ``SANDBOX``).
            vars: Variable overrides injected into the manifest.

        Returns:
            Ordered list of :class:`~pinky_provider.core.diff.ResourceDiff`.
        """
        manifest = Manifest(source, env=env, vars=vars)
        return self._route(manifest).plan(manifest)

    def apply(
        self,
        source: str,
        target: str | None = None,
        env: str = "SANDBOX",
        vars: dict[str, str] | None = None,
    ) -> list[ResourceDiff]:
        """Apply the manifest — deploys or alters all declared objects.

        Args:
            source: Path to ``manifest.yml``.
            target: Target schema as ``DATABASE.SCHEMA`` (schema scope) — unused at account scope.
            env: Environment selecting ``vars/<env>.yml``.
            vars: Variable overrides injected into the manifest.

        Returns:
            The diffs actually executed.
        """
        manifest = Manifest(source, env=env, vars=vars)
        return self._route(manifest).apply(manifest)

apply(source, target=None, env='SANDBOX', vars=None)

Apply the manifest — deploys or alters all declared objects.

Parameters:

Name Type Description Default
source str

Path to manifest.yml.

required
target str | None

Target schema as DATABASE.SCHEMA (schema scope) — unused at account scope.

None
env str

Environment selecting vars/<env>.yml.

'SANDBOX'
vars dict[str, str] | None

Variable overrides injected into the manifest.

None

Returns:

Type Description
list[ResourceDiff]

The diffs actually executed.

Source code in src/pinky_provider/provider.py
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
def apply(
    self,
    source: str,
    target: str | None = None,
    env: str = "SANDBOX",
    vars: dict[str, str] | None = None,
) -> list[ResourceDiff]:
    """Apply the manifest — deploys or alters all declared objects.

    Args:
        source: Path to ``manifest.yml``.
        target: Target schema as ``DATABASE.SCHEMA`` (schema scope) — unused at account scope.
        env: Environment selecting ``vars/<env>.yml``.
        vars: Variable overrides injected into the manifest.

    Returns:
        The diffs actually executed.
    """
    manifest = Manifest(source, env=env, vars=vars)
    return self._route(manifest).apply(manifest)

plan(source, target=None, env='SANDBOX', vars=None)

Compute the full change plan without applying anything.

Parameters:

Name Type Description Default
source str

Path to manifest.yml.

required
target str | None

Target schema as DATABASE.SCHEMA (schema scope) — unused at account scope.

None
env str

Environment selecting vars/<env>.yml (e.g. SANDBOX).

'SANDBOX'
vars dict[str, str] | None

Variable overrides injected into the manifest.

None

Returns:

Type Description
list[ResourceDiff]

Ordered list of :class:~pinky_provider.core.diff.ResourceDiff.

Source code in src/pinky_provider/provider.py
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
def plan(
    self,
    source: str,
    target: str | None = None,
    env: str = "SANDBOX",
    vars: dict[str, str] | None = None,
) -> list[ResourceDiff]:
    """Compute the full change plan without applying anything.

    Args:
        source: Path to ``manifest.yml``.
        target: Target schema as ``DATABASE.SCHEMA`` (schema scope) — unused at account scope.
        env: Environment selecting ``vars/<env>.yml`` (e.g. ``SANDBOX``).
        vars: Variable overrides injected into the manifest.

    Returns:
        Ordered list of :class:`~pinky_provider.core.diff.ResourceDiff`.
    """
    manifest = Manifest(source, env=env, vars=vars)
    return self._route(manifest).plan(manifest)