cortex-training 0.0.3__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.
- cortex_training/__init__.py +49 -0
- cortex_training/__main__.py +20 -0
- cortex_training/_cli.py +1050 -0
- cortex_training/cli.py +103 -0
- cortex_training/client.py +2866 -0
- cortex_training/peft.py +112 -0
- cortex_training/telemetry.py +526 -0
- cortex_training/tui/__init__.py +23 -0
- cortex_training/tui/__main__.py +109 -0
- cortex_training/tui/app.py +646 -0
- cortex_training/tui/format.py +389 -0
- cortex_training/tui/log_cache.py +415 -0
- cortex_training/wire.py +414 -0
- cortex_training-0.0.3.dist-info/METADATA +143 -0
- cortex_training-0.0.3.dist-info/RECORD +19 -0
- cortex_training-0.0.3.dist-info/WHEEL +5 -0
- cortex_training-0.0.3.dist-info/entry_points.txt +3 -0
- cortex_training-0.0.3.dist-info/licenses/LICENSE +177 -0
- cortex_training-0.0.3.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
# Copyright 2025 Snowflake Inc.
|
|
2
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
#
|
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
# you may not use this file except in compliance with the License.
|
|
6
|
+
# You may obtain a copy of the License at
|
|
7
|
+
#
|
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
#
|
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
# See the License for the specific language governing permissions and
|
|
14
|
+
# limitations under the License.
|
|
15
|
+
|
|
16
|
+
"""Resolve Cortex Training connection arguments and launch the read-only TUI.
|
|
17
|
+
|
|
18
|
+
Connection handling is delegated to ``cortex_training._cli`` so the TUI shares the
|
|
19
|
+
SDK's auth surface: it honours ``cortex-training login`` state, ``--config`` /
|
|
20
|
+
``CORTEX_TRAINING_CONFIG``, the ``CORTEX_TRAINING_*`` / ``SNOWFLAKE_*`` env vars, and explicit
|
|
21
|
+
``--base-url`` (local/mock) or ``--host`` + ``--pat`` flags, exactly like the
|
|
22
|
+
CLI. Run ``cortex-training login config.json`` once and then just
|
|
23
|
+
``cortex-training tui JOB_ID``.
|
|
24
|
+
"""
|
|
25
|
+
|
|
26
|
+
from __future__ import annotations
|
|
27
|
+
|
|
28
|
+
import argparse
|
|
29
|
+
import os
|
|
30
|
+
import sys
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def _build_arg_parser(*, prog: str = "cortex-training tui") -> argparse.ArgumentParser:
|
|
34
|
+
p = argparse.ArgumentParser(
|
|
35
|
+
prog=prog,
|
|
36
|
+
description="Read-only TUI for Cortex Training logs.",
|
|
37
|
+
)
|
|
38
|
+
p.add_argument(
|
|
39
|
+
"job_id", nargs="?", help="Job (session) id to open directly. If omitted, the TUI shows a job picker."
|
|
40
|
+
)
|
|
41
|
+
p.add_argument("--sub-job-id", help="Sub-job id used to scope log sources and routing.")
|
|
42
|
+
p.add_argument(
|
|
43
|
+
"--config",
|
|
44
|
+
dest="config",
|
|
45
|
+
default=os.environ.get("CORTEX_TRAINING_CONFIG"),
|
|
46
|
+
help=(
|
|
47
|
+
"Path to a reusable Cortex Training config or credential JSON file "
|
|
48
|
+
"(same format as the cortex-training CLI config)."
|
|
49
|
+
),
|
|
50
|
+
)
|
|
51
|
+
p.add_argument("--base-url", help="Direct base URL for a local or otherwise compatible server.")
|
|
52
|
+
p.add_argument("--host", help="Snowflake account host for PAT auth.")
|
|
53
|
+
p.add_argument("--pat", help="Programmatic access token.")
|
|
54
|
+
p.add_argument("--database", help="Database containing the endpoint.")
|
|
55
|
+
# Left as None so config-file / env values can fill them; the CLI resolver
|
|
56
|
+
# applies the PUBLIC / cortex-training defaults when nothing is set.
|
|
57
|
+
p.add_argument("--schema", default=None)
|
|
58
|
+
p.add_argument("--endpoint", default=None)
|
|
59
|
+
p.add_argument(
|
|
60
|
+
"--poll-interval",
|
|
61
|
+
type=float,
|
|
62
|
+
default=1.0,
|
|
63
|
+
help="Minimum seconds between log polls per source (request-rate floor).",
|
|
64
|
+
)
|
|
65
|
+
p.add_argument("--poll-timeout", type=float, default=1800.0)
|
|
66
|
+
p.add_argument("--no-verify-ssl", action="store_true")
|
|
67
|
+
return p
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
def run(argv=None, *, prog: str = "cortex-training tui") -> int:
|
|
71
|
+
parser = _build_arg_parser(prog=prog)
|
|
72
|
+
args = parser.parse_args(argv)
|
|
73
|
+
|
|
74
|
+
try:
|
|
75
|
+
from cortex_training.tui.app import CortexTrainingLogTUI
|
|
76
|
+
except ImportError as exc:
|
|
77
|
+
print(
|
|
78
|
+
f"The TUI requires the optional 'textual' dependency: pip install cortex-training ({exc})",
|
|
79
|
+
file=sys.stderr,
|
|
80
|
+
)
|
|
81
|
+
return 2
|
|
82
|
+
|
|
83
|
+
import cortex_training._cli as cli
|
|
84
|
+
|
|
85
|
+
# Reuse the CLI's resolution: --config / login state / env / defaults.
|
|
86
|
+
args = cli._resolve_args(args)
|
|
87
|
+
try:
|
|
88
|
+
args = cli._normalize_connection_args(args)
|
|
89
|
+
except ValueError as exc:
|
|
90
|
+
parser.error(str(exc))
|
|
91
|
+
if not args.database:
|
|
92
|
+
parser.error("provide --database or set CORTEX_TRAINING_DATABASE/SNOWFLAKE_DATABASE")
|
|
93
|
+
if args.base_url is None and (args.host is None or args.pat is None):
|
|
94
|
+
parser.error(
|
|
95
|
+
"no connection configured: run 'cortex-training login config.json', "
|
|
96
|
+
"set CORTEX_TRAINING_CONFIG, pass --config config.json, or pass "
|
|
97
|
+
"--base-url (local/mock) or --host + --pat"
|
|
98
|
+
)
|
|
99
|
+
|
|
100
|
+
client = cli.build_client(args, cli._load_cortex_training_client_class())
|
|
101
|
+
|
|
102
|
+
# job_id is optional: given, we jump straight to that job's logs; omitted,
|
|
103
|
+
# the TUI opens the job picker (list_jobs) so you can choose one.
|
|
104
|
+
CortexTrainingLogTUI(client, args.job_id, sub_job_id=args.sub_job_id, poll_interval=args.poll_interval).run()
|
|
105
|
+
return 0
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
if __name__ == "__main__":
|
|
109
|
+
raise SystemExit(run())
|