pragmatiks-cli 16.3.2__tar.gz → 16.3.4__tar.gz

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.
Files changed (24) hide show
  1. {pragmatiks_cli-16.3.2 → pragmatiks_cli-16.3.4}/PKG-INFO +2 -2
  2. {pragmatiks_cli-16.3.2 → pragmatiks_cli-16.3.4}/pyproject.toml +3 -3
  3. {pragmatiks_cli-16.3.2 → pragmatiks_cli-16.3.4}/pyproject.toml.orig +3 -3
  4. {pragmatiks_cli-16.3.2 → pragmatiks_cli-16.3.4}/src/pragma_cli/commands/provider_publish.py +43 -20
  5. {pragmatiks_cli-16.3.2 → pragmatiks_cli-16.3.4}/src/pragma_cli/commands/providers.py +85 -11
  6. {pragmatiks_cli-16.3.2 → pragmatiks_cli-16.3.4}/README.md +0 -0
  7. {pragmatiks_cli-16.3.2 → pragmatiks_cli-16.3.4}/src/pragma_cli/__init__.py +0 -0
  8. {pragmatiks_cli-16.3.2 → pragmatiks_cli-16.3.4}/src/pragma_cli/commands/__init__.py +0 -0
  9. {pragmatiks_cli-16.3.2 → pragmatiks_cli-16.3.4}/src/pragma_cli/commands/auth.py +0 -0
  10. {pragmatiks_cli-16.3.2 → pragmatiks_cli-16.3.4}/src/pragma_cli/commands/completions.py +0 -0
  11. {pragmatiks_cli-16.3.2 → pragmatiks_cli-16.3.4}/src/pragma_cli/commands/config.py +0 -0
  12. {pragmatiks_cli-16.3.2 → pragmatiks_cli-16.3.4}/src/pragma_cli/commands/organizations.py +0 -0
  13. {pragmatiks_cli-16.3.2 → pragmatiks_cli-16.3.4}/src/pragma_cli/commands/projects.py +0 -0
  14. {pragmatiks_cli-16.3.2 → pragmatiks_cli-16.3.4}/src/pragma_cli/commands/provider_output.py +0 -0
  15. {pragmatiks_cli-16.3.2 → pragmatiks_cli-16.3.4}/src/pragma_cli/commands/resources.py +0 -0
  16. {pragmatiks_cli-16.3.2 → pragmatiks_cli-16.3.4}/src/pragma_cli/config.py +0 -0
  17. {pragmatiks_cli-16.3.2 → pragmatiks_cli-16.3.4}/src/pragma_cli/errors.py +0 -0
  18. {pragmatiks_cli-16.3.2 → pragmatiks_cli-16.3.4}/src/pragma_cli/exit_codes.py +0 -0
  19. {pragmatiks_cli-16.3.2 → pragmatiks_cli-16.3.4}/src/pragma_cli/helpers.py +0 -0
  20. {pragmatiks_cli-16.3.2 → pragmatiks_cli-16.3.4}/src/pragma_cli/main.py +0 -0
  21. {pragmatiks_cli-16.3.2 → pragmatiks_cli-16.3.4}/src/pragma_cli/plugins.py +0 -0
  22. {pragmatiks_cli-16.3.2 → pragmatiks_cli-16.3.4}/src/pragma_cli/project_context.py +0 -0
  23. {pragmatiks_cli-16.3.2 → pragmatiks_cli-16.3.4}/src/pragma_cli/py.typed +0 -0
  24. {pragmatiks_cli-16.3.2 → pragmatiks_cli-16.3.4}/src/pragma_cli/teardown.py +0 -0
@@ -1,9 +1,9 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: pragmatiks-cli
3
- Version: 16.3.2
3
+ Version: 16.3.4
4
4
  Summary: Command-line interface for Pragmatiks
5
5
  Requires-Dist: typer>=0.15.3
6
- Requires-Dist: pragmatiks-sdk>=25.1.0
6
+ Requires-Dist: pragmatiks-sdk>=25.2.0
7
7
  Requires-Dist: pyyaml>=6.0.3
8
8
  Requires-Dist: copier>=9.0.0
9
9
  Requires-Dist: rich>=13.9.0
@@ -1,12 +1,12 @@
1
1
  [project]
