Frequently asked questions: general¶
Why is my run in the lost state?¶
The Simvue client sends a heartbeat to the server every minute. A run goes into the lost state if there are no heartbeats for over 3 minutes. Because of this,
it is preferable to use the context manager for the Run()
object, for example:
failed
and an event will be created with details about this exception. Without the
context manager, i.e.
the run automatically be set to the lost
state if there is an exception and no information is available as to what happened.
Interactive plots from artifacts¶
If Matplotlib and Plotly plots are saved directly as artifacts (rather than saved as files first) they can be opened in the web UI as interactive plots. This makes use of plotly.js
- see here for documentation for plotly.js.
Here is a simple but complete example creating a Matplotlib plot (based on an example from the Matplotlib documentation, seen here) and saving it as an artifact. Note the use of the gcf()
method to get the current figure, as we need to
pass a matplotlib.figure.Figure
instance to Simvue.
import numpy as np
import matplotlib.pyplot as plt
from simvue import Run
def f(t):
return np.exp(-t) * np.cos(2*np.pi*t)
if __name__ == "__main__":
t1 = np.arange(0.0, 5.0, 0.1)
t2 = np.arange(0.0, 5.0, 0.02)
plt.figure()
plt.subplot(211)
plt.plot(t1, f(t1), 'bo', t2, f(t2), 'k')
plt.subplot(212)
plt.plot(t2, np.cos(2*np.pi*t2), 'r--')
with Run() as run:
run.init()
run.save_object(plt.gcf(), 'output', name='plot')
name
argument, which is essential when creating artifacts directly from Python objects. This name
is completely arbitrary and up to the user.
If you get an error like:
Aw. Snap! You're gonna have to hold off on the selfies for now. Plotly can't import images from matplotlib yet!