tilie_server.routers.flows#

The flow routes: a timeline’s flow control played, and its flows written.

A manifest states where the flow of a timeline jumps and breaks (its flow control); in which order its stretches are then played is computed, and the computation is timetoalign’s alone. The editor asks for the flows of one timeline (POST /api/flows): its atomic sections, and for each convention the runs played, the sections they cover and what playing found, each finding with its cause where timetoalign names one. When its user wants those flows in the manifest, it asks for the manifest with them written (POST /api/flows/flow-maps): the atomic sections as Regions of the timeline and the computed FlowMaps. A manifest that holds flows written before is written again: a Region whose stretch is an atomic section no longer stays and is rejected as one, which needs the actor who asks. The server stores nothing; what is done with either answer is the editor’s.

Both requests are a JSON object of parameters behind its length, as the MatchClaim provenance routes take them, followed by the manifest file’s text, in any serialization timetoshare reads, to the end of the body. The manifest is read whole by timetoalign, which checks it as a manifest reader does, before the timeline is looked for.

timetoalign’s engine and what reads a posted manifest for it are imported when a request needs them, so a server whose installed timetoalign cannot play flow control still starts and answers every other route; these routes then answer 501.

tilie_server.routers.flows.REQUIRED_PARAMETERS = ('timeline',)#

The parameter both routes require.

tilie_server.routers.flows.FLOWS_PARAMETERS = ('convention', 'believer', 'beliefs')#

The parameters the computing route takes besides, each optional.

tilie_server.routers.flows.WRITING_PARAMETERS = ('believer', 'beliefs', 'actor', 'date')#

The parameters the writing route takes besides, each optional.

tilie_server.routers.flows.MANIFEST_MEDIA_TYPE = 'application/json'#

The media type of the writing route’s answer, a manifest file in JSON.

tilie_server.routers.flows.flow_engine()[source]#

Return timetoalign’s play and atomic_sections.

Raises:

Refusal – 501, if the installed timetoalign has no flow engine.

Return type:

tuple[Callable[[…], Any], Callable[[…], Any]]

tilie_server.routers.flows.asked_reading(parameters)[source]#

Whose beliefs decide which elements are read, where a request says so.

believer is an actor, compared as timetoalign’s engine compares it with the actors of the elements’ beliefs as the manifest writes them; beliefs the belief states read for it (true, undecided, unlikely, false), every state but false without it. An element is read when the believer’s state in it, undecided where they hold no belief, is one of them; without a believer, when no actor rejects it.

Returns:

The keyword arguments of timetoalign’s play, atomic_sections and create_flow_maps_from_flow_control that say so: none without a believer.

Raises:

Refusal – 422 at ["believer"] if the believer is no string; at ["beliefs"] if the states are no list of belief states, or are given without a believer.

Parameters:

parameters (Mapping[str, Any])

Return type:

dict[str, Any]

tilie_server.routers.flows.asked_rejection(parameters)[source]#

Who asks for the flows to be written, and on which day, where a request says so.

Returns:

The actor whose belief rejects the atomic sections that are none any more, and the day of that belief (YYYY-MM-DD); None for each the request leaves out.

Raises:

Refusal – 422 at ["actor"] if the actor is no non-empty string, at ["date"] if the date is no calendar date written YYYY-MM-DD.

Parameters:

parameters (Mapping[str, Any])

Return type:

tuple[str | None, str | None]

tilie_server.routers.flows.asked_conventions(parameters)[source]#

The conventions to answer: the one named, else all, in timetoalign’s order.

Raises:

Refusal – 422 at ["convention"] if the parameter names none.

Parameters:

parameters (Mapping[str, Any])

Return type:

list[Any]

tilie_server.routers.flows.read_request(body, optional)[source]#

