stochss_compute.core package¶
Submodules¶
stochss_compute.core.errors module¶
stochss_compute.core.errors
stochss_compute.core.messages module¶
stochss_compute.core.messages
- class stochss_compute.core.messages.ResultsRequest(results_id)[source]¶
Bases:
Request
Request results from the server.
- Parameters:
results_id (str) – Hash of the SimulationRunRequest
- class stochss_compute.core.messages.ResultsResponse(results=None)[source]¶
Bases:
Response
A response from the server about the Results.
- Parameters:
results (str) – The requested Results from the cache. (JSON)
- class stochss_compute.core.messages.SimStatus(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]¶
Bases:
Enum
Status describing a remote simulation.
- DOES_NOT_EXIST = 'There is no evidence of this simulation either running or on disk.'¶
- ERROR = 'The Simulation has encountered an error.'¶
- PENDING = 'The simulation is pending.'¶
- READY = 'Simulation is done and results exist in the cache.'¶
- RUNNING = 'The simulation is still running.'¶
- class stochss_compute.core.messages.SimulationRunRequest(model, **kwargs)[source]¶
Bases:
Request
A simulation request.
- Parameters:
model (gillespy2.Model) – A model to run.
kwargs (dict[str, Any]) – kwargs for the model.run() call.
- hash()[source]¶
Generate a unique hash of this simulation request. Does not include number_of_trajectories in this calculation.
- Returns:
md5 hex digest.
- Return type:
str
- class stochss_compute.core.messages.SimulationRunResponse(status, error_message=None, results_id=None, results=None, task_id=None)[source]¶
Bases:
Response
A response from the server regarding a SimulationRunRequest.
- Parameters:
status (SimStatus) – The status of the simulation.
error_message (str | None) – Possible error message.
results_id (str | None) – Hash of the simulation request. Identifies the results.
results (str | None) – JSON-Encoded gillespy2.Results
- class stochss_compute.core.messages.SourceIpRequest(cloud_key)[source]¶
Bases:
Request
Restrict server access.
- Parameters:
cloud_key (str) – Random key generated locally during launch.
- class stochss_compute.core.messages.SourceIpResponse(source_ip)[source]¶
Bases:
Response
Response from server containing IP address of the source.
- Parameters:
source_ip (str) – IP address of the client.
- class stochss_compute.core.messages.StatusRequest(results_id)[source]¶
Bases:
Request
A request for simulation status.
- Parameters:
results_id (str) – Hash of the SimulationRunRequest
- class stochss_compute.core.messages.StatusResponse(status, message=None)[source]¶
Bases:
Response
A response from the server about simulation status.
- Parameters:
status (SimStatus) – Status of the simulation
message (str) – Possible error message or otherwise
stochss_compute.core.remote_results module¶
stochss_compute.core.remote_results
- class stochss_compute.core.remote_results.RemoteResults(data=None)[source]¶
Bases:
Results
Wrapper for a gillespy2.Results object that exists on a remote server and which is then downloaded locally. A Results object is: A List of Trajectory objects created by a gillespy2 solver, extends the UserList object.
These three fields must be initialized manually: id, server, n_traj, task_id.
- Parameters:
data (UserList) – A list of trajectory objects.
id (str) – ID of the cached Results object.
server (stochss_compute.ComputeServer) – The remote instance of StochSS-Compute where the Results are cached.
task_id (str) – Handle for the running simulation.
- property data¶
The trajectory data.
- Returns:
self._data
- Return type:
UserList
- get_gillespy2_results()[source]¶
Get the GillesPy2 results object from the remote results.
- Returns:
The generated GillesPy2 results object.
- Return type:
gillespy.Results
- id = None¶
- property is_ready¶
True if results exist in cache on the server.
- Returns:
status == SimStatus.READY
- Return type:
bool
- n_traj = None¶
- server = None¶
- property sim_status¶
Fetch the simulation status.
- Returns:
Simulation status enum as a string.
- Return type:
str
- task_id = None¶
stochss_compute.core.remote_simulation module¶
RemoteSimulation
- class stochss_compute.core.remote_simulation.RemoteSimulation(model, server=None, host: str = None, port: int = 29681, solver=None)[source]¶
Bases:
object
An object representing a remote gillespy2 simulation. Requires a model and a host address. A solver type may be provided, but does not accept instantiated solvers.
- Parameters:
model (gillespy2.Model) – The model to simulate.
server (stochss_compute.Server) – A server to run the simulation. Optional if host is provided.
host (str) – The address of a running instance of StochSS-Compute. Optional if server is provided.
port (int) – The port to use when connecting to the host. Only needed if default server port is changed. Defaults to 29681.
solver (gillespy2.GillesPySolver) – The type of solver to use. Does not accept instantiated solvers.
- is_cached(**params)[source]¶
Checks to see if a dummy simulation exists in the cache.
- Parameters:
params (dict[str, Any]) – Arguments for simulation.
- Returns:
If the results are cached on the server.
- Return type:
bool
- run(**params)[source]¶
Simulate the Model on the target ComputeServer, returning the results or a handle to a running simulation.
See here.
- Parameters:
params (dict[str, Any]) – Arguments to pass directly to the Model#run call on the server.
- Returns:
RemoteResults populated with Results if cached, otherwise and unpopulated RemoteResults
- Return type:
- Raises:
RemoteSimulationError – In the case of SimStatus.ERROR
Module contents¶
stochss_compute.core