Files
openfe/docs/cookbook/dumping_transformation.rst
Alyssa Travitz 66ac2bdc64 migrate json loading to new gufe syntax (#1177)
* updates to cli from_json

* replacing dump instances with to_json

* Remove unnecessary imports of JSON_HANDLER

* addressing review

---------

Co-authored-by: Mike Henry <11765982+mikemhenry@users.noreply.github.com>
Co-authored-by: David L. Dotson <dotsdl@gmail.com>
2025-03-25 23:32:26 +00:00

39 lines
1.3 KiB
ReStructuredText

.. _dumping_transformations:
Dumping a ``Transformation`` to JSON
====================================
If you're trying to run a full campaign of simulations representing an
alchemical network, we generally recommend saving objects using our storage
tools, when avoids saving duplicate information to disk.
.. TODO: add links to storage tools once they're complete
However, there are situations where it is reasonable to serialize a single
:class:`.Transformation`. For example, this can be useful when trying to
compare results run on different machines. This also provides a trivial way
for a user to run edges in parallel, if they don't want to use the more
sophisticated techniques we have developed.
For these cases, we have made it very easy for a user to dump a
transformation to JSON. Simply use the method
:meth:`.Transformation.to_json`. For example:
.. code::
transformation.to_json("mytransformation.json")
When you do dump a single transformation, it can be reloaded into memory
with the :meth:`.Transformation.from_json` method:
.. code::
transformation = Transformation.from_json("mytransformation.json")
Once you've saved to it JSON, you can also run this transformation with the
``openfe`` command line tool's :ref:`cli_quickrun`, e.g.:
.. code:: bash
$ openfe quickrun mytransformation.json -d dir_for_files -o output.json