class PrefectHttpxClient(httpx.AsyncClient):
"""
A Prefect wrapper for the async httpx client with support for retry-after headers
for the provided status codes (typically 429, 502 and 503).
@@ -9485,11 +9490,18 @@
[Configuring Cloudflare Rate Limiting](https://support.cloudflare.com/hc/en-us/articles/115001635128-Configuring-Rate-Limiting-from-UI)
"""
- def __init__(self, *args, enable_csrf_support: bool = False, **kwargs):
+ def __init__(
+ self,
+ *args,
+ enable_csrf_support: bool = False,
+ raise_on_all_errors: bool = True,
+ **kwargs,
+ ):
self.enable_csrf_support: bool = enable_csrf_support
self.csrf_token: Optional[str] = None
self.csrf_token_expiration: Optional[datetime] = None
self.csrf_client_id: uuid.UUID = uuid.uuid4()
+ self.raise_on_all_errors: bool = raise_on_all_errors
super().__init__(*args, **kwargs)
@@ -9637,10 +9649,8 @@
# Convert to a Prefect response to add nicer errors messages
response = PrefectResponse.from_httpx_response(response)
- # Always raise bad responses
- # NOTE: We may want to remove this and handle responses per route in the
- # `PrefectClient`
- response.raise_for_status()
+ if self.raise_on_all_errors:
+ response.raise_for_status()
return response
@@ -9725,14 +9735,7 @@
Source code in prefect/client/base.py
- 305
-306
-307
-308
-309
-310
-311
-312
+ 312
313
314
315
@@ -9773,7 +9776,12 @@
350
351
352
-353 | async def send(self, request: Request, *args, **kwargs) -> Response:
+353
+354
+355
+356
+357
+358
| async def send(self, request: Request, *args, **kwargs) -> Response:
"""
Send a request with automatic retry behavior for the following status codes:
@@ -9816,10 +9824,8 @@
# Convert to a Prefect response to add nicer errors messages
response = PrefectResponse.from_httpx_response(response)
- # Always raise bad responses
- # NOTE: We may want to remove this and handle responses per route in the
- # `PrefectClient`
- response.raise_for_status()
+ if self.raise_on_all_errors:
+ response.raise_for_status()
return response
|
diff --git a/versions/unreleased/api-ref/prefect/settings/index.html b/versions/unreleased/api-ref/prefect/settings/index.html
index 8ab8ded8b6..64b55dce01 100644
--- a/versions/unreleased/api-ref/prefect/settings/index.html
+++ b/versions/unreleased/api-ref/prefect/settings/index.html
@@ -7502,6 +7502,39 @@
+
+
+
+
+
+
+ PREFECT_API_SERVICES_EVENT_PERSISTER_ENABLED
+
+
+
+
+
+
+
+
+
+
+ PREFECT_API_SERVICES_EVENT_PERSISTER_BATCH_SIZE
+
+
+
+
+
+
+
+
+
+
+ PREFECT_API_SERVICES_EVENT_PERSISTER_FLUSH_INTERVAL
+
+
+
+
@@ -12421,6 +12454,39 @@
+
+
+
+
+
+
+ PREFECT_API_SERVICES_EVENT_PERSISTER_ENABLED
+
+
+
+
+
+
+
+
+
+
+ PREFECT_API_SERVICES_EVENT_PERSISTER_BATCH_SIZE
+
+
+
+
+
+
+
+
+
+
+ PREFECT_API_SERVICES_EVENT_PERSISTER_FLUSH_INTERVAL
+
+
+
+
@@ -16244,6 +16310,69 @@
+
+
+
+
+ PREFECT_API_SERVICES_EVENT_PERSISTER_ENABLED = Setting(bool, default=True)
+
+
+ module-attribute
+
+
+
+
+
+
+
+ Whether or not to start the event persister service in the server application.
+
+
+
+
+
+
+
+
+
+ PREFECT_API_SERVICES_EVENT_PERSISTER_BATCH_SIZE = Setting(int, default=20, gt=0)
+
+
+ module-attribute
+
+
+
+
+
+
+
+ The number of events the event persister will attempt to insert in one batch.
+
+
+
+
+
+
+
+
+
+ PREFECT_API_SERVICES_EVENT_PERSISTER_FLUSH_INTERVAL = Setting(float, default=5, gt=0.0)
+
+
+ module-attribute
+
+
+
+
+
+
+
+ The maximum number of seconds between flushes of the event persister.
+
+
+
+
@@ -16759,23 +16888,7 @@
Source code in prefect/settings.py
- 1723
-1724
-1725
-1726
-1727
-1728
-1729
-1730
-1731
-1732
-1733
-1734
-1735
-1736
-1737
-1738
-1739
+ 1739
1740
1741
1742
@@ -16913,7 +17026,23 @@
1874
1875
1876
-1877 | @add_cloudpickle_reduction
+1877
+1878
+1879
+1880
+1881
+1882
+1883
+1884
+1885
+1886
+1887
+1888
+1889
+1890
+1891
+1892
+1893
| @add_cloudpickle_reduction
class Settings(SettingsFieldsMixin):
"""
Contains validated Prefect settings.
@@ -17100,14 +17229,14 @@
Source code in prefect/settings.py
- 1742
-1743
-1744
-1745
-1746
-1747
-1748
-1749 | def value_of(self, setting: Setting[T], bypass_callback: bool = False) -> T:
+ 1758
+1759
+1760
+1761
+1762
+1763
+1764
+1765 | def value_of(self, setting: Setting[T], bypass_callback: bool = False) -> T:
"""
Retrieve a setting's value.
"""
@@ -17138,19 +17267,19 @@
Source code in prefect/settings.py
- 1758
-1759
-1760
-1761
-1762
-1763
-1764
-1765
-1766
-1767
-1768
-1769
-1770 | @root_validator
+ 1774
+1775
+1776
+1777
+1778
+1779
+1780
+1781
+1782
+1783
+1784
+1785
+1786 | @root_validator
def post_root_validators(cls, values):
"""
Add root validation functions for settings here.
@@ -17186,23 +17315,23 @@
Source code in prefect/settings.py
- 1804
-1805
-1806
-1807
-1808
-1809
-1810
-1811
-1812
-1813
-1814
-1815
-1816
-1817
-1818
-1819
-1820 | def with_obfuscated_secrets(self):
+ 1820
+1821
+1822
+1823
+1824
+1825
+1826
+1827
+1828
+1829
+1830
+1831
+1832
+1833
+1834
+1835
+1836 | def with_obfuscated_secrets(self):
"""
Returns a copy of this settings object with secret setting values obfuscated.
"""
@@ -17243,13 +17372,13 @@
Source code in prefect/settings.py
- 1822
-1823
-1824
-1825
-1826
-1827
-1828 | def hash_key(self) -> str:
+ 1838
+1839
+1840
+1841
+1842
+1843
+1844 | def hash_key(self) -> str:
"""
Return a hash key for the settings object. This is needed since some
settings may be unhashable. An example is lists.
@@ -17351,23 +17480,7 @@
Source code in prefect/settings.py
- 1830
-1831
-1832
-1833
-1834
-1835
-1836
-1837
-1838
-1839
-1840
-1841
-1842
-1843
-1844
-1845
-1846
+ 1846
1847
1848
1849
@@ -17395,7 +17508,23 @@ 1871
1872
1873
-1874 | def to_environment_variables(
+1874
+1875
+1876
+1877
+1878
+1879
+1880
+1881
+1882
+1883
+1884
+1885
+1886
+1887
+1888
+1889
+1890
| def to_environment_variables(
self, include: Iterable[Setting] = None, exclude_unset: bool = False
) -> Dict[str, str]:
"""
@@ -17475,23 +17604,7 @@
Source code in prefect/settings.py
- 1982
-1983
-1984
-1985
-1986
-1987
-1988
-1989
-1990
-1991
-1992
-1993
-1994
-1995
-1996
-1997
-1998
+ 1998
1999
2000
2001
@@ -17522,7 +17635,23 @@
2026
2027
2028
-2029 | class Profile(BaseModel):
+2029
+2030
+2031
+2032
+2033
+2034
+2035
+2036
+2037
+2038
+2039
+2040
+2041
+2042
+2043
+2044
+2045
| class Profile(BaseModel):
"""
A user profile containing settings.
"""
@@ -17626,18 +17755,18 @@
Source code in prefect/settings.py
- 1995
-1996
-1997
-1998
-1999
-2000
-2001
-2002
-2003
-2004
-2005
-2006 | def validate_settings(self) -> None:
+ 2011
+2012
+2013
+2014
+2015
+2016
+2017
+2018
+2019
+2020
+2021
+2022 | def validate_settings(self) -> None:
"""
Validate the settings contained in this profile.
@@ -17674,25 +17803,25 @@
Source code in prefect/settings.py
- 2008
-2009
-2010
-2011
-2012
-2013
-2014
-2015
-2016
-2017
-2018
-2019
-2020
-2021
-2022
-2023
-2024
+ | def convert_deprecated_renamed_settings(self) -> List[Tuple[Setting, Setting]]:
+2026
+2027
+2028
+2029
+2030
+2031
+2032
+2033
+2034
+2035
+2036
+2037
+2038
+2039
+2040
+2041
+2042
| def convert_deprecated_renamed_settings(self) -> List[Tuple[Setting, Setting]]:
"""
Update settings in place to replace deprecated settings with new settings when
renamed.
@@ -17747,23 +17876,7 @@
Source code in prefect/settings.py
- 2032
-2033
-2034
-2035
-2036
-2037
-2038
-2039
-2040
-2041
-2042
-2043
-2044
-2045
-2046
-2047
-2048
+ 2048
2049
2050
2051
@@ -17897,7 +18010,23 @@
2179
2180
2181
-2182 | class ProfilesCollection:
+2182
+2183
+2184
+2185
+2186
+2187
+2188
+2189
+2190
+2191
+2192
+2193
+2194
+2195
+2196
+2197
+2198
| class ProfilesCollection:
""" "
A utility class for working with a collection of profiles.
@@ -18124,16 +18253,16 @@
Source code in prefect/settings.py
- 2063
-2064
-2065
-2066
-2067
-2068
-2069
-2070
-2071
-2072 | def set_active(self, name: Optional[str], check: bool = True):
+ 2079
+2080
+2081
+2082
+2083
+2084
+2085
+2086
+2087
+2088 | def set_active(self, name: Optional[str], check: bool = True):
"""
Set the active profile name in the collection.
@@ -18171,23 +18300,7 @@
Source code in prefect/settings.py
- 2074
-2075
-2076
-2077
-2078
-2079
-2080
-2081
-2082
-2083
-2084
-2085
-2086
-2087
-2088
-2089
-2090
+ 2090
2091
2092
2093
@@ -18207,7 +18320,23 @@ 2107
2108
2109
-2110 | def update_profile(
+2110
+2111
+2112
+2113
+2114
+2115
+2116
+2117
+2118
+2119
+2120
+2121
+2122
+2123
+2124
+2125
+2126
| def update_profile(
self, name: str, settings: Mapping[Union[Dict, str], Any], source: Path = None
) -> Profile:
"""
@@ -18268,18 +18397,18 @@
Source code in prefect/settings.py
- 2112
-2113
-2114
-2115
-2116
-2117
-2118
-2119
-2120
-2121
-2122
-2123 | def add_profile(self, profile: Profile) -> None:
+ 2128
+2129
+2130
+2131
+2132
+2133
+2134
+2135
+2136
+2137
+2138
+2139 | def add_profile(self, profile: Profile) -> None:
"""
Add a profile to the collection.
@@ -18314,11 +18443,11 @@
Source code in prefect/settings.py
- 2125
-2126
-2127
-2128
-2129 | def remove_profile(self, name: str) -> None:
+ 2141
+2142
+2143
+2144
+2145 | def remove_profile(self, name: str) -> None:
"""
Remove a profile from the collection.
"""
@@ -18347,20 +18476,20 @@
Source code in prefect/settings.py
- 2131
-2132
-2133
-2134
-2135
-2136
-2137
-2138
-2139
-2140
-2141
-2142
-2143
-2144 | def without_profile_source(self, path: Optional[Path]) -> "ProfilesCollection":
+ 2147
+2148
+2149
+2150
+2151
+2152
+2153
+2154
+2155
+2156
+2157
+2158
+2159
+2160 | def without_profile_source(self, path: Optional[Path]) -> "ProfilesCollection":
"""
Remove profiles that were loaded from a given path.
@@ -18891,18 +19020,18 @@
Source code in prefect/settings.py
- 1886
-1887
-1888
-1889
-1890
-1891
-1892
-1893
-1894
-1895
-1896
-1897 | def get_current_settings() -> Settings:
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|