ScenarioProxy
Object to simplify scenario creation, configuration and run. This can be used in a Jupyter Notebook
:raises Exception: [description] :return: [description] :rtype: [type]
This create a scenario in the database with the provided Task or Protocol
type[gws_core.protocol.protocol.Protocol] | Nonegws_core.folder.space_folder.SpaceFolder | Nonestr - ''ScenarioCreationType - ScenarioCreationType.AUTOstr | NoneTaglistScenariostrretrieve the main protocol of the scenario
ProtocolProxystrboolboolboolScenarioProxyReset the scenario to draft and delete all logs and progress
ScenarioProxyReset all processes in error of the scenario
ScenarioProxyExecute the scenario synchronously and block until it is finished.
The scenario runs in a forked sub-process (ProcessDb) so it can be
stopped, then this method waits for it to complete and raises if it
errored.
.. warning:: This forks the current process. It is safe in tests, CLI commands and the scenario queue subprocess, but must never be called from a FastAPI request handler (i.e. from the running HTTP server). The fork duplicates the server's listening socket and event-loop state, which blocks every other HTTP request until the scenario finishes, and the forked download keeps running even if the client disconnects.
From a request handler, run the scenario asynchronously instead:
use :meth:`run_async` and return immediately, then poll the scenario
status from the front-end (see the ``*_async`` methods on
``ResourceTransfertService``, ``ConverterService``, etc.).
This method enforces the rule above: calling it while this process is the
HTTP server raises a RuntimeError instead of silently degrading the
server. The allow_in_http_server escape hatch exists only for call
sites that are not yet converted and must be reviewed individually; do
not use it for new code.
bool - Falsebool - FalseRun the scenario in a separate CLI process but don't wait for it to finish.
Uses a CLI subprocess (like the queue runner) instead of fork to avoid inheriting the parent's server socket and event loop state, which can block other HTTP requests.
ScenarioWaiterBasicStop the scenario or remove it from the queue depending on its current status.
- If the scenario is running in an external lab, stop all running importing scenarios.
- If the scenario is running locally, stop it.
- If the scenario is in queue, remove it from the queue.
ScenarioProxyCreate a ScenarioProxy from an existing scenario
strScenarioProxy