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.
To read an earlier version, take its revision from history(...) (number == 1 is the first) and read it with the
asset id: client.read_data(asset_id, revision). A revision is the digest of the content, so two assets holding
identical bytes have the same revision; always use the asset id and the revision together.
When you publish with a project access key, each version records which key published it, in the
key’s name as it was then: Workspace’s version line says it was published “from an application using an access key”
and shows the name under Technical details, and history.revisions[-1].via.label gives the same name. Publishing in
Workspace, or with any other credential, records no key. This names the key, not a verified
application.
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. A colleague can add a
version to your result only when the project names you both under Settings → Adding versions to
each other’s results and they can read it; you stay the author and are told.
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-workCorrect a log the project holds
Section titled “Correct a log the project holds”A LAS file the project holds (a kept copy, an upload, or a result’s latest version) can be corrected in Workspace without writing to the source database. Open the file under Data, choose Correct this file, change the samples, and review the changes. The review offers what this file can take:
- Send as the next version — only for a result you may add a version to and reuse. The earlier version is kept,
and everyone who can read the result can see the new one: a program holding it with
ophiolite checkis told “1 newer: name, version 2 by who, when.” andophiolite get --item ITEM --curve GRfetches it. - Send as a new item — always offered. The correction becomes a separate result named “name (corrected)”, built from the version you started from; only you can see it until you share it.
- Download a file — the corrected LAS file, with nothing sent.
A correction is sent once, however often the button is pressed or the connection drops: if sending was interrupted, Finish sending sends the same correction again and it is never added twice. If someone added a version after you started, yours is not sent; look at their version, or save yours as a separate item.
