solprop.backends.session_core#
The building blocks the Python execution sessions share (SEP 47 section 5).
The reference’s session (solprop.backends.host.session.HostSession) runs its
own plane schedule over its own driver, and composes the parts below, none of which
names a driver; the native backend’s prepared execution (solprop_native.session)
makes the same preparation refusals:
AttemptCounterforwards a driver’s attempts to a progress listener and counts them, andYieldDuereads that count and the clock for a bounded advance (SEP 47 section 5.1);SnapshotLatchcoalesces snapshot requests until one is serviced (section 5.5);ObservedFieldobserves a committed field once per ticket and shares it among its exports (section 5.4);merge_summaries(),bind()andEMPTY_SUMMARYassemble events;foreign_request()andcheck_preparation()are the refusals a preparation makes before any session starts (section 5.2).
The lifecycle bookkeeping – receipts, the pending barrier, closing and poisoning – is
solprop.backends.session.SessionLedger.
Module Attributes
Called with each attempt's end, length and acceptance, for a progress reporter. |
|
The summary of a launch plane, which no propagation reached. |
Functions
|
Return an event with its ticket bound to the batch that delivers it. |
|
Refuse a run a constructed backend cannot prepare, by name (SEP 47 5.2). |
|
Return the recipe an export applies at z, and its true-power weight. |
|
Return why request is not a run of own, or |
|
Merge a propagation's summary with the yields before it on the same plane. |
Classes
|
Counts a driver's attempts and forwards them and its start, and nothing else. |
|
One committed field per ticket, shared by every export of it (SEP 47 5.4). |
Holds one outstanding snapshot request until it is serviced (SEP 47 5.5). |
|
|
Says whether a bounded advance has reached its attempt bound or its deadline. |
- class solprop.backends.session_core.AttemptCounter(listener=None, started=None)[source]#
Bases:
NullReporterCounts a driver’s attempts and forwards them and its start, and nothing else.
The service loop reports planes itself;
NullReporterdrops the rest.- Parameters:
- listenercallable or None, optional
Called with each attempt;
Noneonly counts it.- startedcallable or None, optional
Called once, when the driver first propagates;
Nonedrops it.
- Attributes:
- countint
The attempts heard so far.
- solprop.backends.session_core.AttemptListener#
Called with each attempt’s end, length and acceptance, for a progress reporter.
- solprop.backends.session_core.EMPTY_SUMMARY = StepSummary(z=0.0, n_steps=0, n_rejected=0, max_norm=0.0, mean_norm=0.0, wall_time=0.0, met_tolerance=True)#
The summary of a launch plane, which no propagation reached.
- class solprop.backends.session_core.ObservedField(problem, drain)[source]#
Bases:
objectOne committed field per ticket, shared by every export of it (SEP 47 5.4).
A session observes its driver’s field once per state generation, when a consumer first asks for it; every export of that ticket reads the same observation. An observation’s arrays are read-only and nothing writes to them again (
solprop.backends.protocol.HostStepping.observe()), so an export with nothing to convert is that array on a spatial grid, and every other export a new array (or the caller’s destination). Attempts a field fetch drains are kept for the next event’s chunk.- Parameters:
- problemsolprop.translate.problem.PropagationProblem
The run’s problem, for the true-power conversion.
- draincallable
drain(field=True)observes the driver, draining its attempts.
- export(ticket, recipe, out=None)[source]#
Fill a destination with a valid ticket’s converted field.
- Parameters:
- ticketsolprop.backends.events.ExportTicket
A ticket the session’s ledger has checked.
- recipesolprop.backends.export.ExportRecipe
The conversion.
- outnumpy.ndarray or None, optional
The destination; a new array by default.
- Returns:
- numpy.ndarray
The converted field.
- noise_phase(ticket)[source]#
Return the noise phase at a valid ticket.
- Parameters:
- ticketsolprop.backends.events.ExportTicket
A ticket the session’s ledger has checked.
- Returns:
- numpy.ndarray or None
The phase, shape
(n_modes, n_pol, n_omega), orNonewithout noise.
- class solprop.backends.session_core.SnapshotLatch[source]#
Bases:
objectHolds one outstanding snapshot request until it is serviced (SEP 47 5.5).
- Attributes:
- pendingint or None
The outstanding request’s number, or
None.
- class solprop.backends.session_core.YieldDue(counter, limit, started, deadline)[source]#
Bases:
objectSays whether a bounded advance has reached its attempt bound or its deadline.
A class rather than a closure in a session’s
advance, so that no function object is made per call (each one costs the coverage lane’s import hook a compile).- Parameters:
- counterAttemptCounter
The session’s attempt count.
- limitint
The attempt count at which the march halts.
- startedfloat
The advance’s start, in
time.perf_counter()seconds.- deadlinefloat
The seconds after started at which the march halts.
- solprop.backends.session_core.bind(event, receipt)[source]#
Return an event with its ticket bound to the batch that delivers it.
- Parameters:
- eventsolprop.backends.events.Event
An event, with an unbound ticket or none.
- receiptsolprop.backends.events.Receipt
The batch’s receipt.
- Returns:
- solprop.backends.events.Event
The event, its ticket bound; the same event when it carries none.
- solprop.backends.session_core.check_preparation(name, own, problem, request)[source]#
Refuse a run a constructed backend cannot prepare, by name (SEP 47 5.2).
- Parameters:
- namestr
The backend’s registered name, for the message.
- ownsolprop.translate.run_request.RunRequest
The request the backend was built for.
- problemsolprop.translate.problem.PropagationProblem
The run’s problem.
- requestsolprop.translate.run_request.RunRequest
The run’s request.
- Raises:
- solprop.backends.session.SessionError
If the request is not one run of the backend’s own (
foreign_request()).- solprop.exceptions.BackendError
If the request asks for statistics the problem does not carry (
statistics_unavailable()).
- solprop.backends.session_core.export_weight(problem, z, recipe)[source]#
Return the recipe an export applies at z, and its true-power weight.
- Parameters:
- problemsolprop.translate.problem.PropagationProblem
The run’s problem.
- zfloat
The observation’s position, m.
- recipesolprop.backends.export.ExportRecipe
The conversion asked for.
- Returns:
- tuple
The recipe, without the power conversion on a spatial route, whose field measure is already the stored quantity, and the weight, or
Nonewhen no power conversion is made.
- solprop.backends.session_core.foreign_request(own, request)[source]#
Return why request is not a run of own, or
Nonewhen it is.A backend lowers its method, error control, replay and itinerary where it is built (SEP 47 section 5.2), so a run it serves may differ from its own request only where
for_run()changes it: the start, retention, statistics, monitor, history and snapshots.for_runkeeps the other sections by identity, which is what is checked.- Parameters:
- ownsolprop.translate.run_request.RunRequest
The request the backend was built for.
- requestsolprop.translate.run_request.RunRequest
The request one run asks it to serve.
- Returns:
- str or None
The first section that differs, named, or
None.
Examples
>>> from solprop.stepper import DOPRI5, PIController >>> from solprop.translate.problem import StepperSettings >>> from solprop.translate.run_request import describe_run >>> settings = StepperSettings(DOPRI5, PIController(rtol=1e-8, atol=1e-14), ... 1e-9, 0.1, 1e-3, 1.1, None, [0.5, 1.0], "auto") >>> own = describe_run(settings) >>> foreign_request(own, own.for_run(start_plane=1)) is None True >>> foreign_request(own, describe_run(settings)) "the run's integration is not the backend's own"
- solprop.backends.session_core.merge_summaries(before, step)[source]#
Merge a propagation’s summary with the yields before it on the same plane.
- Parameters:
- beforesolprop.backends.protocol.StepSummary or None
The plane so far, or
Nonewhen step is its first propagation.- stepsolprop.backends.protocol.StepSummary
The latest propagation.
- Returns:
- solprop.backends.protocol.StepSummary
The summary of the plane so far.