Publish a result you computed in Python
You can publish a file you computed yourself — a surface, a point set, well tops, a survey, fault sticks or new LAS curves — from exact versions of data in the project. Ophiolite reads it exactly as it reads an upload, records the versions it was built from and the method you declare, and keeps it private to you until you share it. Your Python runs on your computer; Ophiolite does not run it.
1. Read the data you build on
Section titled “1. Read the data you build on”Read each input at an exact version. The version is what your result will name as its parent, so a later change to the input does not change what you built on.
from ophiolite import Client
client = Client("https://ophiolite.example", "my-project", credential)points = client.read_data(asset_id, revision) # a point set at an exact version2. Compute and write the result
Section titled “2. Compute and write the result”Compute with any library. This example triangulates the points with SciPy (not an Ophiolite dependency) and writes the triangles as a triangulated surface:
from scipy.spatial import Delaunayfrom ophiolite.typed import TriangulatedSurface
xy = [(x, y) for x, y, z in points.points]triangles = Delaunay(xy).simplices.tolist()context = points.contextwritten = TriangulatedSurface.write( [tuple(p) for p in points.points], triangles, crs=context["crs"], xy_unit=context["xy_unit"], z_unit=context["z_unit"], z_meaning=context["z_meaning"], positive=context["positive"], vertical_datum=context["vertical_datum"])Every declaration is required; write "unknown" when it is not known. Nothing is
inferred or converted. A writer refuses what the file format cannot carry — a grid
value equal to its NODATA marker, a LAS sample equal to its null marker, a fault
stick with a missing coordinate — instead of altering it.
3. Publish it
Section titled “3. Publish it”Publish from a private work folder. The folder saves a command id and the file’s checksum before anything is sent, so if your computer stops or the reply is lost, publishing the same file again from the same folder finishes the same publication instead of creating a second one.
work = client.work_folder("surface-work")receipt = work.publish_derived( written, name="Top reservoir surface", from_=[points.descriptor], method={"name": "scipy.spatial.Delaunay", "library": "scipy", "version": "1.14.1", "parameters": {}})Without a work folder, client.publish_derived needs a command_id you keep:
retrying with the same id is safe; a new id can publish twice.
When you publish, Ophiolite checks again that you may still build on every parent and that every original they came from still admits you. If not, nothing is published.
4. Read it back
Section titled “4. Read it back”history = client.history({"asset_id": receipt.asset_id, "revision": receipt.revision, "authority": "ophiolite:derived"})print(history.revisions[0].calculation) # "Delaunay triangulation (SciPy)"Workspace shows the result with its method and the versions it was built from. Methods Ophiolite documents are shown in words; any other name is shown as “Method declared by its publisher”, with the exact name under Technical details. The method is script-declared: your code and environment are not captured unless you record them in the parameters.
Share it and add versions
Section titled “Share it and add versions”The result is private to you. Share it from its inspector in Workspace, with anyone
every original allows. To add a new version, publish again with new_version_of and
expected_parent; the new version must be built from the same originals.
From the command line:
ophiolite publish-derived surface.mesh --profile mesh-text/1 --name "Top reservoir surface" \ --from ASSET:REVISION --method scipy.spatial.Delaunay --library scipy --library-version 1.14.1 \ --declare crs=EPSG:28992 --declare z_unit=m --work surface-work