zenml-nightly 0.71.0.dev20241209__py3-none-any.whl → 0.71.0.dev20241211__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.
zenml/VERSION CHANGED
@@ -1 +1 @@
1
- 0.71.0.dev20241209
1
+ 0.71.0.dev20241211
zenml/cli/server.py CHANGED
@@ -587,25 +587,6 @@ def server_list(verbose: bool = False, all: bool = False) -> None:
587
587
  accessible_pro_servers = client.tenant.list(member_only=not all)
588
588
  except AuthorizationException as e:
589
589
  cli_utils.warning(f"ZenML Pro authorization error: {e}")
590
- else:
591
- if not all:
592
- accessible_pro_servers = [
593
- s
594
- for s in accessible_pro_servers
595
- if s.status == TenantStatus.AVAILABLE
596
- ]
597
-
598
- if not accessible_pro_servers:
599
- cli_utils.declare(
600
- "No ZenML Pro servers that are accessible to the current "
601
- "user could be found."
602
- )
603
- if not all:
604
- cli_utils.declare(
605
- "Hint: use the `--all` flag to show all ZenML servers, "
606
- "including those that the client is not currently "
607
- "authorized to access or are not running."
608
- )
609
590
 
610
591
  # We update the list of stored ZenML Pro servers with the ones that the
611
592
  # client is a member of
@@ -633,6 +614,25 @@ def server_list(verbose: bool = False, all: bool = False) -> None:
633
614
  stored_server.update_server_info(accessible_server)
634
615
  pro_servers.append(stored_server)
635
616
 
617
+ if not all:
618
+ accessible_pro_servers = [
619
+ s
620
+ for s in accessible_pro_servers
621
+ if s.status == TenantStatus.AVAILABLE
622
+ ]
623
+
624
+ if not accessible_pro_servers:
625
+ cli_utils.declare(
626
+ "No ZenML Pro servers that are accessible to the current "
627
+ "user could be found."
628
+ )
629
+ if not all:
630
+ cli_utils.declare(
631
+ "Hint: use the `--all` flag to show all ZenML servers, "
632
+ "including those that the client is not currently "
633
+ "authorized to access or are not running."
634
+ )
635
+
636
636
  elif pro_servers:
637
637
  cli_utils.warning(
638
638
  "The ZenML Pro authentication has expired. Please re-login "
@@ -4349,46 +4349,74 @@ class RestZenStore(BaseZenStore):
4349
4349
  {source_context.name: source_context.get().value}
4350
4350
  )
4351
4351
 
