infixspeed-cli 0.0.16__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.
- infix_cli/__init__.py +5 -0
- infix_cli/__main__.py +6 -0
- infix_cli/agent-guide.txt +71 -0
- infix_cli/cli_framework.py +96 -0
- infix_cli/command_contract.py +157 -0
- infix_cli/commands/__init__.py +1 -0
- infix_cli/commands/_artifacts.py +142 -0
- infix_cli/commands/_comparison.py +443 -0
- infix_cli/commands/_confirm.py +26 -0
- infix_cli/commands/_control.py +290 -0
- infix_cli/commands/_create.py +351 -0
- infix_cli/commands/_create_output.py +139 -0
- infix_cli/commands/_delete.py +288 -0
- infix_cli/commands/_download.py +459 -0
- infix_cli/commands/_fusion_common.py +191 -0
- infix_cli/commands/_fusion_config.py +394 -0
- infix_cli/commands/_fusion_feedback.py +319 -0
- infix_cli/commands/_fusion_tasks.py +507 -0
- infix_cli/commands/_fusion_tensorboard.py +132 -0
- infix_cli/commands/_jobs.py +312 -0
- infix_cli/commands/_logs.py +210 -0
- infix_cli/commands/_publish.py +123 -0
- infix_cli/commands/_register.py +600 -0
- infix_cli/commands/_register_output.py +231 -0
- infix_cli/commands/_storage_tree.py +62 -0
- infix_cli/commands/admin.py +668 -0
- infix_cli/commands/asset.py +2012 -0
- infix_cli/commands/auth.py +246 -0
- infix_cli/commands/deploy.py +850 -0
- infix_cli/commands/evaluation.py +360 -0
- infix_cli/commands/examples.py +138 -0
- infix_cli/commands/fusion.py +1842 -0
- infix_cli/commands/merge.py +709 -0
- infix_cli/commands/resource.py +127 -0
- infix_cli/commands/spark.py +347 -0
- infix_cli/commands/storage.py +329 -0
- infix_cli/commands/training.py +748 -0
- infix_cli/config.py +311 -0
- infix_cli/config_input.py +217 -0
- infix_cli/context.py +84 -0
- infix_cli/discovery.py +459 -0
- infix_cli/domain/__init__.py +1 -0
- infix_cli/domain/dto/__init__.py +6 -0
- infix_cli/domain/dto/admin.py +413 -0
- infix_cli/domain/dto/asset.py +390 -0
- infix_cli/domain/dto/common.py +136 -0
- infix_cli/domain/dto/evaluation.py +296 -0
- infix_cli/domain/dto/logs.py +98 -0
- infix_cli/domain/dto/resource.py +108 -0
- infix_cli/domain/dto/serving.py +156 -0
- infix_cli/domain/dto/spark.py +241 -0
- infix_cli/domain/dto/storage.py +75 -0
- infix_cli/domain/dto/training.py +272 -0
- infix_cli/domain/enums.py +359 -0
- infix_cli/domain/hyperparams.py +190 -0
- infix_cli/domain/refs.py +108 -0
- infix_cli/domain/resolve.py +619 -0
- infix_cli/errors.py +158 -0
- infix_cli/example_data/__init__.py +1 -0
- infix_cli/example_data/fusion/README.md +128 -0
- infix_cli/example_data/fusion/fusion.json +149 -0
- infix_cli/example_data/fusion/prompts/code.jsonl +16 -0
- infix_cli/example_data/fusion/prompts/math.jsonl +16 -0
- infix_cli/example_data/fusion.zip +0 -0
- infix_cli/example_data/merge/README.md +89 -0
- infix_cli/example_data/merge/merge.json +26 -0
- infix_cli/example_data/merge.zip +0 -0
- infix_cli/http/__init__.py +1 -0
- infix_cli/http/browser_auth.py +160 -0
- infix_cli/http/client.py +575 -0
- infix_cli/http/pagination.py +84 -0
- infix_cli/http/upload.py +254 -0
- infix_cli/main.py +432 -0
- infix_cli/pipeline_config_schema.py +122 -0
- infix_cli/render/__init__.py +79 -0
- infix_cli/render/json_out.py +123 -0
- infix_cli/render/progress.py +62 -0
- infix_cli/render/text.py +233 -0
- infix_cli/update_check.py +177 -0
- infix_cli/waiter.py +93 -0
- infix_cli/workspace.py +158 -0
- infixspeed_cli-0.0.16.dist-info/METADATA +58 -0
- infixspeed_cli-0.0.16.dist-info/RECORD +85 -0
- infixspeed_cli-0.0.16.dist-info/WHEEL +4 -0
- infixspeed_cli-0.0.16.dist-info/entry_points.txt +2 -0
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
"""Upgrade hint: say when a newer CLI has been published, and never more.
|
|
2
|
+
|
|
3
|
+
The PRD's rule is that the CLI does not upgrade itself — it prints a hint and
|
|
4
|
+
leaves the decision to the user, who can silence it with ``--no-update-check``.
|
|
5
|
+
|
|
6
|
+
Three constraints shape everything here:
|
|
7
|
+
|
|
8
|
+
* **It must never cost the user a command.** The lookup runs after the command
|
|
9
|
+
has already produced its output, on a short timeout, and every failure is
|
|
10
|
+
swallowed. A registry that is slow, down, or refusing credentials is not a
|
|
11
|
+
reason for ``infix training create`` to behave differently.
|
|
12
|
+
* **It must not pollute machine-readable output.** The hint goes to stderr,
|
|
13
|
+
and is suppressed entirely under ``--quiet``, ``--output json``, and when
|
|
14
|
+
stderr is not a terminal — a CI log is exactly where nobody wants it.
|
|
15
|
+
* **It must be rare.** Once a day, cached on disk. A user running twenty
|
|
16
|
+
commands in a row makes one registry request, on the first.
|
|
17
|
+
|
|
18
|
+
The index is GitLab's PyPI registry, which requires authentication. The
|
|
19
|
+
credentials come from wherever pip and uv already read them (``~/.netrc``,
|
|
20
|
+
via httpx's ``trust_env``), so anyone who installed the CLI from this registry
|
|
21
|
+
is already set up. Anyone who is not simply never sees a hint, which is the
|
|
22
|
+
correct outcome: a prompt to upgrade is worth nothing to someone whose machine
|
|
23
|
+
cannot reach the package anyway.
|
|
24
|
+
"""
|
|
25
|
+
|
|
26
|
+
from __future__ import annotations
|
|
27
|
+
|
|
28
|
+
import json
|
|
29
|
+
import os
|
|
30
|
+
import re
|
|
31
|
+
import sys
|
|
32
|
+
import time
|
|
33
|
+
from pathlib import Path
|
|
34
|
+
|
|
35
|
+
from infix_cli import __version__
|
|
36
|
+
|
|
37
|
+
_PACKAGE = "infixspeed-cli"
|
|
38
|
+
# The registry the publish job uploads to (.gitlab-ci.yml, publish-cli).
|
|
39
|
+
_DEFAULT_INDEX = (
|
|
40
|
+
"https://gitlab.infix.io/api/v4/projects/platform%2Finfi-studio/packages/pypi/simple"
|
|
41
|
+
)
|
|
42
|
+
_INTERVAL_SECONDS = 24 * 60 * 60
|
|
43
|
+
# Short enough that a hung registry is indistinguishable from a fast "no".
|
|
44
|
+
_TIMEOUT_SECONDS = 1.5
|
|
45
|
+
_CACHE_NAME = "update-check.json"
|
|
46
|
+
|
|
47
|
+
# Distribution filenames on a simple index: infixspeed_cli-0.0.6-py3-none-any.whl
|
|
48
|
+
# and infixspeed_cli-0.0.6.tar.gz. Both spellings of the separator appear.
|
|
49
|
+
_VERSION_RE = re.compile(r"infixspeed[-_]cli-(\d+(?:\.\d+)*)", re.IGNORECASE)
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
def maybe_notify(run) -> None:
|
|
53
|
+
"""Print the upgrade hint, if there is one and the caller wants it.
|
|
54
|
+
|
|
55
|
+
Silent by construction: every early return below is a case where a hint
|
|
56
|
+
would be noise rather than news.
|
|
57
|
+
"""
|
|
58
|
+
try:
|
|
59
|
+
if not _wanted(run):
|
|
60
|
+
return
|
|
61
|
+
latest = _latest_version()
|
|
62
|
+
if latest and _parse(latest) > _parse(__version__):
|
|
63
|
+
_print_hint(latest)
|
|
64
|
+
except Exception:
|
|
65
|
+
# An upgrade hint is the least important thing this process does.
|
|
66
|
+
# Nothing it can go wrong at is worth a traceback or an exit code.
|
|
67
|
+
return
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
def _wanted(run) -> bool:
|
|
71
|
+
if getattr(run, "no_update_check", False):
|
|
72
|
+
return False
|
|
73
|
+
if os.environ.get("INFIX_NO_UPDATE_CHECK", "").strip():
|
|
74
|
+
return False
|
|
75
|
+
if getattr(run, "quiet", False) or getattr(run, "output", "text") != "text":
|
|
76
|
+
return False
|
|
77
|
+
# Not a terminal means a pipe, a file, or CI. None of them are reading
|
|
78
|
+
# advice, and two of them are parsing what they receive.
|
|
79
|
+
return bool(getattr(sys.stderr, "isatty", lambda: False)())
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
def _latest_version() -> str | None:
|
|
83
|
+
"""The newest published version, from cache when it is fresh enough."""
|
|
84
|
+
cache = _cache_path()
|
|
85
|
+
now = time.time()
|
|
86
|
+
cached = _read_cache(cache)
|
|
87
|
+
if cached and now - cached.get("checked_at", 0) < _INTERVAL_SECONDS:
|
|
88
|
+
return cached.get("latest") or None
|
|
89
|
+
|
|
90
|
+
latest = _fetch_latest()
|
|
91
|
+
# Record the attempt either way: a registry that cannot be reached must
|
|
92
|
+
# not be retried on every single command for the rest of the day.
|
|
93
|
+
_write_cache(cache, {"checked_at": now, "latest": latest or ""})
|
|
94
|
+
return latest
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
def _fetch_latest() -> str | None:
|
|
98
|
+
import httpx
|
|
99
|
+
|
|
100
|
+
index = os.environ.get("INFIX_INDEX_URL", "").strip() or _DEFAULT_INDEX
|
|
101
|
+
url = f"{index.rstrip('/')}/{_PACKAGE}"
|
|
102
|
+
with httpx.Client(
|
|
103
|
+
timeout=_TIMEOUT_SECONDS, follow_redirects=True, auth=_index_auth(),
|
|
104
|
+
) as client:
|
|
105
|
+
response = client.get(url)
|
|
106
|
+
if response.status_code >= 400:
|
|
107
|
+
return None
|
|
108
|
+
found = {m.group(1) for m in _VERSION_RE.finditer(response.text)}
|
|
109
|
+
return max(found, key=_parse) if found else None
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
def _index_auth():
|
|
113
|
+
"""Credentials for the package index, or ``None`` to try unauthenticated.
|
|
114
|
+
|
|
115
|
+
``INFIX_INDEX_TOKEN`` first, for CI images that have no home directory to
|
|
116
|
+
put a netrc in. Otherwise the netrc, which is where pip and uv already
|
|
117
|
+
read this host's credentials from — note that httpx's ``trust_env`` does
|
|
118
|
+
*not* cover netrc, so asking for it is the only way to get it.
|
|
119
|
+
"""
|
|
120
|
+
import httpx
|
|
121
|
+
|
|
122
|
+
token = os.environ.get("INFIX_INDEX_TOKEN", "").strip()
|
|
123
|
+
if token:
|
|
124
|
+
# GitLab accepts a personal or deploy token as the password under this
|
|
125
|
+
# fixed username, the same pair twine uploads with.
|
|
126
|
+
return httpx.BasicAuth("gitlab-ci-token", token)
|
|
127
|
+
try:
|
|
128
|
+
return httpx.NetRCAuth()
|
|
129
|
+
except Exception:
|
|
130
|
+
# No netrc, or an unparseable one. An unauthenticated request still
|
|
131
|
+
# works against a public index, and 401s harmlessly against this one.
|
|
132
|
+
return None
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
def _parse(version: str) -> tuple[int, ...]:
|
|
136
|
+
"""Numeric release tuple, zero-padded so 0.1 and 0.1.0 compare equal.
|
|
137
|
+
|
|
138
|
+
Anything that is not a plain release — a dev or rc suffix — sorts below
|
|
139
|
+
every real release rather than raising, because suggesting an upgrade to a
|
|
140
|
+
pre-release would be worse than staying quiet.
|
|
141
|
+
"""
|
|
142
|
+
parts = re.findall(r"\d+", version.split("+")[0])
|
|
143
|
+
numbers = tuple(int(p) for p in parts[:3])
|
|
144
|
+
return numbers + (0,) * (3 - len(numbers))
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
def _print_hint(latest: str) -> None:
|
|
148
|
+
print(
|
|
149
|
+
f"\nA newer infix is available: {__version__} -> {latest}\n"
|
|
150
|
+
f" Upgrade: uv tool upgrade {_PACKAGE} (or: pip install --upgrade {_PACKAGE})\n"
|
|
151
|
+
f" Silence: infix --no-update-check ... (or set INFIX_NO_UPDATE_CHECK=1)",
|
|
152
|
+
file=sys.stderr,
|
|
153
|
+
)
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
def _cache_path() -> Path:
|
|
157
|
+
from infix_cli.config import cache_dir
|
|
158
|
+
|
|
159
|
+
return cache_dir() / _CACHE_NAME
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
def _read_cache(path: Path) -> dict | None:
|
|
163
|
+
try:
|
|
164
|
+
loaded = json.loads(path.read_text(encoding="utf-8"))
|
|
165
|
+
except (OSError, ValueError):
|
|
166
|
+
return None
|
|
167
|
+
return loaded if isinstance(loaded, dict) else None
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
def _write_cache(path: Path, payload: dict) -> None:
|
|
171
|
+
try:
|
|
172
|
+
path.parent.mkdir(parents=True, exist_ok=True)
|
|
173
|
+
path.write_text(json.dumps(payload), encoding="utf-8")
|
|
174
|
+
except OSError:
|
|
175
|
+
# A read-only home is a supported way to run this CLI. The only cost
|
|
176
|
+
# is that the check is not remembered between commands.
|
|
177
|
+
return
|
infix_cli/waiter.py
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"""``--wait``: poll a job (or an asset registration) to a terminal state.
|
|
2
|
+
|
|
3
|
+
默认轮询等待预算为 30 秒;可用 --timeout 显式延长。
|
|
4
|
+
Ctrl-C 只结束本地等待,远端任务继续执行。HTTP 请求另受客户端请求超时限制。
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
import re
|
|
10
|
+
import time
|
|
11
|
+
from typing import Any, Callable
|
|
12
|
+
|
|
13
|
+
from infix_cli.errors import UsageError, WaitTimeout
|
|
14
|
+
|
|
15
|
+
_START_INTERVAL = 5.0
|
|
16
|
+
_MAX_INTERVAL = 30.0
|
|
17
|
+
DEFAULT_WAIT_TIMEOUT = 30.0
|
|
18
|
+
_DURATION_RE = re.compile(r"^(\d+)\s*([smhd])?$", re.IGNORECASE)
|
|
19
|
+
_UNIT_SECONDS = {"s": 1, "m": 60, "h": 3600, "d": 86400}
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def parse_timeout(value: str | None) -> float | None:
|
|
23
|
+
"""``"30m"`` / ``"6h"`` / ``"90"`` (seconds) -> seconds. None delegates to the caller default."""
|
|
24
|
+
if value in (None, ""):
|
|
25
|
+
return None
|
|
26
|
+
match = _DURATION_RE.match(str(value).strip())
|
|
27
|
+
if not match:
|
|
28
|
+
raise UsageError(
|
|
29
|
+
f'Invalid --timeout "{value}".',
|
|
30
|
+
"Use a number with an optional unit: 90, 30m, 6h, 2d.",
|
|
31
|
+
)
|
|
32
|
+
amount, unit = match.groups()
|
|
33
|
+
return float(amount) * _UNIT_SECONDS[(unit or "s").lower()]
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def wait_until_terminal(
|
|
37
|
+
fetch: Callable[[], tuple[str, Any]],
|
|
38
|
+
*,
|
|
39
|
+
terminal: frozenset[str],
|
|
40
|
+
ctx: Any,
|
|
41
|
+
timeout: float | None = None,
|
|
42
|
+
label: str = "job",
|
|
43
|
+
recheck_hint: str = "",
|
|
44
|
+
announce: Callable[[Any, str, str], None] | None = None,
|
|
45
|
+
) -> tuple[str, Any]:
|
|
46
|
+
"""Poll ``fetch`` until the status it returns is terminal.
|
|
47
|
+
|
|
48
|
+
``fetch`` returns ``(status, payload)``; the payload of the final poll is
|
|
49
|
+
returned alongside the status so the caller can render the finished record
|
|
50
|
+
without fetching it a second time.
|
|
51
|
+
"""
|
|
52
|
+
from infix_cli.render import text
|
|
53
|
+
|
|
54
|
+
started = time.monotonic()
|
|
55
|
+
timeout = DEFAULT_WAIT_TIMEOUT if timeout is None else timeout
|
|
56
|
+
interval = _START_INTERVAL
|
|
57
|
+
last_status: str | None = None
|
|
58
|
+
status, payload = fetch()
|
|
59
|
+
|
|
60
|
+
try:
|
|
61
|
+
while status not in terminal:
|
|
62
|
+
if status != last_status:
|
|
63
|
+
(announce or _announce)(ctx, status, label)
|
|
64
|
+
last_status = status
|
|
65
|
+
if timeout is not None and time.monotonic() - started >= timeout:
|
|
66
|
+
raise WaitTimeout(
|
|
67
|
+
f'Timed out waiting for {label} (last status: {status}).',
|
|
68
|
+
recheck_hint or None,
|
|
69
|
+
details={"label": label, "status": status, "id": payload.get("id") if isinstance(payload, dict) else None, "remote_canceled": False},
|
|
70
|
+
)
|
|
71
|
+
remaining = timeout - (time.monotonic() - started)
|
|
72
|
+
time.sleep(max(0, min(interval, remaining)))
|
|
73
|
+
interval = min(interval * 1.5, _MAX_INTERVAL)
|
|
74
|
+
status, payload = fetch()
|
|
75
|
+
except KeyboardInterrupt:
|
|
76
|
+
# The wait is local; the backend keeps going. Saying so — and how to
|
|
77
|
+
# look again — is the difference between "I cancelled my job" and "I
|
|
78
|
+
# stopped watching it".
|
|
79
|
+
# 入口统一输出中断错误;等待中断不对远端发停止请求。
|
|
80
|
+
raise
|
|
81
|
+
|
|
82
|
+
if status != last_status and status not in terminal:
|
|
83
|
+
(announce or _announce)(ctx, status, label)
|
|
84
|
+
return status, payload
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
def _announce(ctx: Any, status: str, label: str) -> None:
|
|
88
|
+
"""Report each state change. Never a spinner: under CI this is a log file."""
|
|
89
|
+
from infix_cli.render import text
|
|
90
|
+
|
|
91
|
+
if ctx.output == "json" or ctx.quiet:
|
|
92
|
+
return
|
|
93
|
+
text.print_message(ctx, f"{label} is {status}...", symbol="")
|
infix_cli/workspace.py
ADDED
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
"""Workspace binding discovery.
|
|
2
|
+
|
|
3
|
+
An API key is bound to exactly one workspace server-side, and every scoped
|
|
4
|
+
endpoint demands an ``X-Workspace-Id`` header that matches that binding
|
|
5
|
+
(``_enforce_api_key_workspace_binding``). The key itself does not carry the id,
|
|
6
|
+
so the CLI derives it once at login and stores it.
|
|
7
|
+
|
|
8
|
+
``GET /api-keys`` lists the caller's keys with a masked ``key_prefix`` — enough
|
|
9
|
+
to identify which row is the key in hand without ever sending the secret
|
|
10
|
+
anywhere but the Authorization header.
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
from __future__ import annotations
|
|
14
|
+
|
|
15
|
+
from typing import Any
|
|
16
|
+
|
|
17
|
+
from infix_cli.errors import AuthError, CliError
|
|
18
|
+
|
|
19
|
+
_MASK = "****"
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def masks_key(displayed: str, api_key: str) -> bool:
|
|
23
|
+
"""Whether a backend-rendered ``key_prefix`` stands for this key.
|
|
24
|
+
|
|
25
|
+
The two services that issue keys mask them differently — permission writes
|
|
26
|
+
``first4****-last3`` (management/service.go ``prefixOf``) while the studio
|
|
27
|
+
backend writes ``first4****last4`` — so rebuilding the string from a
|
|
28
|
+
formula, as this used to, can only ever match one of them. Against the
|
|
29
|
+
other it silently matches nothing, login falls through to the membership
|
|
30
|
+
list, and the CLI stores a workspace the key is not bound to; every command
|
|
31
|
+
afterwards fails with "API key is not bound to this workspace", pointing at
|
|
32
|
+
the workspace rather than at login.
|
|
33
|
+
|
|
34
|
+
Splitting on the mask and checking the ends instead works for both, and for
|
|
35
|
+
whatever a third issuer picks: only the visible characters are compared,
|
|
36
|
+
and they are exactly the ones the backend chose to reveal.
|
|
37
|
+
"""
|
|
38
|
+
head, sep, tail = (displayed or "").partition(_MASK)
|
|
39
|
+
if not sep:
|
|
40
|
+
return False
|
|
41
|
+
# permission puts a separator right after the mask: "sk-a****-XyZ".
|
|
42
|
+
tail = tail.lstrip("-")
|
|
43
|
+
if not head or not tail:
|
|
44
|
+
return False
|
|
45
|
+
key = (api_key or "").strip()
|
|
46
|
+
return key.startswith(head) and key.endswith(tail)
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def discover_workspace(client: Any, api_key: str, me: dict | None = None) -> tuple[str, str]:
|
|
50
|
+
"""Return ``(workspace_id, workspace_name)`` for the key this client uses.
|
|
51
|
+
|
|
52
|
+
Falls back to the user's sole workspace membership when the key listing is
|
|
53
|
+
unavailable (some roles cannot list keys). Raises only when the answer
|
|
54
|
+
would have to be a guess.
|
|
55
|
+
"""
|
|
56
|
+
listed = _listed_keys(client)
|
|
57
|
+
for entry in listed:
|
|
58
|
+
if masks_key(str(entry.get("key_prefix") or ""), api_key):
|
|
59
|
+
workspace_id = str(entry.get("workspace_id") or "")
|
|
60
|
+
if workspace_id:
|
|
61
|
+
return workspace_id, resolve_name(client, workspace_id, me)
|
|
62
|
+
|
|
63
|
+
memberships = list((me or {}).get("workspace_memberships") or [])
|
|
64
|
+
if len(memberships) == 1:
|
|
65
|
+
chosen = str(memberships[0].get("workspace_id") or "")
|
|
66
|
+
# The sole membership is only a good guess while it is consistent with
|
|
67
|
+
# what the key listing says. When every listed key is bound elsewhere,
|
|
68
|
+
# guessing produces a login that reports success and then fails on every
|
|
69
|
+
# subsequent command with "API key is not bound to this workspace" —
|
|
70
|
+
# an error that points at the workspace and hides the real cause. Better
|
|
71
|
+
# to fail here, naming the workspace that would actually work.
|
|
72
|
+
bound = {str(e.get("workspace_id")) for e in listed if e.get("workspace_id")}
|
|
73
|
+
if bound and chosen not in bound:
|
|
74
|
+
raise AuthError(
|
|
75
|
+
"This API key is bound to a workspace you are not a member of.",
|
|
76
|
+
f"Set INFIX_WORKSPACE_ID to one of: {', '.join(sorted(bound))}.",
|
|
77
|
+
)
|
|
78
|
+
return chosen, str(memberships[0].get("workspace_name") or "")
|
|
79
|
+
|
|
80
|
+
if not memberships:
|
|
81
|
+
raise AuthError(
|
|
82
|
+
"This API key is not bound to any workspace visible to you.",
|
|
83
|
+
"Create a key from the workspace you want to use, "
|
|
84
|
+
"or set INFIX_WORKSPACE_ID explicitly.",
|
|
85
|
+
)
|
|
86
|
+
names = ", ".join(str(m.get("workspace_name") or m.get("workspace_id")) for m in memberships)
|
|
87
|
+
raise AuthError(
|
|
88
|
+
"Cannot tell which workspace this API key belongs to.",
|
|
89
|
+
f"Set INFIX_WORKSPACE_ID to one of: {names}.",
|
|
90
|
+
)
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
def _listed_keys(client: Any) -> list[dict]:
|
|
94
|
+
"""The caller's API keys, whichever shape the endpoint returns.
|
|
95
|
+
|
|
96
|
+
permission answers with a page object (``{items, total, page, …}``); the
|
|
97
|
+
studio backend answered with a bare array. Accepting only the array — as
|
|
98
|
+
this used to — skipped the whole match on a permission-backed deployment
|
|
99
|
+
without any sign that it had.
|
|
100
|
+
|
|
101
|
+
Every page is read: permission serves 20 keys a page by default, and a
|
|
102
|
+
key past the first page used to go unmatched — login then fell back to the
|
|
103
|
+
membership list, where the bound-elsewhere check below could refuse a key
|
|
104
|
+
that works, judging it against only the keys it happened to see.
|
|
105
|
+
|
|
106
|
+
Never raises: some roles cannot list keys at all, and that is a case the
|
|
107
|
+
caller already handles by falling back to the membership list. A listing
|
|
108
|
+
that breaks part-way is treated the same as none, for the same reason: a
|
|
109
|
+
partial set of keys is exactly what misleads that check.
|
|
110
|
+
"""
|
|
111
|
+
from infix_cli.http.pagination import iter_items
|
|
112
|
+
|
|
113
|
+
try:
|
|
114
|
+
return [entry for entry in iter_items(client, "/api-keys") if isinstance(entry, dict)]
|
|
115
|
+
except CliError:
|
|
116
|
+
return []
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
def resolve_name(client: Any, workspace_id: str, me: dict | None = None) -> str:
|
|
120
|
+
"""The workspace's display name, or ``""`` when it cannot be established.
|
|
121
|
+
|
|
122
|
+
``/account/me`` carries the name on each membership row, which covers an
|
|
123
|
+
ordinary member in one request. A tenant owner has no membership rows at
|
|
124
|
+
all — the listing comes back empty — so relying on it alone left every
|
|
125
|
+
owner reading the raw id (``admin-test-592fbd``) where the PRD shows a
|
|
126
|
+
name. ``GET /workspaces/{id}`` is the authoritative answer; it costs a
|
|
127
|
+
second request, and only on the path where the first found nothing.
|
|
128
|
+
|
|
129
|
+
Never raises: a name is a nicety, and the id is a usable fallback that
|
|
130
|
+
every caller already handles.
|
|
131
|
+
"""
|
|
132
|
+
if not workspace_id:
|
|
133
|
+
return ""
|
|
134
|
+
name = _name_of(me, workspace_id)
|
|
135
|
+
if name:
|
|
136
|
+
return name
|
|
137
|
+
try:
|
|
138
|
+
detail = client.get(f"/workspaces/{workspace_id}")
|
|
139
|
+
except CliError:
|
|
140
|
+
return ""
|
|
141
|
+
return str((detail or {}).get("name") or "") if isinstance(detail, dict) else ""
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
def _name_of(me: dict | None, workspace_id: str) -> str:
|
|
145
|
+
for entry in (me or {}).get("workspace_memberships") or []:
|
|
146
|
+
if str(entry.get("workspace_id")) == workspace_id:
|
|
147
|
+
return str(entry.get("workspace_name") or "")
|
|
148
|
+
return ""
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
def role_in(me: dict | None, workspace_id: str) -> str:
|
|
152
|
+
"""The caller's role in one workspace; tenant owners outrank membership."""
|
|
153
|
+
if (me or {}).get("is_owner"):
|
|
154
|
+
return "owner"
|
|
155
|
+
for entry in (me or {}).get("workspace_memberships") or []:
|
|
156
|
+
if str(entry.get("workspace_id")) == workspace_id:
|
|
157
|
+
return str(entry.get("role") or "")
|
|
158
|
+
return ""
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: infixspeed-cli
|
|
3
|
+
Version: 0.0.16
|
|
4
|
+
Summary: InfiXspeed platform command-line interface
|
|
5
|
+
License: Proprietary
|
|
6
|
+
Requires-Python: >=3.10
|
|
7
|
+
Requires-Dist: httpx>=0.27
|
|
8
|
+
Requires-Dist: pyyaml<7,>=6.0
|
|
9
|
+
Requires-Dist: rich>=13
|
|
10
|
+
Requires-Dist: tomli>=2.0; python_version < '3.11'
|
|
11
|
+
Requires-Dist: typer>=0.12
|
|
12
|
+
Provides-Extra: dev
|
|
13
|
+
Requires-Dist: pytest>=8; extra == 'dev'
|
|
14
|
+
Requires-Dist: respx>=0.21; extra == 'dev'
|
|
15
|
+
Description-Content-Type: text/markdown
|
|
16
|
+
|
|
17
|
+
# InfiXspeed CLI
|
|
18
|
+
|
|
19
|
+
`infix` is the command-line interface for the InfiXspeed platform. It supports workspace storage, assets, training, evaluation, deployment, Model Fusion, and Model Merge.
|
|
20
|
+
|
|
21
|
+
## Install
|
|
22
|
+
|
|
23
|
+
Requires Python 3.10 or later on macOS or Linux. Install with `uv`:
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
uv tool install infixspeed-cli
|
|
27
|
+
infix --version
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Or install with `pip` in a virtual environment:
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
python3 -m venv ~/.venvs/infixspeed-cli
|
|
34
|
+
source ~/.venvs/infixspeed-cli/bin/activate
|
|
35
|
+
python -m pip install infixspeed-cli
|
|
36
|
+
infix --version
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Sign in
|
|
40
|
+
|
|
41
|
+
The CLI connects to the InfiXspeed A1 deployment at `https://infixspeed-cp.infiseek.cn` by default. Sign in through your browser and choose a workspace to authorize.
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
infix auth login
|
|
45
|
+
infix doctor
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Set `INFIX_API_KEY` using a key from the target workspace to authenticate in automation. For another deployment, pass `--api-url` when signing in or set `INFIX_API_URL` for the current process.
|
|
49
|
+
|
|
50
|
+
## Explore commands
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
infix capabilities --groups -o text
|
|
54
|
+
infix schema fusion run
|
|
55
|
+
infix examples show fusion -o text
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Business commands produce JSON by default. Use `-o text` for readable terminal output.
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
infix_cli/__init__.py,sha256=5OT9O3rRxZK5xEKIg0tEaD3wo4F80uYM0rY-euRPa9g,181
|
|
2
|
+
infix_cli/__main__.py,sha256=1Tsqp3QmsJf5D93QwfvLYmgHTh-_bGsT8BS1QGi5HLg,137
|
|
3
|
+
infix_cli/agent-guide.txt,sha256=mO7KV8Lk4VQDgz2g7r4-jVoSY0VThmXxzEDZLmlDYhI,4286
|
|
4
|
+
infix_cli/cli_framework.py,sha256=bAsvaggTiQlL-OIkpgWVCXJzf7evN5DyRUfMZQVzm3Y,3425
|
|
5
|
+
infix_cli/command_contract.py,sha256=5MjN_2vU_mpDlPhYTqsHHL-LEeyahxkJqPAddQhpIV0,7184
|
|
6
|
+
infix_cli/config.py,sha256=ByxddW99NpIgTnk1OfTi0Ed6qtO233lI0uMgKKAVHNk,11290
|
|
7
|
+
infix_cli/config_input.py,sha256=eBWkdU-hmCOWF4VoP-2orCxnKGf41E6hyCTS44EaIk8,8047
|
|
8
|
+
infix_cli/context.py,sha256=yZJ5nGR-Sj27NoTV-JcxXo-omkVNzSoOys52dyKZSLg,3052
|
|
9
|
+
infix_cli/discovery.py,sha256=6C_yXySKujOkvV6HusFE08s-3ZAyOp2Qs84NWqvZ-Z8,19691
|
|
10
|
+
infix_cli/errors.py,sha256=kB7KNit18AlqjX6_jYY4j0mNxa7kVZu4SRKwrhsTisU,4383
|
|
11
|
+
infix_cli/main.py,sha256=GA5kGIx53Q3aADm9sqAI1FV__V31UwpGiHTyIgf934Q,16870
|
|
12
|
+
infix_cli/pipeline_config_schema.py,sha256=bz852fqOt804Z_kBpDbJ3inul3-DR0eUaW5JaOvrQdg,4487
|
|
13
|
+
infix_cli/update_check.py,sha256=Bq71KN154y1IMXs1MLhLiySq0ZdtKC8QR_fQk7TqZko,6735
|
|
14
|
+
infix_cli/waiter.py,sha256=dbSkdfk3U558xebpovYZBHysRjIgbXXLsGtFHlm0uuc,3473
|
|
15
|
+
infix_cli/workspace.py,sha256=MvLzNvsxG-NKOk2blezU-gRztmWDsR6VPmaY6q8_bPI,6973
|
|
16
|
+
infix_cli/commands/__init__.py,sha256=c5gluXpLL1BD2UH6fMkvwsQ46WNpAhj7ZFJnN8gi07U,47
|
|
17
|
+
infix_cli/commands/_artifacts.py,sha256=ZA112xtRvXaPrwwvldIcJJ-E6s_WWzNbGoBp1x4acDE,5186
|
|
18
|
+
infix_cli/commands/_comparison.py,sha256=m9DHh3nroyBwuzo0HQnTPytNvzDWjXdggTuTKzfAYRE,17190
|
|
19
|
+
infix_cli/commands/_confirm.py,sha256=4MU2Qv63vr578mmnPR3FQPc_Gzv9hmBZ_NM7aRBLucg,778
|
|
20
|
+
infix_cli/commands/_control.py,sha256=i86nSLSSLNPYB2rPQh5tqGNoeFDofgrpcrDGNNmUvus,11712
|
|
21
|
+
infix_cli/commands/_create.py,sha256=ks_SF85I0QAE4NgyF9DQV8Q3w1z8dCR3pheaYgynAmA,12546
|
|
22
|
+
infix_cli/commands/_create_output.py,sha256=KjJhL0gHtj8W0RZppIxgaqtpDG48FvBNZfKjeJYTFWc,5058
|
|
23
|
+
infix_cli/commands/_delete.py,sha256=nfD9otqe8IwkoB_FKSpj4NX0KQb42lT9RScW8PQwELM,11726
|
|
24
|
+
infix_cli/commands/_download.py,sha256=vCANiPkR9-6leqtySvC3sy0X2VRVdiRw1RbndO82DO0,18116
|
|
25
|
+
infix_cli/commands/_fusion_common.py,sha256=BMC4xcpEdBgyhNLSFi5FQIYerRDdVRRVLGGZoUgJPGg,6359
|
|
26
|
+
infix_cli/commands/_fusion_config.py,sha256=73vfLdnl2OzPOp72wIxnkqOoiQP5451oD9PIDbkUtUE,15660
|
|
27
|
+
infix_cli/commands/_fusion_feedback.py,sha256=9JmZN9pM8qNbuhWFIb0WhZUdmklVYp8bwikL7dFRU8g,11900
|
|
28
|
+
infix_cli/commands/_fusion_tasks.py,sha256=KzLqNKgwgpnv18WofSNRXYnXWQOr_S1FfnCkuRMEKyo,18664
|
|
29
|
+
infix_cli/commands/_fusion_tensorboard.py,sha256=XTPJCNNZGF5fdu0ue4EoqeIdvEdFLBlL1k8FsKrtq7c,4810
|
|
30
|
+
infix_cli/commands/_jobs.py,sha256=Q3BQPHXkbZbBP8uRq1ngZCFbxTLelCi8cnFBPJdWwck,10937
|
|
31
|
+
infix_cli/commands/_logs.py,sha256=gZnviToh4Lrzb2HQChSJtqQEJa7LoGfGk-kP9AHtr5o,7567
|
|
32
|
+
infix_cli/commands/_publish.py,sha256=E-QnLYnENB_WavuH8w38EMQyutnK0cjl1zA-DKzQRjI,4875
|
|
33
|
+
infix_cli/commands/_register.py,sha256=4lCQJaCklSMXcON_22ij8igQEqjTp7id1JF5A65pB-U,23432
|
|
34
|
+
infix_cli/commands/_register_output.py,sha256=2CM2QtuHBANZxJHL27N3ja9PV0T3I-Uj_1dOE1TarI0,8997
|
|
35
|
+
infix_cli/commands/_storage_tree.py,sha256=DrH4JQFUfQ9gzFbA04ilpKFii0ZAvXw2gyk13woZTbI,2292
|
|
36
|
+
infix_cli/commands/admin.py,sha256=vsajSZP8Td6x5qSlHNLYtbGs_Hyi5DeRciZTFG038UM,26638
|
|
37
|
+
infix_cli/commands/asset.py,sha256=uwkwYHMeTF3Q08q64dEA9sQhQwQzsRUaFVmpRyDmUVs,86038
|
|
38
|
+
infix_cli/commands/auth.py,sha256=t9TwpktC5HMV8x-I07L6UdsfvHuStiQHTatMPyBLekA,9475
|
|
39
|
+
infix_cli/commands/deploy.py,sha256=oVJzqq5bdmDLW5z5pOzQZohJ5d3SJhAOaQul-Ulk3to,35004
|
|
40
|
+
infix_cli/commands/evaluation.py,sha256=DHiF9W3FDHmlIXvprj7QHgAeBYX7PRnh0qaOmJoITLw,15345
|
|
41
|
+
infix_cli/commands/examples.py,sha256=7vQEvkQI5BLc4MDd83wJVVq9kxBFjQCIjWtskmjKfhU,4953
|
|
42
|
+
infix_cli/commands/fusion.py,sha256=pDqT75sN8a9l2DwxJwHc-BSD_c-xwH7GQe0Qm31qRvA,64487
|
|
43
|
+
infix_cli/commands/merge.py,sha256=RjaHbZdhcWu8e8eI9yrJVV4X0RRS33VBLQQnVOmgZ1I,24075
|
|
44
|
+
infix_cli/commands/resource.py,sha256=P3gRwJrxV3hisiNzKr_PBNk68jIkcqrLD7tKo1UlfDY,5034
|
|
45
|
+
infix_cli/commands/spark.py,sha256=ZuVogw0fItQx2j9_gnofBxetrGPhMoP_iO_b5KCpX6s,13997
|
|
46
|
+
infix_cli/commands/storage.py,sha256=vEzvW5MwobJySSStlpJuEOuLOQzD3Ph-bWkJOpq6JIo,11580
|
|
47
|
+
infix_cli/commands/training.py,sha256=erpZa_UOGi984R6Y6Vr0PkQt49feDQq3gjTg6CremkM,30328
|
|
48
|
+
infix_cli/domain/__init__.py,sha256=nxP-jRUpNDci3EJ2k4qfxGppCp7UtDGA8fe1SLm4j4I,65
|
|
49
|
+
infix_cli/domain/enums.py,sha256=IzuOzJN_7OVZWPptaF5QFBx_GzB13oiL3keqjB7jcy0,11819
|
|
50
|
+
infix_cli/domain/hyperparams.py,sha256=jOFTEGSJyUT-_Addf23dGtfsrkusqasBZpdZzerhL9k,6168
|
|
51
|
+
infix_cli/domain/refs.py,sha256=zevjXB9B6Yi6YnHLL8A6JyK84wEmFRwXUcY-IffAP9Q,3719
|
|
52
|
+
infix_cli/domain/resolve.py,sha256=eIR7hXp3z0Ouzt50Ksq1D8a0s6SB0y_iell9fPEWIvY,24112
|
|
53
|
+
infix_cli/domain/dto/__init__.py,sha256=_e7QCmNAfZWxyu2sBYS8dEYy5PsFxhfLEazbjxVU6uM,219
|
|
54
|
+
infix_cli/domain/dto/admin.py,sha256=eMpAan4QrkIzlHQIOWmkfT5LnS1N0I-Tm7dvvR5nWB0,13472
|
|
55
|
+
infix_cli/domain/dto/asset.py,sha256=nQGuoay3mdS7XOchzxMHgYuZqTw-810biSuPWT3pe-Q,14999
|
|
56
|
+
infix_cli/domain/dto/common.py,sha256=BQIxaZU8YZsJjCE_T4orSsVIn7jdn0nIXtYBMHZ2yHw,4451
|
|
57
|
+
infix_cli/domain/dto/evaluation.py,sha256=b5z-Bbgz6vu7NoFayx36kMDOxXlSJRqn0TWHk_-P8ew,12058
|
|
58
|
+
infix_cli/domain/dto/logs.py,sha256=QZNd5aVK40MoiaIc4RC1QEDNTCOvOedV_-z4zhoF_wc,3097
|
|
59
|
+
infix_cli/domain/dto/resource.py,sha256=MKYL41LzwYAhHpFh475WA4nKfSWMN08SDygZKBoU8SA,4201
|
|
60
|
+
infix_cli/domain/dto/serving.py,sha256=bTlJVIy-CCzD9sPn2ytO0FqwUxlRJ4_iOjIoAwPUHl8,5885
|
|
61
|
+
infix_cli/domain/dto/spark.py,sha256=ZafAoZ0NQQ3keT4tuL5UOAvNtS9xDssEOa_zEipKBuY,9529
|
|
62
|
+
infix_cli/domain/dto/storage.py,sha256=LXVzX5Ih-OL-vry8Yd0PCGqeOZKyKgxS9bQ9TjQhqN8,2315
|
|
63
|
+
infix_cli/domain/dto/training.py,sha256=qa1Hu-zw_wsTMibEaHauUf7IvCWMz3foZwpFYu2UzAw,11153
|
|
64
|
+
infix_cli/example_data/__init__.py,sha256=QuVtWv2j8daMnW_XhzXkhZHEJaMJTzf6TAMdUjvaXYs,94
|
|
65
|
+
infix_cli/example_data/fusion.zip,sha256=C3OnAaRylUwEC2s7z7Kl6It98U6CyvmtPpJMCeS8KtY,7031
|
|
66
|
+
infix_cli/example_data/merge.zip,sha256=yBNznWU7oOPo2l4CrO_ZuMvsMaaJ7U8aY9g9cS4pIMU,3521
|
|
67
|
+
infix_cli/example_data/fusion/README.md,sha256=G3ydwszPV5tev0-IBznYq0645gpn2GM0nQncwjI4DrQ,6956
|
|
68
|
+
infix_cli/example_data/fusion/fusion.json,sha256=qS61em7HDxwM1OfYmGoPwEz2HQZe1nbw-9Gr7j0bqs0,3656
|
|
69
|
+
infix_cli/example_data/fusion/prompts/code.jsonl,sha256=rUCLjNRD9-uNv-6mVUrCMM3jOtHPUah52pbqJv7GpFE,3187
|
|
70
|
+
infix_cli/example_data/fusion/prompts/math.jsonl,sha256=11xwLiHZWrPMs1Uip7t6z9XQLdvE-l4ywz-WP-yxYjk,2984
|
|
71
|
+
infix_cli/example_data/merge/README.md,sha256=4_U1mK88ul0qkRD91atLgT4nVMWIK-fgmP7EUk8vnkM,4960
|
|
72
|
+
infix_cli/example_data/merge/merge.json,sha256=RTnvB-6fCfHN8v5iw2cfpPDAukw_JeUG5BrRu8hhxyw,690
|
|
73
|
+
infix_cli/http/__init__.py,sha256=e5FQB2VGRCQefx3b9IF2VhhQw6WpV-21_IqFCtdYIbI,60
|
|
74
|
+
infix_cli/http/browser_auth.py,sha256=v0kO0xkY8iU7G1jF6OhnUXljswo5t5Q6HbMVCHorF8I,6497
|
|
75
|
+
infix_cli/http/client.py,sha256=YS3z5SrDNTX52bbBIod1finrwjPHuIqfXN2ukcw8R3k,22322
|
|
76
|
+
infix_cli/http/pagination.py,sha256=bx0_8JMnd_ECn4Agljqi1tB64IDwCg0gcVYPzWKnBZY,2719
|
|
77
|
+
infix_cli/http/upload.py,sha256=J6aip_5UkbT5MeDnO_qUPuTDIc_8e6za-GybMNx8JY0,9180
|
|
78
|
+
infix_cli/render/__init__.py,sha256=qLFp8SdekQrG461SX6evdvmHWqGaxgQgCV20ix_hlHo,2510
|
|
79
|
+
infix_cli/render/json_out.py,sha256=teFope58oGgYStJcocU2pbbXNmaxO5IWBytl1zQjhmY,4140
|
|
80
|
+
infix_cli/render/progress.py,sha256=aUOHMGe2e5CdSKnvTw1-AfVI-T___4oOPn9wm5tYzME,1786
|
|
81
|
+
infix_cli/render/text.py,sha256=ccxZ1G6dQHn9IH4zRtHdw7LjdKgZfFbgZfT7T6Lv_MY,8391
|
|
82
|
+
infixspeed_cli-0.0.16.dist-info/METADATA,sha256=z_NsT-8RjTjsAjGpFB3CnyVC-mYou_bsyP3B-Qtgb0w,1623
|
|
83
|
+
infixspeed_cli-0.0.16.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
|
|
84
|
+
infixspeed_cli-0.0.16.dist-info/entry_points.txt,sha256=fyHfN1IA-caECYZ8w2PjZRr0avkkz0_Dkx2x3O45kgo,45
|
|
85
|
+
infixspeed_cli-0.0.16.dist-info/RECORD,,
|