Skill state and logging

Log to the run, pass values between skills in a run, write run artifacts and project data, read the run's identity, and detect the simulator.

Logging

print_log(*args, runlog=False, runlog_type="transfer", save_to_project=False, export=False, sep=" ", end="\n")

Logs a message, formatting its arguments as print does. Use it instead of print.

  • A plain call goes to the service log. On a run of a single skill (the Skills Editor, zeon run <skill>) it is also shown in the skill's console and written to the run log, up to the first 2000 lines of a run; after that one line says the output was cut. On a workflow run, each step's plain calls are written to the run log under that step, up to 2000 lines per step. zeon logs ID and the app's Log tab show them.
  • runlog=True also writes the message to the run log, the step-by-step record shown for every run. Use it for what an operator needs to see during a workflow.
  • runlog_type sets the run-log entry type. The starter skills open with print_log(runlog=True, runlog_type="step_start"), which starts the step's group in the run log under the step's name.
  • save_to_project=True (deprecated; prefer export=True), with runlog=True, also appends the entry to data/logs/<execution_id>/run_log_<execution_id>.jsonl in the project, which syncs with it.
  • export=True marks the run for upload to your lab's own storage bucket when data export is configured. One call anywhere in the run is enough; the whole run folder is uploaded when the run ends.
print_log(f"plate_transfer: {plate_id} -> {dest_id}.{destination_anchor}")
print_log(f"Moved {plate_id} to {dest_id}", runlog=True)

Passing values between skills

A skill node's parameters do not read a previous node's return value. To hand a value from one skill to a later one in the same run, use the skill variables:

FunctionEffect
set_skill_variable(key, value)Stores any Python value under key.
get_skill_variable(key, default=None)Reads it back, or default when unset.
clear_skill_variable(key)Removes key; no error when it is absent.

The store is cleared when a workflow run starts. A run of a single skill (the Skills Editor, zeon run <skill>) does not clear it, so values carry from one single-skill run to the next; the Skills Editor's Reset Variables button clears it. The store lives in memory only: do not use it to keep anything beyond a run.

Files a run produces

FunctionReturns
execution_dir(create=False)The current run's artifact folder (run log, your own outputs), outside the project. None outside a run.
project_data_dir(subdir=None, create=False)<project>/data/ or a subfolder of it, inside the project. None when no project is loaded.

create=True creates the folder. Files under execution_dir() belong to the run and do not sync with the project. Files under project_data_dir() are part of the project: they are pushed to the cloud copy of the project when a workflow run finishes, and come down to your working tree with zeon pull or zeon sync (see What gets synced). Key entries by run so runs do not overwrite each other:

import json

eid = ExecutionInfoContext.get().execution_id
d = project_data_dir(f"readings/{eid}", create=True)
if d:
    (d / "reading.json").write_text(json.dumps(reading))

Each part of subdir is sanitised, so a name cannot leave the data/ folder.

The run's identity

ExecutionInfoContext.get().execution_id is the id of the current run (empty outside a run). It is the id the CLI and the app show for the run.

Simulator or real rig

is_sim_mode() returns True when the skill acts on the simulated set and False on real hardware. Use it around steps with no simulated counterpart. It says nothing about whether a real move is safe.

Per-object live state

get_world_state and set_world_state read and update state stored with the world per object, such as a tip box's next tip. See Objects, anchors, and the world.


Did this page help you?