4352
- try:
4353
- return self._handle_response(
4354
- self.session.request(
4355
- method,
4356
- url,
4357
- params=params,
4358
- verify=self.config.verify_ssl,
4359
- timeout=timeout or self.config.http_timeout,
4360
- **kwargs,
4361
- )
4362
- )
4363
- except CredentialsNotValid:
4364
- # NOTE: CredentialsNotValid is raised only when the server
4365
- # explicitly indicates that the credentials are not valid and they
4366
- # can be thrown away.
4367
-
4368
- # We authenticate or re-authenticate here and then try the request
4369
- # again, this time with a valid API token in the header.
4370
- self.authenticate(
4371
- # If the last request was authenticated with an API token,
4372
- # we force a re-authentication to get a fresh token.
4373
- force=self._api_token is not None
4374
- )
4375
-
4376
- try:
4377
- return self._handle_response(
4378
- self.session.request(
4379
- method,
4380
- url,
4381
- params=params,
4382
- verify=self.config.verify_ssl,
4383
- timeout=self.config.http_timeout,
4384
- **kwargs,
4352
+ # If the server replies with a credentials validation (401 Unauthorized)
4353
+ # error, we (re-)authenticate and retry the request here in the
4354
+ # following cases:
4355
+ #
4356
+ # 1. initial authentication: the last request was not authenticated
4357
+ # with an API token.
4358
+ # 2. re-authentication: the last request was authenticated with an API
4359
+ # token that was rejected by the server. This is to cover the case
4360
+ # of expired tokens that can be refreshed by the client automatically
4361
+ # without user intervention from other sources (e.g. API keys).
4362
+ #
4363
+ # NOTE: it can happen that the same request is retried here for up to
4364
+ # two times: once after initial authentication and once after
4365
+ # re-authentication.
4366
+ re_authenticated = False
4367
+ while True:
4368
+ try:
4369
+ return self._handle_response(
4370
+ self.session.request(
4371
+ method,
4372
+ url,
4373
+ params=params,
4374
+ verify=self.config.verify_ssl,
4375
+ timeout=timeout or self.config.http_timeout,
4376
+ **kwargs,
4377
+ )
4385
4378
  )
4386
- )
4387
- except CredentialsNotValid as e:
4388
- raise CredentialsNotValid(
4389
- "The current credentials are no longer valid. Please log in "
4390
- "again using 'zenml login'."
4391
- ) from e
4379
+ except CredentialsNotValid as e:
4380
+ # NOTE: CredentialsNotValid is raised only when the server
4381
+ # explicitly indicates that the credentials are not valid and
4382
+ # they can be thrown away or when the request is not
4383
+ # authenticated at all.
4384
+
4385
+ if self._api_token is None:
4386
+ # The last request was not authenticated with an API
4387
+ # token at all. We authenticate here and then try the
4388
+ # request again, this time with a valid API token in the
4389
+ # header.
4390
+ logger.debug(
4391
+ f"The last request was not authenticated: {e}\n"
4392
+ "Re-authenticating and retrying..."
4393
+ )
4394
+ self.authenticate()
4395
+ elif not re_authenticated:
4396
+ # The last request was authenticated with an API token
4397
+ # that was rejected by the server. We attempt a
4398
+ # re-authentication here and then retry the request.
4399
+ logger.debug(
4400
+ "The last request was authenticated with an API token "
4401
+ f"that was rejected by the server: {e}\n"
4402
+ "Re-authenticating and retrying..."
4403
+ )
4404
+ re_authenticated = True
4405
+ self.authenticate(
4406
+ # Ignore the current token and force a re-authentication
4407
+ force=True
4408
+ )
4409
+ else:
4410
+ # The last request was made after re-authenticating but
4411
+ # still failed. Bailing out.
4412
+ logger.debug(
4413
+ f"The last request failed after re-authenticating: {e}\n"
4414
+ "Bailing out..."
4415
+ )
4416
+ raise CredentialsNotValid(
4417
+ "The current credentials are no longer valid. Please "
4418
+ "log in again using 'zenml login'."
4419
+ ) from e
4392
4420
 
4393
4421
  def get(
4394
4422
  self,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: zenml-nightly
3
- Version: 0.71.0.dev20241209
3
+ Version: 0.71.0.dev20241211
4
4
  Summary: ZenML: Write production-ready ML code.
5
5
  Home-page: https://zenml.io
6
6
  License: Apache-2.0
@@ -6,7 +6,7 @@ RELEASE_NOTES.md,sha256=vXcUYeQObADBY79bTVCn6mwBs-81i5iKWIq5BCTo_Fc,397266
6
6
  ROADMAP.md,sha256=hiLSmr16BH8Dfx7SaQM4JcXCGCVl6mFZPFAwJeDTrJU,407
7
7
  SECURITY.md,sha256=9DepA8y03yvCZLHEfcXLTDH4lUyKHquAdukBsccNN7c,682
8
8
  zenml/README.md,sha256=827dekbOWAs1BpW7VF1a4d7EbwPbjwccX-2zdXBENZo,1777
9
- zenml/VERSION,sha256=MbgImS2fal6QhIKh19ZP5ftYGf39W9LkR8FSgZOJlDQ,19
9
+ zenml/VERSION,sha256=-GVk175N9G5c6rMDVfwSHnCa08R-RA89DJQhwj-6vg0,19
10
10
  zenml/__init__.py,sha256=SkMObQA41ajqdZqGErN00S1Vf3KAxpLvbZ-OBy5uYoo,2130
11
11
  zenml/actions/__init__.py,sha256=mrt6wPo73iKRxK754_NqsGyJ3buW7RnVeIGXr1xEw8Y,681
12
12
  zenml/actions/base_action.py,sha256=UcaHev6BTuLDwuswnyaPjdA8AgUqB5xPZ-lRtuvf2FU,25553
@@ -51,7 +51,7 @@ zenml/cli/model_registry.py,sha256=cNAZ3iBa0ofdMD8inQil05yLJq7rWKgadSKMmVdlHOQ,2
51
51
  zenml/cli/pipeline.py,sha256=ZK_J_GE1OGZkLCBsdTiHnSh7BBp29QiigtxvQNifxAc,19228
52
52
  zenml/cli/secret.py,sha256=2WxDYg6iodnAVSbVJQvQEYWEgcy0oytcSBVnnyN0JOw,20135
53
53
  zenml/cli/served_model.py,sha256=3w1UcAbg6Geu37fr7ej1_81GBCt3fF7j3Ge799YE4Mc,14974
54
- zenml/cli/server.py,sha256=vmNThi0nwNQoNAmLkA_kwcudoNrqR2wVcWNA7y7vfSI,25519
54
+ zenml/cli/server.py,sha256=JbvRyc1Ha2LPGNVtZhJzZeTK0w9Z54SHBbjos1UWu54,25438
55
55
  zenml/cli/service_accounts.py,sha256=kl2YSUCsfy3V5ezjbnEjy7i29QgHw-UhLr26rdvz938,17789
56
56
  zenml/cli/service_connectors.py,sha256=9VQc3eBaezRWWptL-UJJXbr6ILLWZIESDkDCTq4MsaQ,74319
57
57
  zenml/cli/stack.py,sha256=VFbwx7YRq75QoCYcE7jXAMX9ugXSTkhfxl4ejCoDJQQ,67405
@@ -1242,7 +1242,7 @@ zenml/zen_stores/migrations/versions/ec6307720f92_simplify_model_version_links.p
1242
1242
  zenml/zen_stores/migrations/versions/f3b3964e3a0f_add_oauth_devices.py,sha256=2CR4R-7Vx6j_AXxo-e5Guy6OX-ZnS47HSKSGfqlO-y0,3065
1243
1243
  zenml/zen_stores/migrations/versions/f49904a80aa7_increase_length_of_artifact_table_sources.py,sha256=kLgfDUnQdAb5_SyFx3VKXDLC0YbuBKf9iXRDNeBin7Q,1618
1244
1244
  zenml/zen_stores/migrations/versions/fbd7f18ced1e_increase_step_run_field_lengths.py,sha256=kn-ng5EHe_mmLfffIFbz7T59z-to3oMx8III_4wOsz4,1956
1245
- zenml/zen_stores/rest_zen_store.py,sha256=lVhqMKEG6Z4dIiTxojeO-9rS97A_0PSC2gUsypsIv0k,157687
1245
+ zenml/zen_stores/rest_zen_store.py,sha256=jCZXIhV_ylTzltN2pxCQ3UevmvZfggtyVHqzu75gHlc,159507
1246
1246
  zenml/zen_stores/schemas/__init__.py,sha256=vMb0Pyf94aMWZDWpPKuRaxNoMsTp9DZNKSQScm9Vd5I,4339
1247
1247
  zenml/zen_stores/schemas/action_schemas.py,sha256=vNnDF4zRy0eWgNwtcU7yY0JXyqe4I3Nns2LHRHWwiDs,6293
1248
1248
  zenml/zen_stores/schemas/api_key_schemas.py,sha256=pCvoTSXSHz-im6aRt-opSBnmIhw3wDRIsi-NJP5WtCQ,7243
@@ -1288,8 +1288,8 @@ zenml/zen_stores/secrets_stores/sql_secrets_store.py,sha256=Bq1djrUP9saoD7vECjS7
1288
1288
  zenml/zen_stores/sql_zen_store.py,sha256=UG37nByum6t-YmLF4KRPJFpLvVl-JMRyPYtDXO1uvE8,408356
1289
1289
  zenml/zen_stores/template_utils.py,sha256=EKYBgmDLTS_PSMWaIO5yvHPLiQvMqHcsAe6NUCrv-i4,9068
1290
1290
  zenml/zen_stores/zen_store_interface.py,sha256=vf2gKBWfUUPtcGZC35oQB6pPNVzWVyQC8nWxVLjfrxM,92692
1291
- zenml_nightly-0.71.0.dev20241209.dist-info/LICENSE,sha256=wbnfEnXnafPbqwANHkV6LUsPKOtdpsd-SNw37rogLtc,11359
1292
- zenml_nightly-0.71.0.dev20241209.dist-info/METADATA,sha256=jZPN5hID6PCMHflRcmW9ls-8_IAhSbEZlSvSNxuNzb4,21215
1293
- zenml_nightly-0.71.0.dev20241209.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
1294
- zenml_nightly-0.71.0.dev20241209.dist-info/entry_points.txt,sha256=QK3ETQE0YswAM2mWypNMOv8TLtr7EjnqAFq1br_jEFE,43
1295
- zenml_nightly-0.71.0.dev20241209.dist-info/RECORD,,
1291
+ zenml_nightly-0.71.0.dev20241211.dist-info/LICENSE,sha256=wbnfEnXnafPbqwANHkV6LUsPKOtdpsd-SNw37rogLtc,11359
1292
+ zenml_nightly-0.71.0.dev20241211.dist-info/METADATA,sha256=UC5kQiqGin_DlilJ40MloYxiEPLcFgUqOdebUbTpZcU,21215
1293
+ zenml_nightly-0.71.0.dev20241211.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
1294
+ zenml_nightly-0.71.0.dev20241211.dist-info/entry_points.txt,sha256=QK3ETQE0YswAM2mWypNMOv8TLtr7EjnqAFq1br_jEFE,43
1295
+ zenml_nightly-0.71.0.dev20241211.dist-info/RECORD,,