The parameters of a request and its manifest, as its file writes it (IDs #id) and with every ID made bare.

Parameters:
  • body (bytes) – The parameters’ length in bytes (a little-endian 32-bit integer), the parameters as a JSON object in UTF-8, then the manifest file’s text.

  • optional (tuple[str, ...]) – The parameters the route takes besides timeline.

Raises:

Refusal – As tilie_server.routers.claim_provenance.split_parameters() and tilie_server.manifests.read_manifest().

Return type:

tuple[dict[str, Any], Any, Any]

tilie_server.routers.flows.asked_timeline(parameters, manifest, bare)[source]#

The timeline a request names, as timetoalign reads it in its manifest.

Parameters:
  • parameters (Mapping[str, Any]) – The request’s parameters; timeline is a bare ID.

  • manifest (Mapping[str, Any]) – The manifest as its file writes it (IDs #id).

  • bare (Mapping[str, Any]) – The same manifest with every ID made bare.

Returns:

The bundle timetoalign reads the manifest into, and the timeline in it.

Raises:

Refusal – 422 at ["timeline"] if the parameter is no string or names no timeline of the manifest, at any depth; as tilie_server.claim_columns.manifest_bundle() if timetoalign refuses the manifest.

Return type:

tuple[Any, Any]

tilie_server.routers.flows.flows_answer(body)[source]#

The flows of the timeline a request names.

Returns:

{"timeline", "number_type", "atomic_sections", "conventions"}, the timeline’s bare ID and number type; its atomic sections in the order of the axis, each {"name", "start", "end"}; and under each convention answered {"runs", "sections"}, the runs played as [start, end] pairs (stretches played one after the other without a jump between them are one run) and the names of the atomic sections they cover, in the order played, and findings, what playing found, each {"kind", "coordinate", "message"} with the end of a stretch never played and, where timetoalign names one, the cause (single_playback: a stretch the single flow leaves out that the default flow plays); printed finds nothing. Every value on the axis is written as a manifest writes a value on the timeline’s own axis: an integer, a number or a [numerator, denominator] pair, as the number type says. A timeline without flow control answers one section and one run over its whole length.

Raises:

Refusal – 501 as flow_engine(); 422 as read_request(), asked_conventions(), asked_reading() and asked_timeline(); 422 at ["timeline"] with timetoalign’s message if the timeline’s length is unknown or its flow control cannot be played.

Parameters:

body (bytes)

Return type:

dict[str, Any]

tilie_server.routers.flows.written_manifest(body)[source]#

The manifest of a request with the flows of the timeline it names written.

Returns:

A manifest file’s text in timetoshare’s JSON serialization, the manifest as timetoalign writes it, in the minimal form, after writing the timeline’s atomic sections as Regions and its computed FlowMaps. A child timeline’s Regions are written on the child and its FlowMaps on the root of its tree, which a FlowMap names. A timeline without flow control has nothing written. Where the manifest holds flows written before, an atomic section whose stretch is still one keeps its Region, a new stretch gets a new Region, and a Region whose stretch is none any more stays, with the belief false of the request’s actor on the request’s date (the server’s day without one) in its type statement; the computed FlowMaps keep their IDs and list the sections standing now. The Regions and FlowMaps written anew get random IDs, minted in that order from one seed: seed_from of the manifest as timetoalign writes it before the call (its minimal JSON text), the timeline’s ID, believer and beliefs (None where not given), so one request is answered alike in either form of its manifest and on every asking.

Raises:

Refusal – 501 as flow_engine(); 422 as read_request(), asked_reading(), asked_rejection() and asked_timeline(); 422 at ["timeline"] with timetoalign’s message if it does not write the flows: the timeline’s length is unknown, its flow control cannot be played, or it holds an atomic section that is none any more and the request names no actor to reject it.

Parameters:

body (bytes)

Return type:

str

tilie_server.routers.flows.flows(body)[source]#

Answer the flows of one timeline of the posted manifest.

The body is the parameters’ length in bytes (a little-endian 32-bit integer), the parameters {"timeline": <bare ID>, "convention"?: "default" | "single" | "printed", "believer"?: <actor>, "beliefs"?: [<belief state>, …]} as JSON, then the manifest file’s text: the elements read are those whose state for believer is one of beliefs (every state but false without it), or, without a believer, those no actor rejects. The answer is JSON (flows_answer()), with all three conventions where none is named. A request that cannot be answered is answered 422 with {"detail": {"path", "message"}}, a parameter’s at its name; a timetoalign that cannot play flow control, 501.

Parameters:

body (Annotated[bytes, Depends(dependency=~tilie_server.manifests.posted_body, use_cache=True, scope=function)])

Return type:

Response

tilie_server.routers.flows.flow_maps(body)[source]#

Answer the posted manifest with the flows of one timeline written.

The body is the parameters’ length in bytes (a little-endian 32-bit integer), the parameters {"timeline": <bare ID>, "believer"?: <actor>, "beliefs"?: [<belief state>, …], "actor"?: <actor>, "date"?: "YYYY-MM-DD"} as JSON, then the manifest file’s text; believer and beliefs read the elements as the computing route does. actor is who asks: the one whose belief rejects an atomic section written before that is none any more, on date. The answer is a manifest file in JSON (written_manifest()); nothing is stored. Refusals answer as the computing route’s.

Parameters:

body (Annotated[bytes, Depends(dependency=~tilie_server.manifests.posted_body, use_cache=True, scope=function)])

Return type:

Response