2
2
  name = "pragmatiks-cli"
3
- version = "16.3.2"
3
+ version = "16.3.4"
4
4
  description = "Command-line interface for Pragmatiks"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.13"
7
7
  dependencies = [
8
8
  "typer>=0.15.3",
9
- "pragmatiks-sdk>=25.1.0",
9
+ "pragmatiks-sdk>=25.2.0",
10
10
  "pyyaml>=6.0.3",
11
11
  "copier>=9.0.0",
12
12
  "rich>=13.9.0",
@@ -55,7 +55,7 @@ exclude = ["**/__pycache__/**"]
55
55
 
56
56
  [tool.commitizen]
57
57
  name = "cz_conventional_commits"
58
- version = "16.3.2"
58
+ version = "16.3.4"
59
59
  version_files = ["pyproject.toml:^version"]
60
60
  tag_format = "v$version"
61
61
  bump_message = "bump: version $current_version → $new_version [skip ci]"
@@ -1,12 +1,12 @@
1
1
  [project]
2
2
  name = "pragmatiks-cli"
3
- version = "16.3.2"
3
+ version = "16.3.4"
4
4
  description = "Command-line interface for Pragmatiks"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.13"
7
7
  dependencies = [
8
8
  "typer>=0.15.3",
9
- "pragmatiks-sdk>=25.1.0",
9
+ "pragmatiks-sdk>=25.2.0",
10
10
  "pyyaml>=6.0.3",
11
11
  "copier>=9.0.0",
12
12
  "rich>=13.9.0",
@@ -56,7 +56,7 @@ exclude = ["**/__pycache__/**"]
56
56
 
57
57
  [tool.commitizen]
58
58
  name = "cz_conventional_commits"
59
- version = "16.3.2"
59
+ version = "16.3.4"
60
60
  version_files = ["pyproject.toml:^version"]
61
61
  tag_format = "v$version"
62
62
  bump_message = "bump: version $current_version → $new_version [skip ci]"
@@ -844,6 +844,27 @@ def compute_watch_end(version: ProviderVersion, watch_started_at: float) -> floa
844
844
  return max(minimum_end, deadline_end)
845
845
 
846
846
 
847
+ class AdmissionWatchError(Exception):
848
+ """Polling a watched version failed; carries the version as the watch last read it.
849
+
850
+ Attributes:
851
+ version: The latest version the watch read successfully, or the
852
+ declared version when no read succeeded.
853
+ error: What failed while polling.
854
+ """
855
+
856
+ def __init__(self, version: ProviderVersion, error: Exception) -> None:
857
+ """Record the version the watch last read and the polling failure.
858
+
859
+ Args:
860
+ version: The latest version the watch read successfully.
861
+ error: What failed while polling.
862
+ """
863
+ super().__init__(f"Watching {version.canonical} {version.version} failed")
864
+ self.version = version
865
+ self.error = error
866
+
867
+
847
868
  def watch_admission(
848
869
  client: PragmaClient,
849
870
  declared_version: DeclaredProviderVersion,
@@ -874,26 +895,29 @@ def watch_admission(
874
895
  still unsettled when the watch bound passed first.
875
896
 
876
897
  Raises:
877
- httpx.HTTPStatusError: If reading the version fails.
878
- httpx.TransportError: If the API cannot be reached.
879
- """ # noqa: DOC502
898
+ AdmissionWatchError: If anything fails while polling, carrying the
899
+ latest version read successfully and the failure.
900
+ """
880
901
  version = declared_version
881
902
 
882
- while version.status not in SETTLED_VERSION_STATUSES:
883
- remaining_seconds = compute_watch_end(version, watch_started_at) - time.monotonic()
903
+ try:
904
+ while version.status not in SETTLED_VERSION_STATUSES:
905
+ remaining_seconds = compute_watch_end(version, watch_started_at) - time.monotonic()
884
906
 
885
- if remaining_seconds <= 0:
886
- break
907
+ if remaining_seconds <= 0:
908
+ break
887
909
 
888
- time.sleep(min(ADMISSION_POLL_INTERVAL_SECONDS, remaining_seconds))
889
- previous_status = version.status
890
- version = client.get_provider_version(version.canonical, version.version)
910
+ time.sleep(min(ADMISSION_POLL_INTERVAL_SECONDS, remaining_seconds))
911
+ previous_status = version.status
912
+ version = client.get_provider_version(version.canonical, version.version)
891
913
 
892
- if is_replaced_publish(version, declared_version):
893
- break
914
+ if is_replaced_publish(version, declared_version):
915
+ break
894
916
 
895
- if version.status != previous_status:
896
- show_status(version.status)
917
+ if version.status != previous_status:
918
+ show_status(version.status)
919
+ except Exception as e:
920
+ raise AdmissionWatchError(version, e) from e
897
921
 
898
922
  return version
899
923
 
@@ -947,8 +971,7 @@ def watch_admission_with_progress(
947
971
  The version as :func:`watch_admission` last read it.
948
972
 
949
973
  Raises:
950
- httpx.HTTPStatusError: If reading the version fails.
951
- httpx.TransportError: If the API cannot be reached.
974
+ AdmissionWatchError: If polling fails (see :func:`watch_admission`).
952
975
  """ # noqa: DOC502
953
976
  starting_label = format_watched_status_label(declared_version, declared_version.status)
954
977
 
@@ -1241,12 +1264,12 @@ def publish(
1241
1264
 
1242
1265
  try:
1243
1266
  last_read_version = watch_admission_with_progress(client, declared_version, watch_started_at)
1244
- except Exception as e:
1245
- reason = format_watch_failure_reason(e)
1267
+ except AdmissionWatchError as e:
1268
+ reason = format_watch_failure_reason(e.error)
1246
1269
  try:
1247
- output_data(build_publish_document(declared_version, declared_version), output)
1270
+ output_data(build_publish_document(e.version, declared_version), output)
1248
1271
  finally:
1249
- report_watch_failure(reason, declared_version, republish_command)
1272
+ report_watch_failure(reason, e.version, republish_command)
1250
1273
 
1251
1274
  output_data(build_publish_document(last_read_version, declared_version), output)
1252
1275
 
@@ -15,9 +15,11 @@ import httpx
15
15
  import typer
16
16
  import yaml
17
17
  from pragma_sdk import (
18
+ InstallationLifecycleState,
18
19
  PragmaClient,
19
20
  ProviderInstallation,
20
21
  ProviderInstallationEvent,
22
+ ProviderModel,
21
23
  ProviderVersion,
22
24
  VersionStatus,
23
25
  )
@@ -395,7 +397,9 @@ def fetch_install_preview(client: PragmaClient, name: str, version: str | None)
395
397
  With an explicit version, reads that version in any status, so a version
396
398
  the caller's organization is still admitting, or one that failed, reaches
397
399
  the install request and its refusal rather than stopping at the catalog.
398
- Without one, reads the catalog entry and previews its latest version.
400
+ Without one, reads the catalog entry and the caller's installations: a
401
+ ``failed`` installation previews its stored version, the one installing
402
+ it again installs, and anything else previews the catalog's latest version.
399
403
 
400
404
  Args:
401
405
  client: Authenticated SDK client.
@@ -411,27 +415,81 @@ def fetch_install_preview(client: PragmaClient, name: str, version: str | None)
411
415
  is not found.
412
416
  httpx.HTTPStatusError: If the read fails with any other status.
413
417
  """ # noqa: DOC502
414
- try:
415
- if version is None:
416
- provider = fetch_with_spinner(f"Fetching provider '{name}'...", lambda: client.get_provider(name))
417
- label = provider.display_name or name
418
- latest_version = provider.latest_version or "latest"
419
- return label, latest_version
418
+ if version is None:
419
+ provider = fetch_catalog_provider(client, name)
420
+ label = provider.display_name or name
421
+ stored_version = fetch_install_again_version(client, name)
422
+ preview_version = stored_version or provider.latest_version or "latest"
423
+
424
+ return label, preview_version
420
425
 
426
+ try:
421
427
  provider_version = fetch_with_spinner(
422
428
  f"Fetching {name} {version}...",
423
429
  lambda: client.get_provider_version(name, version),
424
430
  )
425
431
  return name, provider_version.version
426
432
  except httpx.HTTPStatusError as e:
427
- subject = f"Provider '{name}'" if version is None else f"Version {version} of '{name}'"
428
- report_not_found(e, f"{subject} not found in the store.")
433
+ report_not_found(e, f"Version {version} of '{name}' not found in the store.")
434
+
435
+
436
+ def fetch_catalog_provider(client: PragmaClient, name: str) -> ProviderModel:
437
+ """Fetch a provider's catalog entry for the install preview.
438
+
439
+ Args:
440
+ client: Authenticated SDK client.
441
+ name: Provider name (``org/name``).
442
+
443
+ Returns:
444
+ The catalog entry.
445
+
446
+ Raises:
447
+ typer.Exit: With ``NOT_FOUND_EXIT_CODE`` if the provider is not found.
448
+ httpx.HTTPStatusError: If the read fails with any other status.
449
+ """ # noqa: DOC502
450
+ try:
451
+ return fetch_with_spinner(f"Fetching provider '{name}'...", lambda: client.get_provider(name))
452
+ except httpx.HTTPStatusError as e:
453
+ report_not_found(e, f"Provider '{name}' not found in the store.")
454
+
455
+
456
+ def fetch_install_again_version(client: PragmaClient, name: str) -> str | None:
457
+ """Fetch the version installing ``name`` again without a version installs.
458
+
459
+ Args:
460
+ client: Authenticated SDK client.
461
+ name: Provider name (``org/name``).
462
+
463
+ Returns:
464
+ The stored version (``operation_version``) of the caller's ``failed``
465
+ installation of ``name``, or ``None`` when it has none.
466
+
467
+ Raises:
468
+ httpx.HTTPStatusError: If the read fails.
469
+ """ # noqa: DOC502
470
+ installations = fetch_with_spinner("Fetching installations...", lambda: client.list_installations())
471
+
472
+ for installation in installations:
473
+ if installation.canonical == name and installation.lifecycle_state == InstallationLifecycleState.FAILED:
474
+ return installation.operation_version
475
+
476
+ return None
429
477
 
430
478
 
431
479
  @app.command()
432
480
  def install(
433
481
  name: ProviderNameArgument,
434
- version: Annotated[str | None, typer.Option("--version", "-v", help="Version to install (default: latest)")] = None,
482
+ version: Annotated[
483
+ str | None,
484
+ typer.Option(
485
+ "--version",
486
+ "-v",
487
+ help=(
488
+ "Version to install (default: the latest published version; "
489
+ "installing a failed installation again: its stored version)"
490
+ ),
491
+ ),
492
+ ] = None,
435
493
  config: Annotated[
436
494
  list[str] | None,
437
495
  typer.Option("--config", "-c", help="Configuration key=value pair (repeatable)"),
@@ -1119,6 +1177,22 @@ def format_installation_state(state: str | None) -> str:
1119
1177
  return f"[{color}]{format_installation_state_label(state)}[/{color}]"
1120
1178
 
1121
1179
 
1180
+ def format_running_installation_operation(installation: ProviderInstallation) -> str:
1181
+ """Format an installation's operation for the installed table, only while it runs.
1182
+
1183
+ Args:
1184
+ installation: The installed provider.
1185
+
1186
+ Returns:
1187
+ The operation and its target from :func:`format_installation_operation`
1188
+ while ``operation_running``, or a dim dash once it settled.
1189
+ """
1190
+ if not installation.operation_running:
1191
+ return "[dim]-[/dim]"
1192
+
1193
+ return format_installation_operation(installation.operation_type, installation.operation_version)
1194
+
1195
+
1122
1196
  def format_installation_operation(operation_type: str | None, operation_version: str | None) -> str:
1123
1197
  """Format an operation and the version it targets, such as ``upgrade v3.0.0`` or ``restart v3.0.0``.
1124
1198
 
@@ -1175,7 +1249,7 @@ def print_installed_table(installations: list[ProviderInstallation]) -> None:
1175
1249
  escape(installation.canonical),
1176
1250
  format_installation_state(installation.lifecycle_state),
1177
1251
  format_target_version(installation.installed_version),
1178
- format_installation_operation(installation.operation_type, installation.operation_version),
1252
+ format_running_installation_operation(installation),
1179
1253
  format_optional_value(installation.failure_message),
1180
1254
  )
1181
1255