kalfa 3.0.0.dev0__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.
- kalfa/__init__.py +19 -0
- kalfa/api.py +284 -0
- kalfa/board/__init__.py +1 -0
- kalfa/board/answers.py +419 -0
- kalfa/board/server.py +536 -0
- kalfa/board/static/api.js +176 -0
- kalfa/board/static/app.js +122 -0
- kalfa/board/static/board.css +228 -0
- kalfa/board/static/charts.css +46 -0
- kalfa/board/static/components/badge.js +14 -0
- kalfa/board/static/components/chart.js +204 -0
- kalfa/board/static/components/diagram.js +857 -0
- kalfa/board/static/components/error.js +17 -0
- kalfa/board/static/components/loading.js +7 -0
- kalfa/board/static/components/progress.js +25 -0
- kalfa/board/static/components/settings.js +418 -0
- kalfa/board/static/components/spark.js +43 -0
- kalfa/board/static/components/table.js +156 -0
- kalfa/board/static/diagram.css +76 -0
- kalfa/board/static/format.js +138 -0
- kalfa/board/static/index.html +34 -0
- kalfa/board/static/plot.js +594 -0
- kalfa/board/static/predictions.css +20 -0
- kalfa/board/static/store.js +215 -0
- kalfa/board/static/views/compare.js +185 -0
- kalfa/board/static/views/home.js +90 -0
- kalfa/board/static/views/record/config.js +81 -0
- kalfa/board/static/views/record/curves.js +137 -0
- kalfa/board/static/views/record/data.js +378 -0
- kalfa/board/static/views/record/files.js +128 -0
- kalfa/board/static/views/record/log.js +164 -0
- kalfa/board/static/views/record/model.js +286 -0
- kalfa/board/static/views/record/overview.js +216 -0
- kalfa/board/static/views/record/plots.js +103 -0
- kalfa/board/static/views/record/predictions.js +834 -0
- kalfa/board/static/views/record.js +179 -0
- kalfa/board/static/views/runs.js +124 -0
- kalfa/board/static/views/sweep.js +282 -0
- kalfa/board/watch.py +87 -0
- kalfa/cli.py +371 -0
- kalfa/commands/__init__.py +0 -0
- kalfa/commands/common.py +8 -0
- kalfa/commands/export.py +117 -0
- kalfa/commands/generate.py +31 -0
- kalfa/commands/guide/__init__.py +101 -0
- kalfa/commands/guide/about.py +93 -0
- kalfa/commands/guide/calls.py +102 -0
- kalfa/commands/guide/sections.py +186 -0
- kalfa/commands/guide/seen.py +307 -0
- kalfa/commands/guide/show.py +106 -0
- kalfa/commands/guide/training.py +333 -0
- kalfa/commands/guide/words.py +97 -0
- kalfa/commands/legos.py +508 -0
- kalfa/commands/plots.py +27 -0
- kalfa/commands/report/__init__.py +64 -0
- kalfa/commands/report/page.py +112 -0
- kalfa/commands/report/predictions.py +216 -0
- kalfa/commands/report/sections.py +356 -0
- kalfa/commands/stop.py +60 -0
- kalfa/commands/sweep/__init__.py +202 -0
- kalfa/commands/sweep/checks.py +98 -0
- kalfa/commands/sweep/plan.py +183 -0
- kalfa/commands/sweep/points.py +123 -0
- kalfa/commands/sweep/runner.py +100 -0
- kalfa/commands/sweep/space.py +67 -0
- kalfa/commands/sweep/strategies.py +228 -0
- kalfa/core/__init__.py +0 -0
- kalfa/core/aliases.py +229 -0
- kalfa/core/build.py +727 -0
- kalfa/core/check.py +550 -0
- kalfa/core/coerce.py +36 -0
- kalfa/core/context.py +149 -0
- kalfa/core/device.py +63 -0
- kalfa/core/errors.py +45 -0
- kalfa/core/graph.py +304 -0
- kalfa/core/history.py +70 -0
- kalfa/core/loop.py +710 -0
- kalfa/core/make.py +121 -0
- kalfa/core/plan.py +156 -0
- kalfa/core/predict.py +290 -0
- kalfa/core/protocols.py +122 -0
- kalfa/core/record.py +347 -0
- kalfa/core/refs.py +88 -0
- kalfa/core/rng.py +100 -0
- kalfa/core/rules.py +513 -0
- kalfa/core/run.py +568 -0
- kalfa/core/spec.py +413 -0
- kalfa/core/state.py +100 -0
- kalfa/core/wrap.py +671 -0
- kalfa/records/__init__.py +24 -0
- kalfa/records/compare.py +86 -0
- kalfa/records/reader.py +561 -0
- kalfa/records/stats/__init__.py +36 -0
- kalfa/records/stats/choices.py +282 -0
- kalfa/records/stats/classes.py +236 -0
- kalfa/records/stats/measures.py +144 -0
- kalfa/records/stats/pairs.py +225 -0
- kalfa/records/stats/tables.py +153 -0
- kalfa/records/sweep.py +244 -0
- kalfa/std/__init__.py +17 -0
- kalfa/std/actions.py +35 -0
- kalfa/std/common.py +56 -0
- kalfa/std/data/__init__.py +1 -0
- kalfa/std/data/base.py +45 -0
- kalfa/std/data/columns.py +190 -0
- kalfa/std/data/flow.py +317 -0
- kalfa/std/data/images.py +443 -0
- kalfa/std/data/options.py +147 -0
- kalfa/std/data/pre.py +84 -0
- kalfa/std/data/splits.py +140 -0
- kalfa/std/data/stream.py +294 -0
- kalfa/std/data/table.py +642 -0
- kalfa/std/data/text.py +436 -0
- kalfa/std/data/transforms.py +327 -0
- kalfa/std/data/weights.py +113 -0
- kalfa/std/data/window.py +135 -0
- kalfa/std/figure.py +37 -0
- kalfa/std/init.py +72 -0
- kalfa/std/loggers.py +105 -0
- kalfa/std/losses.py +161 -0
- kalfa/std/metrics.py +463 -0
- kalfa/std/models.py +122 -0
- kalfa/std/notes.py +1553 -0
- kalfa/std/objectives.py +360 -0
- kalfa/std/plots/__init__.py +75 -0
- kalfa/std/plots/classification.py +207 -0
- kalfa/std/plots/common.py +44 -0
- kalfa/std/plots/curves.py +56 -0
- kalfa/std/plots/images.py +188 -0
- kalfa/std/plots/pairs.py +66 -0
- kalfa/std/plots/predictions.py +154 -0
- kalfa/std/samplers.py +261 -0
- kalfa/std/samples.py +72 -0
- kalfa/std/schedules.py +74 -0
- kalfa/std/steps.py +133 -0
- kalfa/std/triggers.py +135 -0
- kalfa/summary.py +296 -0
- kalfa/tui/__init__.py +4 -0
- kalfa/tui/app.py +107 -0
- kalfa/tui/config.py +61 -0
- kalfa/tui/guide.py +100 -0
- kalfa/tui/jobs.py +97 -0
- kalfa/tui/legos.py +62 -0
- kalfa/tui/records.py +439 -0
- kalfa-3.0.0.dev0.dist-info/METADATA +261 -0
- kalfa-3.0.0.dev0.dist-info/RECORD +148 -0
- kalfa-3.0.0.dev0.dist-info/WHEEL +4 -0
- kalfa-3.0.0.dev0.dist-info/entry_points.txt +2 -0
kalfa/__init__.py
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
from importlib.metadata import PackageNotFoundError, version
|
|
2
|
+
|
|
3
|
+
from .core.aliases import lego, register, resolve
|
|
4
|
+
from .core.errors import BuildError, ConfigError, KalfaError, Problem, RunError
|
|
5
|
+
from .core.protocols import Action, ContextMetric, Logger, Objective, Step, Trigger
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
try:
|
|
9
|
+
__version__ = version("kalfa")
|
|
10
|
+
except PackageNotFoundError:
|
|
11
|
+
__version__ = "3.0.0.dev0"
|
|
12
|
+
|
|
13
|
+
from . import std # noqa: E402
|
|
14
|
+
from .api import Monitor, Record, Rule, Run, Train, call, check, open, predict, run, summarize # noqa: E402
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
__all__ = ["Action", "BuildError", "ConfigError", "ContextMetric", "KalfaError", "Logger", "Monitor", "Objective",
|
|
18
|
+
"Problem", "Record", "Rule", "Run", "RunError", "Step", "Train", "Trigger", "__version__", "call", "check",
|
|
19
|
+
"lego", "predict", "records", "register", "resolve", "run", "std", "summarize"]
|
kalfa/api.py
ADDED
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
from dataclasses import dataclass, field
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
|
|
4
|
+
import pandas
|
|
5
|
+
|
|
6
|
+
from . import summary as summarizing
|
|
7
|
+
from .core import check as checking
|
|
8
|
+
from .core import run as running
|
|
9
|
+
from .core.run import Monitor
|
|
10
|
+
from .records import reader
|
|
11
|
+
from .records import stats as statistics
|
|
12
|
+
from .records.compare import compare as compare_records, config_of
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def call(use, **params):
|
|
16
|
+
return {"use": use, **params}
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
@dataclass
|
|
20
|
+
class Rule:
|
|
21
|
+
when: object = None
|
|
22
|
+
after: str | None = None
|
|
23
|
+
once: bool = True
|
|
24
|
+
set: dict = field(default_factory=dict)
|
|
25
|
+
stop: bool = False
|
|
26
|
+
run: object = None
|
|
27
|
+
|
|
28
|
+
def to_mapping(self):
|
|
29
|
+
out = {}
|
|
30
|
+
if self.when is not None:
|
|
31
|
+
out["when"] = self.when
|
|
32
|
+
if self.after is not None:
|
|
33
|
+
out["after"] = self.after
|
|
34
|
+
if not self.once:
|
|
35
|
+
out["once"] = False
|
|
36
|
+
if self.set:
|
|
37
|
+
out["set"] = dict(self.set)
|
|
38
|
+
if self.stop:
|
|
39
|
+
out["stop"] = True
|
|
40
|
+
if self.run is not None:
|
|
41
|
+
out["run"] = self.run
|
|
42
|
+
return out
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
@dataclass
|
|
46
|
+
class Train:
|
|
47
|
+
epochs: int | None = None
|
|
48
|
+
updates: dict | None = None
|
|
49
|
+
step: object = None
|
|
50
|
+
predicts: str | None = None
|
|
51
|
+
evaluate: list | None = None
|
|
52
|
+
checkpoint: dict | None = None
|
|
53
|
+
report: str | None = None
|
|
54
|
+
track: list | None = None
|
|
55
|
+
log: list | None = None
|
|
56
|
+
|
|
57
|
+
def to_mapping(self):
|
|
58
|
+
return {key: value for key, value in self.__dict__.items() if value is not None}
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
def section_mapping(key, value):
|
|
62
|
+
converter = getattr(value, "to_mapping", None)
|
|
63
|
+
if callable(converter):
|
|
64
|
+
return converter()
|
|
65
|
+
if key == "rules" and isinstance(value, dict):
|
|
66
|
+
return {name: section_mapping(name, rule) for name, rule in value.items()}
|
|
67
|
+
return value
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
class Run:
|
|
71
|
+
def __init__(self, **sections):
|
|
72
|
+
self.sections = sections
|
|
73
|
+
|
|
74
|
+
def to_mapping(self):
|
|
75
|
+
return {key: section_mapping(key, value) for key, value in self.sections.items()}
|
|
76
|
+
|
|
77
|
+
def check(self, sets=(), params=()):
|
|
78
|
+
return checking.check(mappings=[self.to_mapping()], sets=running.pairs(sets),
|
|
79
|
+
params=running.pairs(params, "param"))
|
|
80
|
+
|
|
81
|
+
def start(self, record=None, sets=(), params=(), monitor=None):
|
|
82
|
+
return running.run(mappings=[self.to_mapping()], sets=sets, params=params, record=record,
|
|
83
|
+
monitor=monitor_of(monitor))
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
def sources(source):
|
|
87
|
+
if isinstance(source, dict):
|
|
88
|
+
return (), [source]
|
|
89
|
+
if isinstance(source, (list, tuple)):
|
|
90
|
+
return tuple(str(item) for item in source), []
|
|
91
|
+
return (str(source),), []
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
def check(source, sets=(), params=()):
|
|
95
|
+
paths, mappings = sources(source)
|
|
96
|
+
return checking.check(paths=paths, sets=running.pairs(sets), params=running.pairs(params, "param"),
|
|
97
|
+
mappings=mappings)
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
def monitor_of(monitor):
|
|
101
|
+
if monitor is True:
|
|
102
|
+
return Monitor()
|
|
103
|
+
if monitor is False:
|
|
104
|
+
return Monitor(quiet=True)
|
|
105
|
+
return monitor
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
def run(source, sets=(), params=(), record=None, monitor=None):
|
|
109
|
+
paths, mappings = sources(source)
|
|
110
|
+
return running.run(paths=paths, sets=sets, params=params, mappings=mappings, record=record,
|
|
111
|
+
monitor=monitor_of(monitor))
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
@dataclass
|
|
115
|
+
class Prediction:
|
|
116
|
+
path: str
|
|
117
|
+
table: pandas.DataFrame
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
def predict(directory, data=None, model=None, which=None, device=None):
|
|
121
|
+
path, table = running.predict_record(str(directory), data=data, model=model, which=which, device=device)
|
|
122
|
+
return Prediction(str(path), table)
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
class Record:
|
|
126
|
+
def __init__(self, directory):
|
|
127
|
+
self.directory = str(directory)
|
|
128
|
+
|
|
129
|
+
@property
|
|
130
|
+
def manifest(self):
|
|
131
|
+
return reader.read_manifest(self.directory)
|
|
132
|
+
|
|
133
|
+
@property
|
|
134
|
+
def plan(self):
|
|
135
|
+
return reader.read_plan(self.directory)
|
|
136
|
+
|
|
137
|
+
@property
|
|
138
|
+
def history(self):
|
|
139
|
+
return pandas.DataFrame(reader.read_history(self.directory))
|
|
140
|
+
|
|
141
|
+
@property
|
|
142
|
+
def events(self):
|
|
143
|
+
return reader.read_events(self.directory)
|
|
144
|
+
|
|
145
|
+
@property
|
|
146
|
+
def best(self):
|
|
147
|
+
return reader.best_of(self.directory)
|
|
148
|
+
|
|
149
|
+
def predict(self, data=None, model=None, which=None, device=None):
|
|
150
|
+
return predict(self.directory, data=data, model=model, which=which, device=device).table
|
|
151
|
+
|
|
152
|
+
def generate(self, n=None, which=None, device=None, out=None):
|
|
153
|
+
from .commands.generate import generate_record
|
|
154
|
+
|
|
155
|
+
return generate_record(self.directory, n=n, which=which, device=device, out=out)
|
|
156
|
+
|
|
157
|
+
def plots(self, only=None, which=None, device=None):
|
|
158
|
+
from .commands.plots import draw
|
|
159
|
+
|
|
160
|
+
return draw(self.directory, only=only, which=which, device=device)
|
|
161
|
+
|
|
162
|
+
def export(self, format="state_dict", model=None, which=None, out=None, **options):
|
|
163
|
+
from .commands.export import export_record
|
|
164
|
+
|
|
165
|
+
return export_record(self.directory, format=format, model=model, which=which, out=out, **options)
|
|
166
|
+
|
|
167
|
+
def stop(self, by="api"):
|
|
168
|
+
from .commands.stop import stop_record
|
|
169
|
+
|
|
170
|
+
return stop_record(self.directory, by=by)
|
|
171
|
+
|
|
172
|
+
def resume(self, sets=(), params=()):
|
|
173
|
+
return running.resume(self.directory, sets=sets, params=params)
|
|
174
|
+
|
|
175
|
+
@property
|
|
176
|
+
def summary(self):
|
|
177
|
+
return reader.summary_of(self.directory)
|
|
178
|
+
|
|
179
|
+
@property
|
|
180
|
+
def state(self):
|
|
181
|
+
return reader.state_of(self.manifest)
|
|
182
|
+
|
|
183
|
+
@property
|
|
184
|
+
def progress(self):
|
|
185
|
+
return reader.progress_of(self.directory)
|
|
186
|
+
|
|
187
|
+
@property
|
|
188
|
+
def updates(self):
|
|
189
|
+
return pandas.DataFrame(reader.read_updates(self.directory))
|
|
190
|
+
|
|
191
|
+
@property
|
|
192
|
+
def files(self):
|
|
193
|
+
return reader.files_of(self.directory)
|
|
194
|
+
|
|
195
|
+
@property
|
|
196
|
+
def model_summary(self):
|
|
197
|
+
return reader.model_summary_of(self.directory)
|
|
198
|
+
|
|
199
|
+
@property
|
|
200
|
+
def data_report(self):
|
|
201
|
+
return reader.data_report_of(self.directory)
|
|
202
|
+
|
|
203
|
+
@property
|
|
204
|
+
def config(self):
|
|
205
|
+
return config_of(self.directory)
|
|
206
|
+
|
|
207
|
+
@property
|
|
208
|
+
def fields(self):
|
|
209
|
+
return reader.fields_of(self.directory)
|
|
210
|
+
|
|
211
|
+
@property
|
|
212
|
+
def predictions(self):
|
|
213
|
+
return statistics.read_predictions(self.directory)
|
|
214
|
+
|
|
215
|
+
def series(self, keys=None, limit=None):
|
|
216
|
+
return pandas.DataFrame(reader.series_of(self.directory, keys=keys_of(keys), limit=limit))
|
|
217
|
+
|
|
218
|
+
def steps(self, keys=None, limit=None):
|
|
219
|
+
return pandas.DataFrame(reader.updates_of(self.directory, keys=keys_of(keys), limit=limit))
|
|
220
|
+
|
|
221
|
+
def patches(self):
|
|
222
|
+
return reader.events_of(self.directory, kinds=["patch"])
|
|
223
|
+
|
|
224
|
+
def stats(self, where=None, **options):
|
|
225
|
+
return statistics.prediction_stats(self.directory, plan=self.plan, where=where, **options)
|
|
226
|
+
|
|
227
|
+
def compare(self, *others, keys=None):
|
|
228
|
+
directories = [self.directory] + [directory_of(other) for other in others]
|
|
229
|
+
return compare_records(directories, keys=keys_of(keys))
|
|
230
|
+
|
|
231
|
+
|
|
232
|
+
def keys_of(keys):
|
|
233
|
+
if keys is None:
|
|
234
|
+
return None
|
|
235
|
+
return [keys] if isinstance(keys, str) else list(keys)
|
|
236
|
+
|
|
237
|
+
|
|
238
|
+
def directory_of(record):
|
|
239
|
+
return record.directory if isinstance(record, Record) else str(record)
|
|
240
|
+
|
|
241
|
+
|
|
242
|
+
def open(directory):
|
|
243
|
+
return Record(directory)
|
|
244
|
+
|
|
245
|
+
|
|
246
|
+
def records(root):
|
|
247
|
+
return [Record(directory) for directory in summarizing.under(root)]
|
|
248
|
+
|
|
249
|
+
|
|
250
|
+
def summarize(paths, by=None, mode=None, top=None):
|
|
251
|
+
return summarizing.summarize(paths, by=by, mode=mode, top=top)
|
|
252
|
+
|
|
253
|
+
|
|
254
|
+
def generate(directory, n=None, which=None, device=None, out=None):
|
|
255
|
+
from .commands.generate import generate_record
|
|
256
|
+
|
|
257
|
+
return generate_record(str(directory), n=n, which=which, device=device, out=out)
|
|
258
|
+
|
|
259
|
+
|
|
260
|
+
def export(directory, format="state_dict", model=None, which=None, out=None, **options):
|
|
261
|
+
from .commands.export import export_record
|
|
262
|
+
|
|
263
|
+
return export_record(str(directory), format=format, model=model, which=which, out=out, **options)
|
|
264
|
+
|
|
265
|
+
|
|
266
|
+
def stop(directories, by="api"):
|
|
267
|
+
from .commands.stop import stop_many
|
|
268
|
+
|
|
269
|
+
return stop_many([str(item) for item in ([directories] if isinstance(directories, (str, Path)) else directories)],
|
|
270
|
+
by=by)
|
|
271
|
+
|
|
272
|
+
|
|
273
|
+
def sweep(source, sets=(), params=(), record=None, jobs=1, repair=False, monitor=None):
|
|
274
|
+
from .commands import sweep as sweeping
|
|
275
|
+
|
|
276
|
+
paths, mappings = sources(source)
|
|
277
|
+
plan = sweeping.plan_of(paths=paths, sets=sets, params=params, mappings=mappings, record=record)
|
|
278
|
+
return sweeping.run_local(plan, monitor=monitor, jobs=jobs, repair=repair, log=lambda text: None)
|
|
279
|
+
|
|
280
|
+
|
|
281
|
+
def report(paths, out=None, by=None, mode=None, top=None, points=None):
|
|
282
|
+
from .commands.report import write_report
|
|
283
|
+
|
|
284
|
+
return write_report(paths, out=out, by=by, mode=mode, top=top, points=points)
|
kalfa/board/__init__.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from .server import serve # noqa: F401
|