Repository navigation
Azathoth 1.6 makes a remote an Azathoth people work on, not only one they
push to. It names, in code, what a remote asks its policy and tells its
audit for every call of the service API, and what a remote's plugins may
build on; a remote answers its requests together rather than one at a
time, and serves every call of the service API, asking and telling as
named; it runs the calls that take minutes as jobs, kept in its database
and followed as they go; api.connect calls a remote as an instance of
its own; every command but a few runs on a remote with --remote; and a
named remote's token may be printed by a command, as an identity
provider's tool prints one. A new example, the model watch, tries the
models released since its last run on your own workflows' benchmarks, and
leaves any that do the same work for less for you to promote. The
database schema moves from version 7 to version 9, as Upgrading From 1.5
below says.
This release changes what the image runs on AWS: the stack's one-off
init task moves its database from schema version 7 to version 9, and its
workers run jobs as 1.5's did. Release validation requires a release that
changes what the stack runs to be deployed to an AWS sandbox before it
ships, and no sandbox was available, so this release was not deployed. The
template was read, the worker run against botocore's Stubber and the S3
tools against a stand-in for S3, as for every release; what only a real
deployment proves, that the stack's workers run jobs on real SQS and S3, is
unproven for 1.6.0, as what 1.5.0, 1.4.0 and 1.3.0 left unproven still is
(Release Validation).
The Action Catalog
Actionnames all 27 actions of the catalog, the protocol's six keeping
their values, andHIGH_PRIVILEGE_ACTIONSthe five that let a caller run
code on the remote, read what should not spread, or let others in
(ADR 0134).AuditEventKindgains a kind for each outcome of an action that changes
something or reads restricted data, so promoting and rolling back are
told apart; each kind names the action it records
(ADR 0134).azathoth.api.callslists every call of the service API once, with the
actions it always asks, the resource it acts on, what more it asks and
when, and what it tells the audit; the calls that name an instance's own
remotes are never served. Every call's docstring, and a new Actions table
in the service API's README, say the same, and tests hold all three
together
(ADR 0134).PermissionDeniedError,permission_denied, is what a call will raise
when a remote's policy refuses it, its message the policy's reason; it is
never aNotFoundError
(ADR 0134).
A Remote Serves Requests Together
- A remote answers requests together. Every call to its seams and
repositories runs off the event loop, at most eight at once, so a slow
policy or a long push holds up no other request,/healthincluded
(ADR 0135). - A transaction may be read-only,
transaction(read_only=True), taking no
write lock; a write in one raisesReadOnlyTransactionError. Everything
a remote reads, it reads so
(ADR 0135). - An SQLite file is put in WAL mode the first time it is opened, so readers
never wait for a writer; it gains-waland-shmfiles beside it while
it is open
(ADR 0135). - A PostgreSQL database keeps a pool of up to eight connections rather than
one; a transaction that finds none free for thirty seconds raises
DatabaseBusyError. A transaction begun inside another on the same
thread raisesNestedTransactionError, on either database
(ADR 0135). - Of two pushes of one lineage built on its latest revision, the second is
told the lineage diverged, never saved as a fork, between the threads of
one server and between servers on one PostgreSQL database. A save with
fast_forwardraisesNotFastForwardErrorwhen it would not build on the
latest
(ADR 0135). azathoth remote serverefuses to serve an SQLite database another
server is already serving: SQLite serves one remote process on one
machine, and PostgreSQL serves more
(ADR 0135).
The Service API on a Remote
- A remote serves every call of the service API at
POST /v1/calls/<NAME>,
its arguments a JSON object by name and its answer the call's result as
JSON, read from the call's method so no route is written by hand; bytes
travel in base64.azathoth.remote.callingsays how each call travels
(ADR 0136). - What a caller changes through a remote is recorded as theirs, under
their principal's name
(ADR 0136). - A call asks the policy its actions about what it names, and each
condition it names before a change is made or restricted data is sent; a
listing leaves out what is refused
(ADR 0136). - The eight calls that take a callback for their events, such as
runs.run,
are answered 501jobuntil a remote runs them on its workers
(ADR 0136). GET /v1/servicesays what a remote serves and its edition, andGET
andPOST /v1/permissionswhat the caller may do on it and on each
resource asked about
(ADR 0136).- A service route refuses with
{"error", "code"}, the code an
ApiError's own, and the status its kind is given
(ADR 0136). - A remote tells its audit before it acts or sends what it read, the push
route too, and follows a change that fails withrequest_failed, a new
kind; an audit that cannot be told stops the request, answered 503
audit_unavailable. A push's audit says how many revisions it offered
(ADR 0136). - A push carrying a process tool asks
import_process_toolfor it, and is
told as one, as importing one is
(ADR 0136). tools.install_standardinstalls the standard tool library through the
service API, andinit,tool install-standardandapi.initialize
install it the same way
(ADR 0136).azathoth remote token createandrevoketell the remote's audit before
the token changes, asoperator:<AUTHOR>, andrevokenow needs an
author ascreatedoes
(ADR 0136).- A remote reads which providers are on, and their keys, when
remote servestarts
(ADR 0136).
A Client for the Service API
api.connect(url)returns an instance whose every call is sent to the
remote, andinstance.remote(name).connect()connects to a remote an
instance named, with the token its own variable holds
(ADR 0137).api.Instanceis a Protocol that a localAzathothand a
ConnectedInstanceboth satisfy, so code written for one runs against
either; a connected instance's collections are typed as a local
instance's and take the same arguments
(ADR 0137).- A refusal through a remote raises the error the local call would have
raised, with the remote's message: a service route's refusal now names
the kinds its error descends from, inkinds, and aModelInUseError's
carries itsdependents
(ADR 0137). RemoteRefusedErrorgainsstatusandrefusal, the status and code
of a refusal of no kind this Azathoth knows, andRemoteUnavailableError,
remote_unavailable, is such a refusal with 503, which may be tried
again later
(ADR 0137).- A connected instance calls the eight jobs as a local instance does: it
submits one, hands its events toon_event, asks the remote to stop it
when itscancelis cancelled, and returns its result or raises its
refusal. A stream that drops is followed again from the last event seen,
up to 5 more times
(ADR 0137,
ADR 0138). - A connected instance's
jobssubmits a job without waiting, follows,
reads, lists and stops one
(ADR 0138).
Jobs on a Remote
- A remote runs the eight calls that take a callback for their events,
such asruns.runandbenchmarks.run, as jobs. Each is asked of the
policy and told to the audit as its call is, queued in the database, and
answered202with aJobAcceptedand its path inLocation
(ADR 0138). azathoth remote serveruns 2 jobs at once on its own threads, each as
its caller, and--jobsruns another number;--jobs 0runs none, and
queues them for another server over the same PostgreSQL database
(ADR 0138).- A job outlives the request that submitted it. When its server stops, or
stops beating for 90 seconds, a run, a resumed run or an invocation is
queued again and goes on from its journal; any other job is refused 409
interrupted, saying how to go on
(ADR 0138,
ADR 0139). RunStartednames its run inrun_idbefore the run starts, here and on
a remote, so aruns.runjob a stopped server left is resumed from the
run's journal, and a runner is taken for stopped only once a run it held
has let its lease go
(ADR 0139).- A job's event stream reads its events once more when it sees the job
has finished, so its last event, such asinvocation_finished, is never
lost
(ADR 0139). GET /v1/jobslists the caller's own jobs,GET /v1/jobs/{job_id}
returns one with its result,POST /v1/jobs/{job_id}/cancelstops one,
andGET /v1/jobs/{job_id}/eventsstreams its events as server-sent
events, fromLast-Event-IDwhen a client reconnects. Another caller's
job is read withread_runsand stopped with its call's actions, and a
restricted job's result is sent only withread_restricted
(ADR 0138).AuditEventKind.JOB_CANCELLED,job_cancelled, is told before a job is
asked to stop
(ADR 0138).GET /v1/servicesays injobshow many jobs wait and run, and how many
runners beat in the last 60 seconds
(ADR 0138).
The Command Line on a Remote
- Every command takes
--remote <NAME>, a remote this instance named, or
its URL, and runs on that remote, printing exactly what it prints here:
the same lines, records and exit status. Without--remote, a command
runs as it always has
(ADR 0140). - Fourteen commands never run on a remote, such as
init,remote push
andtool verify, and say why in one line, with status 2
(ADR 0140). - A run, an invocation, a job request, a resume, a benchmark run or
comparison and an optimization run as jobs on the remote and are shown
as they go; Ctrl-C or SIGTERM stops the job there. A file given as input
is read here, as onlyfile:references are, and sent
(ADR 0140). - A command a step of another run started takes no
--remote, since it
runs where its parent does
(ADR 0140). - A remote with no such name, or no token, is refused in one line, with
status 1, before a command does anything; so is a remote that cannot be
reached, or one whose policy refuses the caller
(ADR 0140). - The service API's views hold all a command prints: a run's
source,
lineageandevaluations, a step'sresourcesandemits_values, an
invocation'serror_code,request_digest,lineage,input_provenance
andcitations, a production'semissions, a benchmark'scited_cases
andcomparisons, an execution's totals, and an optimization's
experiments with their winners
(ADR 0140). tools.definition,tools.implementations,tools.implementation,
tools.test_casesandtools.test_caseread a tool's current
artifacts, each theread_catalogaction, and the tool commands read
through them
(ADR 0140).- An argument that is a model or a JSON value, such as
runs.invoke's
input, is read over HTTP as the model first, so a file arrives as a file
(ADR 0140). tool from-mcpno longer sends a remote what only tests give it
(ADR 0140).
Tokens Printed by a Command
azathoth remote add <NAME> <URL> --token-command "<COMMAND>", or
instance.remotes.add(..., token_command=[...]), names a remote whose
token a command prints, such asgcloud auth print-identity-token,
instead of one read from a variable; a name keeps one or the other,
never both, andremote listshows the command quoted
(ADR 0141).- The command is run without a shell, given no input, and has 30 seconds
to print the token alone; one that does not is refused before anything
is sent, saying what it said on standard error
(ADR 0141). - Its token is kept in the process, never on disk, until 30 seconds before
a JWT's expiry, or for 5 minutes. Pushes, pulls, statuses and--remote
reach a named remote with it, and a connected instance asks for it
before each request
(ADR 0141). NamedRemote.token_commandholds a name's command, andtoken_variable
isNonefor such a name.api.token_of(remote, environ=None)returns
the token a named remote is reached with now
(ADR 0141).
Serving on Windows
- Serving a remote and running the queue worker are tested on Linux and
macOS. On Windowsazathoth remote serveandazathoth worker runstill
run, at their operator's own risk, after one line saying so
(ADR 0142). - Their tests are skipped on Windows, each saying why; every other test,
reaching a remote included, runs on every platform
(ADR 0142). - A server's runners claim no job once it is stopping, so a job one runner
hands back as the server stops is not taken by another, only to be
handed back again.
Examples
examples/model-watch/is a workflow to run every night: Discover New
Models, Add to Local Portfolio, Benchmark Against New Models, Compare Cost
& Quality, and Propose Winner. A ledger remembers every model it has
considered, so a rejected model never comes back; new models are
authorized on the local instance only, tried on each target's own
benchmark, and any winner that keeps its accuracy on a new model is
proposed with its promote command, never promoted. It is built on what
1.5 already does, optimizing and promoting an experiment's winner, and
needs no decision of its own.
Plugins
- A remote calls a plugin's seams from several threads at once; Writing a
Plugin says what that asks of one
(ADR 0135). - The remote's README names, under Writing a Plugin, everything a plugin
may rely on within 1.x, and a test fails if any of it goes missing
(ADR 0134). azathoth.persistence.database_locationfinds the database
AZATHOTH_DATABASEnames, orazathoth.db, as the command line does, so a
plugin finds the databaseazathoth remote servedoes;run_backfillsis
exported beside it
(ADR 0134).PersistenceErroris among what a plugin may rely on, so a plugin may
catch every error the database raises
(ADR 0136).- A policy may say more of its edition with an
edition_detail, such as who
it is licensed to. Nothing in Azathoth acts on an edition or its detail,
and a test reads every shipped module to keep it so
(ADR 0134).
Upgrading From 1.5
Upgrade, and run azathoth init as after every upgrade:
python -m pip install --upgrade azathoth-ai
azathoth initpython -m pip install --upgrade azathoth-ai
azathoth initIf you serve workflows with azathoth-mcp, upgrade it in the same command,
as Installing Azathoth shows: 1.6 of it requires 1.6 of
azathoth-ai.
The database schema moves from version 7 to version 9, which adds the
tables a remote keeps its jobs in
(ADR 0138)
and the table of the commands named remotes' tokens are printed by
(ADR 0141).
An SQLite file is upgraded the first time it is used. A PostgreSQL
database refuses every command until azathoth init has run once, from
any one machine, and 1.5 refuses it after that, so upgrade Azathoth on
every machine first; a database 1.6.0b1 made, at version 8, is upgraded
the same way. init keeps everything the database holds.
azathoth remote serve now runs jobs, 2 at once by default, and says so
on a second line when it starts.
A few refusals now say what the service API says
(ADR 0140):
benchmark runandbenchmark comparerefuse a benchmark with no
cases before any case runs, rather than ending in a traceback or saying
no case was recorded.benchmark comparerefuses fewer than two distinct workflows with
A comparison needs at least two distinct workflows., andworkflow optimizeno generations withAn optimization session needs at least one generation.; both refuse a target not above zero withInput should be greater than 0, rather than the whole validation error.- An error of the service API that a command does not report itself is
reported in one line, with status 1, rather than as a traceback.