Skip to content

Reading and writing projects from programs

In the app: Help → Help contents, Reading and writing projects from programs.

Every step of a session is a call of a public function: its stable ID, its arguments (settings written out in full, datasets and results by name) and the name its result is kept under. Another program can build such calls (make_call), run them in a session (Session.run), or record a slow one without running it (Session.add(cmd, deferred=True): listed as not computed until Compute runs it, against the objects it uses as they were where it stands in the history), and save the project for the app to open. It can keep its own files in the project (session.attachments), and read a project's steps, as calls, without opening it.

A saved result (File → Save result…) keeps the call that made it in its provenance, so Call(**provenance["call"]).invoke({"data": data}) makes it again from the same data. Each result's provenance, each save of a project and each saved result also record the pymetrix commit beside the version, when pymetrix runs from a checkout of its source, and whether the code differed from that commit.

These names (Call, make_call, the codec's encode and decode, Session.attachments) are a public interface, provisional before version 1.0: documented and tested as public, but still free to change before 1.0. The user guide's section "Reading and writing projects from programs" has examples.

See also