prefect-client 3.4.1.dev1__py3-none-any.whl → 3.4.1.dev2__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.
prefect/_build_info.py CHANGED
@@ -1,5 +1,5 @@
1
1
  # Generated by versioningit
2
- __version__ = "3.4.1.dev1"
3
- __build_date__ = "2025-05-04 08:07:31.383855+00:00"
4
- __git_commit__ = "378fc4f6b72aace32343264ee6cea198d949ba6a"
2
+ __version__ = "3.4.1.dev2"
3
+ __build_date__ = "2025-05-05 08:08:58.760597+00:00"
4
+ __git_commit__ = "c158d3eb6aae366fd814ba55c9151ca73ca1666a"
5
5
  __dirty__ = False
@@ -322,12 +322,16 @@ class PrefectClient(
322
322
  if api_version is None:
323
323
  api_version = SERVER_API_VERSION
324
324
  httpx_settings["headers"].setdefault("X-PREFECT-API-VERSION", api_version)
325
- if api_key:
326
- httpx_settings["headers"].setdefault("Authorization", f"Bearer {api_key}")
327
-
325
+ # Prioritize auth_string if provided, otherwise use api_key
328
326
  if auth_string:
329
327
  token = base64.b64encode(auth_string.encode("utf-8")).decode("utf-8")
330
- httpx_settings["headers"].setdefault("Authorization", f"Basic {token}")
328
+ httpx_settings["headers"]["Authorization"] = (
329
+ f"Basic {token}" # Overwrite if exists
330
+ )
331
+ elif api_key:
332
+ httpx_settings["headers"]["Authorization"] = (
333
+ f"Bearer {api_key}" # Set if auth_string is not present
334
+ )
331
335
 
332
336
  # Context management
333
337
  self._context_stack: int = 0
@@ -1189,12 +1193,16 @@ class SyncPrefectClient(
1189
1193
  if api_version is None:
1190
1194
  api_version = SERVER_API_VERSION
1191
1195
  httpx_settings["headers"].setdefault("X-PREFECT-API-VERSION", api_version)
1192
- if api_key:
1193
- httpx_settings["headers"].setdefault("Authorization", f"Bearer {api_key}")
1194
-
1196
+ # Prioritize auth_string if provided, otherwise use api_key
1195
1197
  if auth_string:
1196
1198
  token = base64.b64encode(auth_string.encode("utf-8")).decode("utf-8")
1197
- httpx_settings["headers"].setdefault("Authorization", f"Basic {token}")
1199
+ httpx_settings["headers"]["Authorization"] = (
1200
+ f"Basic {token}" # Overwrite if exists
1201
+ )
1202
+ elif api_key:
1203
+ httpx_settings["headers"]["Authorization"] = (
1204
+ f"Bearer {api_key}" # Set if auth_string is not present
1205
+ )
1198
1206
 
1199
1207
  # Context management
1200
1208
  self._context_stack: int = 0
@@ -13,7 +13,7 @@ from typing_extensions import Self
13
13
  from prefect._internal.schemas.bases import IDBaseModel
14
14
  from prefect.events.clients import websocket_connect
15
15
  from prefect.logging import get_logger
16
- from prefect.settings import PREFECT_API_KEY
16
+ from prefect.settings import get_current_settings
17
17
 
18
18
  logger: Logger = get_logger(__name__)
19
19
 
@@ -76,10 +76,17 @@ class Subscription(Generic[S]):
76
76
  websocket = await self._connect.__aenter__()
77
77
 
78
78
  try:
79
+ settings = get_current_settings()
80
+ auth_token = (
81
+ settings.api.auth_string.get_secret_value()
82
+ if settings.api.auth_string
83
+ else None
84
+ )
85
+ api_key = settings.api.key.get_secret_value() if settings.api.key else None
86
+ token = auth_token or api_key # Prioritize auth_token
87
+
79
88
  await websocket.send(
80
- orjson.dumps(
81
- {"type": "auth", "token": PREFECT_API_KEY.value()}
82
- ).decode()
89
+ orjson.dumps({"type": "auth", "token": token}).decode()
83
90
  )
84
91
 
85
92
  auth: dict[str, Any] = orjson.loads(await websocket.recv())
@@ -107,11 +114,13 @@ class Subscription(Generic[S]):
107
114
  reason = None
108
115
 
109
116
  if reason:
110
- raise Exception(
111
- "Unable to authenticate to the subscription. Please "
112
- "ensure the provided `PREFECT_API_KEY` you are using is "
113
- f"valid for this environment. Reason: {reason}"
114
- ) from e
117
+ error_message = (
118
+ "Unable to authenticate to the subscription. Please ensure the provided "
119
+ "`PREFECT_API_AUTH_STRING` (for self-hosted with auth string) or "
120
+ "`PREFECT_API_KEY` (for Cloud or self-hosted with API key) "
121
+ f"you are using is valid for this environment. Reason: {reason}"
122
+ )
123
+ raise Exception(error_message) from e
115
124
  raise
116
125
  else:
117
126
  self._websocket = websocket
prefect/tasks.py CHANGED
@@ -1551,7 +1551,7 @@ class Task(Generic[P, R]):
1551
1551
  validated_state=task_run.state,
1552
1552
  )
1553
1553
 
1554
- if task_run_url := url_for(task_run):
1554
+ if get_current_settings().ui_url and (task_run_url := url_for(task_run)):
1555
1555
  logger.info(
1556
1556
  f"Created task run {task_run.name!r}. View it in the UI at {task_run_url!r}"
1557
1557
  )
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: prefect-client
3
- Version: 3.4.1.dev1
3
+ Version: 3.4.1.dev2
4
4
  Summary: Workflow orchestration and management.
5
5
  Project-URL: Changelog, https://github.com/PrefectHQ/prefect/releases
6
6
  Project-URL: Documentation, https://docs.prefect.io
@@ -1,7 +1,7 @@
1
1
  prefect/.prefectignore,sha256=awSprvKT0vI8a64mEOLrMxhxqcO-b0ERQeYpA2rNKVQ,390
2
2
  prefect/__init__.py,sha256=iCdcC5ZmeewikCdnPEP6YBAjPNV5dvfxpYCTpw30Hkw,3685
3
3
  prefect/__main__.py,sha256=WFjw3kaYJY6pOTA7WDOgqjsz8zUEUZHCcj3P5wyVa-g,66
4
- prefect/_build_info.py,sha256=S2FR6y1xQ3ZKOstDGJZLDW2Sml9MbnhZ9zMjp4hX7qw,185
4
+ prefect/_build_info.py,sha256=qHCpV6KpRqnsAiZVjqF9RvA2dX5er6gG6lSsXYjxJw4,185
5
5
  prefect/_result_records.py,sha256=S6QmsODkehGVSzbMm6ig022PYbI6gNKz671p_8kBYx4,7789
6
6
  prefect/_versioning.py,sha256=YqR5cxXrY4P6LM1Pmhd8iMo7v_G2KJpGNdsf4EvDFQ0,14132
7
7
  prefect/_waiters.py,sha256=Ia2ITaXdHzevtyWIgJoOg95lrEXQqNEOquHvw3T33UQ,9026
@@ -28,7 +28,7 @@ prefect/task_engine.py,sha256=j0rr8IyBinJmKPD-486RYWKZakhifkEE9ppPCJ9Es-U,62463
28
28
  prefect/task_runners.py,sha256=vzJ1kiW1z90Fkkg21QNhPwjfLoDy6rVsUAToXqb6FUE,16206
29
29
  prefect/task_runs.py,sha256=7LIzfo3fondCyEUpU05sYFN5IfpZigBDXrhG5yc-8t0,9039
30
30
  prefect/task_worker.py,sha256=gMj_rl4EjTrnJ5YSOXinC6y-7KSK7fRQt_UYbZbrrV8,17879
31
- prefect/tasks.py,sha256=EpMw5O1B9pAFVraC0KzytMOKi8iy7ZYnKWRs7WtvogU,74742
31
+ prefect/tasks.py,sha256=DODF_1xPDQVvj_paJDWm43RS46Jdx9_7b2huqT_QyiM,74778
32
32
  prefect/transactions.py,sha256=uIoPNudzJzH6NrMJhrgr5lyh6JxOJQqT1GvrXt69yNw,26068
33
33
  prefect/variables.py,sha256=dCK3vX7TbkqXZhnNT_v7rcGh3ISRqoR6pJVLpoll3Js,8342
34
34
  prefect/_experimental/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -82,9 +82,9 @@ prefect/client/base.py,sha256=7VAMyoy8KtmtI-H8KYsI16_uw9TlrXSrcxChFuMp65Q,26269
82
82
  prefect/client/cloud.py,sha256=jnFgg0osMVDGbLjdWkDX3rQg_0pI_zvfSlU480XCWGQ,6523
83
83
  prefect/client/collections.py,sha256=t9XkVU_onQMZ871L21F1oZnAiPSQeeVfd_MuDEBS3iM,1050
84
84
  prefect/client/constants.py,sha256=Z_GG8KF70vbbXxpJuqW5pLnwzujTVeHbcYYRikNmGH0,29
85
- prefect/client/subscriptions.py,sha256=b2gjoWjrTjshnv_s6zlPN3t0JIe2EKAdMqEzj3-kc6w,3879
85
+ prefect/client/subscriptions.py,sha256=PTYi1Pp7rX-aGdcxZkxRBZkZnpzBt1P17APsm05EDR8,4376
86
86
  prefect/client/utilities.py,sha256=UEJD6nwYg2mD8-GSmru-E2ofXaBlmSFZ2-8T_5rIK6c,3472
87
- prefect/client/orchestration/__init__.py,sha256=O6tItUwU1NBycVPf0PoYVT8bF8gfrVoe9eaSmTQTNFU,55485
87
+ prefect/client/orchestration/__init__.py,sha256=DPbazZvQDgoSZipuNk4z_AILgJbM6zBld-1OsVH55ME,55831
88
88
  prefect/client/orchestration/base.py,sha256=HM6ryHBZSzuHoCFQM9u5qR5k1dN9Bbr_ah6z1UPNbZQ,1542
89
89
  prefect/client/orchestration/routes.py,sha256=_-HC-EmgMhsYdmGwZTxIXlINaVzYuX7RZAvzjHbVp-4,4266
90
90
  prefect/client/orchestration/_artifacts/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -319,7 +319,7 @@ prefect/workers/cloud.py,sha256=dPvG1jDGD5HSH7aM2utwtk6RaJ9qg13XjkA0lAIgQmY,287
319
319
  prefect/workers/process.py,sha256=Yi5D0U5AQ51wHT86GdwtImXSefe0gJf3LGq4r4z9zwM,11090
320
320
  prefect/workers/server.py,sha256=2pmVeJZiVbEK02SO6BEZaBIvHMsn6G8LzjW8BXyiTtk,1952
321
321
  prefect/workers/utilities.py,sha256=VfPfAlGtTuDj0-Kb8WlMgAuOfgXCdrGAnKMapPSBrwc,2483
322
- prefect_client-3.4.1.dev1.dist-info/METADATA,sha256=IFwUWcPPlE7Z-2A_Xn2tZef9WEqSXbfjlRRx0TQnbfI,7471
323
- prefect_client-3.4.1.dev1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
324
- prefect_client-3.4.1.dev1.dist-info/licenses/LICENSE,sha256=MCxsn8osAkzfxKC4CC_dLcUkU8DZLkyihZ8mGs3Ah3Q,11357
325
- prefect_client-3.4.1.dev1.dist-info/RECORD,,
322
+ prefect_client-3.4.1.dev2.dist-info/METADATA,sha256=SrQm0IQPihKCyz3wiIcpgc7slcilDL4wdt9-gV9G2xk,7471
323
+ prefect_client-3.4.1.dev2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
324
+ prefect_client-3.4.1.dev2.dist-info/licenses/LICENSE,sha256=MCxsn8osAkzfxKC4CC_dLcUkU8DZLkyihZ8mGs3Ah3Q,11357
325
+ prefect_client-3.4.1.dev2.dist-info/RECORD,,