Advanced Octave A02 — Dynamic availability and compatibility
Advanced GNU Octave with GX-TXT · Module 01
A02 — Disponibilità dinamica e compatibilità
A scientific script may require more services: read a Dataset, calculate a regression and prepare a chart. In this lesson we build a table that controls, in the Octave Bridge actually started, each operation necessary to the flow.
Objectives and prerequisites
We assume the skills of introductory Octave course and Class A01. We will learn how to use gxtxt_api_has, gxtxt_api_has_operation, a two-column cell array and the short circuit of && to verify dependencies without assuming that each installation has the same inventory.
Test environment: GX-TXT dev112-P011-bis and GNU Octave 9.4.0. The table describes the availability during that execution; a release or a set of different modules can return other values.
Example: a dependency matrix
Import compatibilita.m into the Octave Script Workspace, save the script in the Session and start it from Run → Open Script Runner → Run Job.
% Advanced Octave course A02: verify a workflow's public operations.
% SPDX-License-Identifier: GPL-3.0-or-later
requirements = {'CANONICAL_DATASET_API_v2', 'list'; ...
'CANONICAL_DATASET_API_v2', 'read_range'; ...
'NUMERIC_API_v1', 'linear_regression'; ...
'PLOT_DATASET_API_v4', 'validate_spec'};
ready = true;
fprintf('Workflow compatibility: API / operation / available\n');
for k = 1:rows(requirements)
api = requirements{k,1};
operation = requirements{k,2};
present = gxtxt_api_has(api);
available = present && gxtxt_api_has_operation(api, operation);
ready = ready && available;
fprintf('%s / %s / %d\n', api, operation, available);
endfor
fprintf('All required operations available: %d\n', ready);
if !ready
error('Required workflow operation unavailable; see compatibility table.');
endif
Each requirements row associates an API identifier with an operation. Graffe braces extract the actual text from the cell. gxtxt_api_has controls the provider’s presence in the Bridge; gxtxt_api_has_operation controls the operation. With present &&..., Octave does not assess the second control if the first is false. The ready accumulator becomes false if at least one element is missing.
In our execution the four rows report 1 and the final summary is 1 : the operations are available. The table does not run them and does not guarantee that a future request has correct arguments. In particular, the presence of validate_spec does not prove that any graph is valid or readable.
Designing a useful control
You can add rows for the operations required by your project and use gxtxt_api_describe, introduced in A01, to consult the contract. gxtxt_api_list instead allows you to explore the APIs displayed in the current context; the selective table is used to control what your flow really uses.
Do not rely on the inventory order and do not automatically replace a missing operation with another just because the name looks similar. If an addiction is mandatory, stop the script before the scientific stage avoids incomplete results presented as an completed analysis.
Exercise
- In a copy of the script, add a row with a non-existent operation name for an API present. What value does it appear and why does the script end with error?
- What is the difference between API available and available operation?
- A table all at
1ensures that your Dataset contains correct units?
Worked solution
- The line returns
0;readybecomes false and the final guard signals the missing dependence. - The provider can exist without exposing the single operation required in that version.
- No. Check the presence of operations, not the correctness of data, units or model.
The next lesson will deepen the values and dimensions transferred between Octave and Bridge.
Other steps of this project
- Advanced Octave A75 — Dynamical systems in phase space
- Advanced Octave A81 — Geography of the waves and a 3D surface
- Advanced Octave A82 — Age, sex and demographic inequalities
- Advanced Octave A83 — All-cause mortality, certified COVID deaths and surveillance
- Advanced Octave A84 — A reproducible public account
- Advanced Octave A73 — Optimization landscapes and 3D trajectories