ap-client 0.3.1.dev1__tar.gz → 0.3.2__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: ap-client
3
- Version: 0.3.1.dev1
3
+ Version: 0.3.2
4
4
  Summary: Agent Platform API Client & CLI
5
5
  Requires-Python: >=3.10
6
6
  Requires-Dist: pyyaml>=6.0
@@ -9,9 +9,9 @@ Requires-Dist: rich>=13.0.0
9
9
  Requires-Dist: typer>=0.9.0
10
10
  Requires-Dist: websockets>=13.0
11
11
  Provides-Extra: all
12
- Requires-Dist: instance-repo[oss]>=1.1.0; extra == 'all'
12
+ Requires-Dist: instance-repo[oss]<2.0.0,>=1.1.2; extra == 'all'
13
13
  Provides-Extra: dataset
14
- Requires-Dist: instance-repo[oss]>=1.1.0; extra == 'dataset'
14
+ Requires-Dist: instance-repo[oss]<2.0.0,>=1.1.2; extra == 'dataset'
15
15
  Description-Content-Type: text/markdown
16
16
 
17
17
  A lightweight Python SDK and command line interface for Agent Platform. It provides helpers for configuring API access and managing templates, datasets, jobs, and groups.
@@ -294,24 +294,6 @@ def _secret_ws_params(workspace_id: Optional[str]) -> Optional[dict]:
294
294
  return {"workspace_id": workspace_id} if workspace_id else None
295
295
 
296
296
 
297
- def _unwrap_data(payload: Any) -> Any:
298
- """Unwrap the apiserver ``{code,message,data}`` envelope when present.
299
-
300
- The dataset-domain detail/create/patch endpoints return a bare JSON body,
301
- but the same handlers are occasionally wrapped by the generic success
302
- envelope. Tolerate both so command code never has to branch: a mapping that
303
- carries ``data`` alongside ``code``/``message`` is treated as an envelope,
304
- anything else is returned verbatim.
305
- """
306
- if (
307
- isinstance(payload, dict)
308
- and "data" in payload
309
- and ("code" in payload or "message" in payload)
310
- ):
311
- return payload["data"]
312
- return payload
313
-
314
-
315
297
  def _split_paged(payload: Any) -> tuple[list[dict], dict]:
316
298
  """Split a ``PagedSuccess`` envelope into ``(records, pagination)``.
317
299
 
@@ -815,26 +815,43 @@ def _print_json_block(data: Any) -> None:
815
815
  typer.echo(json.dumps(data, ensure_ascii=False, indent=2))
816
816
 
817
817
 
818
+ def _format_nested_detail(value: Any) -> str:
819
+ """Nested dict/list for detail views: compact one-liner, pretty JSON when long.
820
+
821
+ A detail view must not silently drop data - the manifest in ``ap instance
822
+ get`` used to be cut mid-JSON by the one-liner preview.
823
+ """
824
+ compact = json.dumps(value, ensure_ascii=False, separators=(",", ":"))
825
+ if len(compact) <= _PLAIN_VALUE_PREVIEW:
826
+ return compact
827
+ return json.dumps(value, ensure_ascii=False, indent=2)
828
+
829
+
818
830
  def _print_detail(data: object) -> None:
819
831
  """Render a single object as an aligned key/value detail view.
820
832
 
821
833
  Top-level scalars become key/value rows (``image`` fields shortened); nested
822
- dict/list fields are shown as compact one-liners. Falls back to JSON for
834
+ dict/list fields are shown as compact one-liners, or pretty-printed across
835
+ multiple lines when the one-liner would not fit. Falls back to JSON for
823
836
  non-dict payloads.
824
837
  """
825
838
  if not isinstance(data, dict):
826
839
  _print_json(data)
827
840
  return
828
- scalar_rows: list[tuple[str, Any]] = []
829
- nested_rows: list[tuple[str, Any]] = []
841
+ rows: list[tuple[str, str]] = []
830
842
  for key, value in data.items():
831
843
  if isinstance(value, (dict, list)):
832
- nested_rows.append((key, value))
844
+ rows.append((key, _format_nested_detail(value)))
833
845
  elif key == "image" and isinstance(value, str):
834
- scalar_rows.append((key, _shorten_image(value)))
846
+ rows.append((key, _shorten_image(value)))
835
847
  else:
836
- scalar_rows.append((key, value))
837
- _print_key_values(scalar_rows + nested_rows, skip_empty=False)
848
+ rows.append((key, _format_plain_value(value, max_len=0)))
849
+ width = max((len(label) for label, _text in rows), default=0)
850
+ indent = " " * (width + 4)
851
+ for label, text in rows:
852
+ if "\n" in text:
853
+ text = text.replace("\n", f"\n{indent}")
854
+ typer.echo(f" {label.ljust(width)}: {text}")
838
855
 
839
856
 
840
857
  def _print_template_get_plain(t: dict) -> None:
@@ -944,7 +961,7 @@ def _print_field_value(value: Any, output_format: str) -> None:
944
961
  _print_formatted(value, "json" if output_format == "plain" else output_format)
945
962
 
946
963
 
947
- def _format_plain_value(value: Any) -> str:
964
+ def _format_plain_value(value: Any, *, max_len: int = _PLAIN_VALUE_PREVIEW) -> str:
948
965
  if value is None:
949
966
  return ""
950
967
  if isinstance(value, (dict, list)):
@@ -952,9 +969,9 @@ def _format_plain_value(value: Any) -> str:
952
969
  else:
953
970
  text = str(value)
954
971
  text = text.replace("\r", "\\r").replace("\n", "\\n")
955
- if len(text) <= _PLAIN_VALUE_PREVIEW:
972
+ if not max_len or len(text) <= max_len:
956
973
  return text
957
- return f"{text[: _PLAIN_VALUE_PREVIEW - 3]}..."
974
+ return f"{text[: max_len - 3]}..."
958
975
 
959
976
 
960
977
  def _print_key_values(rows: list[tuple[str, Any]], *, skip_empty: bool = True) -> None: