Advanced Octave A16 — Reproducible transformations

by Giux GX-TXT, octave-en, scripts-en 2 min read

Advanced GNU Octave with GX-TXT · Module 03

A transformation can produce a new Dataset while keeping the source separate. In GX-TXT the Dataset Transform public service allows you to describe the operation, plan it and publish the result through the Script Bridge.

Objectives and prerequisites

We use the octave_advanced_sensor synthetic series of lesson A07, which contains time and tension. We take note of introductory course publications and previous advanced lessons. The test uses GX-TXT dev112-P011-bis and Octave 9.4.0.

We design the two variables in a new Dataset. In this example the source contains only two: the didactic value is to observe the transformation cycle, not to reduce the number of columns. The octave_advanced_projection result is created-only: to repeat the exercise choose a free ID or a new Session.

Describe the transformation

Import proietta_dataset.m, register it and run it from Runner.

The request brings together operation, source, output ID and options in a poster:

src = struct('dataset_id','octave_advanced_sensor', ...
             'variable_ids',{{'time_s','voltage_v'}});
output = struct('dataset_id','octave_advanced_projection','storage','auto');
manifest = struct('api_version',1,'operation','project_variables', ...
                  'sources',{{src}},'output',output,'options',struct(), ...
                  'schema_policy',struct());
plan = gxtxt_api_call(api,'plan',{manifest});

project_variables selects the variables indicated in the order required. The double levels of cells preserve the ID and source collection as fields of the Octave structure. The plan describes the operation before the publication; the number of rows envisaged is read by the result of the planning.

Run and release

The program uses unwind_protect to release the plan even if the execution fails:

unwind_protect
  fprintf('Planned rows: %d\n', plan.row_count);
  result = gxtxt_api_call(api,'execute',{plan});
  assert(strcmp(result.dataset_id,output.dataset_id));
unwind_protect_cleanup
  gxtxt_api_call(api,'release_plan',{plan.plan_id});
end_unwind_protect

Finally, he reads the Dataset derived through the canonical API. A transformation of this type produces a distinct resource and does not require to modify the internal files of the Session.

The test shows 11 rows and 11 rows read in the result. This control does not compare all values: in a real analysis it also checks content, order, unity and origin. Different operations, such as filtering or converting units, require specific options and controls; are not implicit in this projection.

Exercise

  1. What role does the octave_advanced_projection ID play?
  2. Why is the plan released in the cleaning section?
  3. Why don’t 11 incoming and outgoing rows just prove that every value is correct?

Worked solution

  1. Identify the new derived Dataset, distinct from the source.
  2. To free the resource even in the presence of a mistake during the execution.
  3. Counting does not verify content, order, unity or correspondence of variables.

Download the Module 03 scripts (ZIP)

#GNU Octave #GX-TXT #GX-TXT public APIs

Other steps of this project

Leave a Reply

Your email address will not be published. Required fields are marked *