Run and Publish from Python

GX-TXT P011-bis · Scientific Dataset Plot 4.4.2

Run the Plot Dataset calls in Python Scripts inside GX-TXT. The managed Job makes the Session Datasets and the references of the registered producer available.

Registering and running a script

  1. Open the Session with categoria imported as in Bars. Download category_ticks_python.py (ZIP).
  2. Open Viewers → Python Scripts. Create a new document or open the source. For registration give a Script ID as category_ticks_python and a name. Insert the code and use Save.
  3. Open Run → Review and Run. Use Validate to check the context, then Run. In Jobs open the run and compare the output of the two APIs. If the Dataset is missing, check the ID in the Session. If an API is missing, check the preflight of the declarations gxtxt_api_require.
  4. In Plots, check the two references reported by the Job. The code checks the pairs after load_spec and tries the host operation renderSnapshot to show the expected rejection by the Bridge.
Python Script Workspace with the script registered in the Session.
Python Script Workspace with the script registered in the Session. Enlarge
Review and Run of the Python code with the declared APIs.
Review and Run of the Python code with the declared APIs. Enlarge

Arguments and catalog check

from gxtxt import gxtxt_api_call, gxtxt_api_describe, gxtxt_api_require
api = "PLOT_DATASET_API_v4"
gxtxt_api_require("PLOT_DATASET_API_v4@4:plot.dataset")
operations = gxtxt_api_describe(api)["operations"]
spec = gxtxt_api_call(api, "new_spec", ["plot.dataset.xy", "Measured data"])
original = gxtxt_api_call(api, "newSpec", [])

Pass positional arguments in a list. Nested objects such as PlotSpec use dict and sequences of dict. A call has an API ID and an operation key, both case-sensitive. new_spec accepts plot and title. newSpec builds the defaults or receives the flat text options. Local Tcl commands, renderer functions and internal worker paths have their own contracts.

Python recipes

  • category_ticks_python.py (ZIP) publishes the bar plot in v3 and v4 and checks the Upsert identity.
  • publication_lifecycle.py (ZIP) use osservazioni and publishes lines, points, steps, errors, bands and distributions. The scatter with three names also has SVG. The Job reports the rejection of the right-only series with v3.
  • native_models.py (ZIP) use osservazioni, produces an in-memory PNG from a managed source, builds two HDF5 Datasets and publishes the triangular cells and the centroid profile with v4. Run it in a Session where the IDs field_nodes and field_cells are free.

Checking contracts and format variants