PHOEBE 2.1 Documentation

2.1 Docs



Prev: Advanced: Alternate Backends Next: Adding new passbands to PHOEBE
.

IPython Notebook | Python Script

Advanced: Detaching from Run Compute

Setup

As always, let’s do imports and initialize a logger and a new Bundle. See Building a System for more details.

%matplotlib inline
import phoebe
from phoebe import u # units
import numpy as np
import matplotlib.pyplot as plt

logger = phoebe.logger()

b = phoebe.default_binary()
/usr/local/lib/python2.7/dist-packages/IPython/kernel/__init__.py:13: ShimWarning: The IPython.kernel package has been deprecated. You should import from ipykernel or jupyter_client instead.
  "You should import from ipykernel or jupyter_client instead.", ShimWarning)
WARNING: Constant u'Gravitational constant' is already has a definition in the u'si' system [astropy.constants.constant]
WARNING:astropy:Constant u'Gravitational constant' is already has a definition in the u'si' system
WARNING: Constant u'Solar mass' is already has a definition in the u'si' system [astropy.constants.constant]
WARNING:astropy:Constant u'Solar mass' is already has a definition in the u'si' system
WARNING: Constant u'Solar radius' is already has a definition in the u'si' system [astropy.constants.constant]
WARNING:astropy:Constant u'Solar radius' is already has a definition in the u'si' system
WARNING: Constant u'Solar luminosity' is already has a definition in the u'si' system [astropy.constants.constant]
WARNING:astropy:Constant u'Solar luminosity' is already has a definition in the u'si' system
WARNING: developer mode enabled, to disable 'rm ~/.phoebe_devel_enabled' and restart phoebe or phoebe._devel_enabled=False to temporarily disable
/usr/local/lib/python2.7/dist-packages/astropy/units/quantity.py:732: FutureWarning: comparison to None will result in an elementwise object comparison in the future.
  return super(Quantity, self).__eq__(other)

Now we’ll add datasets

b.add_dataset('lc', times=np.linspace(0,20,501))
<ParameterSet: 11 parameters | kinds: lc, lc_dep>

Run Compute

Here we just pass detach=True to any run_compute call. We’ll immediately be returned to the prompt instead of waiting for the results to complete.

b.run_compute(detach=True, model='mymodel')
WARNING:BUNDLE:detach support is EXPERIMENTAL
<Parameter: detached_job=unknown | keys: description, value, server_status, location, status_method, retrieve_method, uniqueid>

If we then try to access the model, we see that there is instead a single parameter that is a placeholder - this parameter stores information on how to check the progress of the run_compute job and how to load the resulting model once it’s complete

b['mymodel']
<Parameter: detached_job=unknown | keys: description, value, server_status, location, status_method, retrieve_method, uniqueid>

Re-attaching to a Job

We can check on the job’s status

b['mymodel'].status
'unknown'

If we want, we can even save the Bundle and load it later to retrieve the results. In this case where the job is being run in a different Python thread but on the same machine, you cannot, however, exit Python or restart your machine.

When detaching and running on a server (coming soon), you will then be able to exit your Python session or even open the Bundle on a different machine.

b.save('test_detach.bundle')
'test_detach.bundle'
b = phoebe.Bundle.open('test_detach.bundle')
b['mymodel'].status
'unknown'

And at any point we can choose to “re-attach”. If the job isn’t yet complete, we’ll be in a wait loop until it is. Once the job is complete, the new model will be loaded and accessible.

b['mymodel'].attach()
<ParameterSet: 3 parameters | qualifiers: detached_job, fluxes, times>
b['mymodel']
<ParameterSet: 3 parameters | qualifiers: detached_job, fluxes, times>
axs, artists = b['mymodel'].plot()
../../_images/detach_20_0.png
Prev: Advanced: Alternate Backends Next: Adding new passbands to PHOEBE
.
Last update: 10/29/2018 9:20 a.m. (CET)