Skip to main content

MRG Import Tool

The MRG Import Tool (MRG importer) ensures that the scope within which it is run, obtains a local copy of all MRGs that are available in the scopes that are mentioned in the scopes section of its SAF. This makes life easy for various tools, e.g., the MRGT and the TRRT, that can now assume that all MRGs that they may need to consult in order to do their job, are readily available.

Installing the Tool

The tool can be installed from the command line and made globally available by executing

npm install -g @tno-terminology-design/mrg-import
Before running the tool from the command line, make sure you have met the necessary prerequisites depending on your operating environment.

  1. Node.js and NPM: Ensure Node.js and NPM are installed.
  2. Global Installation: If you have installed the package globally, confirm the global NPM modules path by running npm config get prefix. The global modules are usually stored under <prefix>/node_modules.
  3. Environment Variables: Add the path to global NPM binaries to your system's PATH environment variable. This should be <prefix> on Windows. To add to PATH, you can edit your environment variables or run set PATH=%PATH%;<prefix> in the CMD.

Calling the Tool

The behavior of the MRG importer can be configured per call e.g. by a configuration file and/or command-line parameters. The command-line syntax is as follows:

mrg-import [ <paramlist> ]

where <paramlist> is an (optional) list of parameters.

Legend

The columns in the following table are defined as follows:

  1. Parameter specifies the parameter and further specifications
  2. Req'd specifies whether (Y) or not (n) the field is required to be present when the tool is being called. If required, it MUST either be present in the configuration file, or as a command-line parameter.
  3. Description specifies the meaning of the Value field, and other things you may need to know, e.g. why it is needed, a required syntax, etc.

If a configuration file used, the long version of the parameter must be used (without the preceding --).

KeyReq'dDescription
-c, --config <path>nPath (including the filename) of the tool's (YAML) configuration file.
-s, --scopedir <path>YPath of the scope directory from which the tool is called.
-e, --onNotExist <action>nThe action in case an MRG file unexpectedly does not exist.
-V, --versionnoutput the version number of the tool.
-h, --helpndisplay help for command.
`-e`, `--onNotExist` Actions
<action>Description
'throw'an error is thrown (an exception is raised), and processing will stop.
'warn'a message is displayed (and logged) and processing continues.
'log'a message is written to a log(file) and processing continues.
'ignore'processing continues as if nothing happened.

Running the Tool

The current version of the tool simply reads all MRG files from all scopes that are specifeid in the SAF.

It does so by reading the scopes section of its SAF (of the current scope). This section contains entries, each of which specifies a scopetag field and a URL field. We will use <my-stag> and <url> to refer to the values of these fields respectively.

For each such entry, the tool obtains the SAF of that scope, which is located at <url>, and from there, it determines the path of the (remote) glossarydir, as well as the scopetag <stag> that it uses to refer to itself, and is used as part of the filenames that contain MRGs that are generated within that scope.

Then, it copies all files from the remote glossarydir that are named mrg.<stag>*.yaml to the glossarydir of the current scope, and replaces the <stag> part with <my-stag> (as the scope that calls itself <stag> is called <my-stag> in the current scope).

Exceptions, Warnings, and Logging

Editor's note

This section needs to be reviewed/revised so as to enable a consistent way of error checking and logging, similar to what is done in the TRRT

The general principle is that the MRG importer helps its users to do their jobs. This means that errors that terminate the processing are limited to the max, that warnings (perhaps at different 'levels' of detail/severity) are given output whenever possible (yet may be limited by command-line options), and that texts are tailored for the envisaged users of the tool.

Also, the MRGT provides suggestions that help tool-operators (curators) to not only identify, but also fix any problems.