lodol 0.2.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
lodol/__init__.py ADDED
@@ -0,0 +1,115 @@
1
+ """Lodol's Developer API, from Python.
2
+
3
+ from lodol import Lodol
4
+
5
+ lodol = Lodol() # reads LODOL_API_KEY
6
+ run = lodol.workflows.run("665f...", inputs={"client": "Acme"}, wait=True)
7
+ print(run.status)
8
+ """
9
+
10
+ from __future__ import annotations
11
+
12
+ import warnings
13
+ from typing import Any
14
+
15
+ from lodol._logs import setup_logging
16
+ from lodol.client import AsyncLodol, Lodol
17
+ from lodol.exceptions import (
18
+ APIConnectionError,
19
+ APIError,
20
+ APIResponseValidationError,
21
+ APIStatusError,
22
+ APITimeoutError,
23
+ AuthenticationError,
24
+ BadRequestError,
25
+ ConfigurationError,
26
+ ConflictError,
27
+ InternalServerError,
28
+ LodolError,
29
+ NotFoundError,
30
+ PaymentRequiredError,
31
+ PermissionDeniedError,
32
+ RateLimitError,
33
+ RunFailedError,
34
+ RunLimitError,
35
+ UnprocessableEntityError,
36
+ WaitTimeoutError,
37
+ )
38
+ from lodol.models import (
39
+ Approval,
40
+ ApprovalStatus,
41
+ Decision,
42
+ DeletedRun,
43
+ DeletedWorkflow,
44
+ RetryOptions,
45
+ Run,
46
+ RunStatus,
47
+ Step,
48
+ StepStatus,
49
+ Workflow,
50
+ WorkflowCheck,
51
+ WorkflowInput,
52
+ WorkflowOutput,
53
+ )
54
+ from lodol.pagination import AsyncPaginator, Paginator
55
+ from lodol.version import __version__
56
+
57
+ setup_logging()
58
+
59
+ __all__ = [
60
+ "APIConnectionError",
61
+ "APIError",
62
+ "APIResponseValidationError",
63
+ "APIStatusError",
64
+ "APITimeoutError",
65
+ "Approval",
66
+ "ApprovalStatus",
67
+ "AsyncLodol",
68
+ "AsyncPaginator",
69
+ "AuthenticationError",
70
+ "BadRequestError",
71
+ "ConfigurationError",
72
+ "ConflictError",
73
+ "Decision",
74
+ "DeletedRun",
75
+ "DeletedWorkflow",
76
+ "InternalServerError",
77
+ "Lodol",
78
+ "LodolError",
79
+ "NotFoundError",
80
+ "Paginator",
81
+ "PaymentRequiredError",
82
+ "PermissionDeniedError",
83
+ "RateLimitError",
84
+ "RetryOptions",
85
+ "Run",
86
+ "RunFailedError",
87
+ "RunLimitError",
88
+ "RunStatus",
89
+ "Step",
90
+ "StepStatus",
91
+ "UnprocessableEntityError",
92
+ "WaitTimeoutError",
93
+ "Workflow",
94
+ "WorkflowCheck",
95
+ "WorkflowInput",
96
+ "WorkflowOutput",
97
+ "__version__",
98
+ ]
99
+
100
+ # Renamed in 0.2.0. Importing an old name still works, with a warning, so a
101
+ # script written for 0.1 starts and says what to change.
102
+ _RENAMED = {"Execution": "Run", "LodolTimeoutError": "WaitTimeoutError"}
103
+
104
+
105
+ def __getattr__(name: str) -> Any:
106
+ if name in _RENAMED:
107
+ new_name = _RENAMED[name]
108
+ warnings.warn(
109
+ f"lodol.{name} is now lodol.{new_name}; the old name will be removed "
110
+ "in a future release.",
111
+ DeprecationWarning,
112
+ stacklevel=2,
113
+ )
114
+ return globals()[new_name]
115
+ raise AttributeError(f"module 'lodol' has no attribute {name!r}")
lodol/_logs.py ADDED
@@ -0,0 +1,26 @@
1
+ from __future__ import annotations
2
+
3
+ import logging
4
+ import os
5
+
6
+ _LEVELS = {"debug": logging.DEBUG, "info": logging.INFO}
7
+
8
+
9
+ def setup_logging() -> None:
10
+ """Log to stderr when ``LODOL_LOG`` is ``info`` (retries, and what runs
11
+ being waited on are doing) or ``debug`` (every request too).
12
+
13
+ Requests are logged by method, path and status only: never a header, so
14
+ never the API key, and never a body, which may hold a run's inputs.
15
+ """
16
+ logger = logging.getLogger("lodol")
17
+ logger.addHandler(logging.NullHandler())
18
+ level = _LEVELS.get(os.environ.get("LODOL_LOG", "").strip().lower())
19
+ if level is None:
20
+ return
21
+ handler = logging.StreamHandler()
22
+ handler.setFormatter(
23
+ logging.Formatter("%(asctime)s lodol %(levelname)s %(message)s")
24
+ )
25
+ logger.addHandler(handler)
26
+ logger.setLevel(level)