reqif Labs
Syside Automator ReqIF import/export.
This module converts between ReqIF (Requirements Interchange Format) files and SysMLv2 workspaces. It can be driven from the command line or from Python scripts; both surfaces share the same underlying entry points.
Installation
The public functions and CLI both require the [reqif] extra which pulls in
additional third-party dependencies. Install it with:
pip install 'syside[reqif]'
# or, for uv-managed projects:
uv add 'syside[reqif]'
When the extra is missing, the captured ImportError is exposed as
_missing_extra_error for callers building their own CLI.
Command-line usage
The CLI is reachable both through the top-level syside console script
and as a runnable module. The three are equivalent:
syside reqif <subcommand> [options]
python -m syside reqif <subcommand> [options]
python -m syside.reqif <subcommand> [options]
All subcommands operate on the current working directory as the workspace root. The available subcommands are:
init— write the canonicalSysideReqIFSysMLv2 library into the workspace so subsequent imports have something to reference. Use--lib-dirto override the defaultLIBRARY_DIRlocation.import <file>— convert a.reqifor.reqifzfile into SysMLv2 packages under the workspace, performing a fresh build or a delta update depending on existing content. Attachments are extracted into--attachments-dir(default:ATTACHMENTS_DIR).lock— assign stable UUIDs and last-change timestamps to any ReqIF-tagged elements that don’t yet have them, so subsequent round-trips preserve identity. Takes no options.export— convert the SysMLv2 models from the workspace into a.reqifor.reqifzfile.check reqif <file>— validate that a ReqIF file satisfies the invariants required for round-trippable conversion (relation-group ownership, no hierarchy cycles, no name shadowing, etc.).check sysml— validate the workspace SysMLv2 model (currently enforces at most one top-level package per.sysmldocument, and that all ReqIF tags are locked).
Each subcommand exits 0 on success and raises on failure.
Library usage
Every CLI subcommand has a public Python counterpart: an options
dataclass plus a function named after the subcommand. The functions
return the CLI exit code and raise ValueError on validation
failures, and operate on the current working directory (use
os.chdir to target a different workspace).
from pathlib import Path
from syside.reqif import (
ImportOptions,
CheckReqifOptions,
InitOptions,
check_reqif,
import_,
init,
)
# Initialise the workspace once.
init(InitOptions(lib_dir=None))
# Validate a ReqIF file before importing it.
reqif_file = Path("requirements.reqif")
check_reqif(CheckReqifOptions(file=reqif_file))
# Import the file; attachments land in ./attachments_reqif/.
import_(ImportOptions(file=reqif_file, attachments_dir=None))
The default-path constants (LIBRARY_PKG, LIBRARY_DIR,
ATTACHMENTS_DIR) are re-exported here so callers can reference
the same defaults the CLI uses without reaching into private modules.
Index
Classes
Parsed arguments for the |
||
Parsed arguments for the |
||
Parsed arguments for the |
||
Parsed arguments for the |
||
Parsed arguments for the |
||
Mixin for subcommand option dataclasses. |
Attributes
Functions
Run the ReqIF-side validation suite against |
||
Run the SysMLv2-side validation suite against the current workspace. |
||
Run the SysMLv2 -> ReqIF conversion. |
||
Run the ReqIF -> SysMLv2 conversion. |
||
Initialise the current workspace for ReqIF <-> SysMLv2 conversion. |
||
Lock unlocked ReqIF-tagged elements in the workspace SysMLv2 model. |
Attributes
- ATTACHMENTS_DIR = 'attachments_reqif'
Default workspace-relative directory that
syside reqif importextracts ReqIF attachments into whenImportOptions.attachments_diris unset.
- LIBRARY_DIR = 'lib'
Default workspace-relative directory for the SysMLv2 ReqIF library, used by
syside reqif initwhenInitOptions.lib_diris unset.
- LIBRARY_PKG = 'SysideReqIF'
Name (without
.sysmlextension) of the canonical SysMLv2 library package thatsyside reqif initwrites into the workspace.
Functions
- check_reqif(opts: syside.reqif.CheckReqifOptions) int
Run the ReqIF-side validation suite against
opts.file.Loads the file into the intermediate representation runs the same validations as when doing
run_import.Returns
0on success; raisesValueErroron the first failed check.
- check_sysml(opts: syside.reqif.CheckSysmlOptions) int
Run the SysMLv2-side validation suite against the current workspace.
Loads every
.sysmldocument under the current working directory and runs the same validations as when doingrun_export.Returns
0on success; raisesValueErroron the first failed check.
- export(opts: syside.reqif.ExportOptions) int
Run the SysMLv2 -> ReqIF conversion.
Loads the workspace SysMLv2 model under the current working directory and converts it into ReqIF saved into
opts.file. If theopts.reqifzflag is set, the resulting ReqIF file is zipped into a.reqifzfile, along with all files found inopts.attachments_dir(or<cwd>/joined withsyside.reqif.ATTACHMENTS_DIRwhen unset) recursively.opts.titleis used as the title for the ReqIF file and is required.opts.commentis used as the comment for the ReqIF file.opts.repository_idis used as the repository ID for the ReqIF file.
The latter two are optional.
Returns
0on success.
- import_(opts: syside.reqif.ImportOptions) int
Run the ReqIF -> SysMLv2 conversion.
Loads the workspace SysMLv2 model under the current working directory and parses
opts.fileinto the intermediate representation. If the workspace contains no existing ReqIF content, a fresh set of SysMLv2 packages is built from the IR; otherwise a delta import is performed against the existing content.Attachments referenced by the ReqIF file are extracted into
opts.attachments_dir(or<cwd>/joined withsyside.reqif.ATTACHMENTS_DIRwhen unset).Returns
0on success.
- init(opts: syside.reqif.InitOptions) int
Initialise the current workspace for ReqIF <-> SysMLv2 conversion.
Scans the current working directory for an existing
<{LIBRARY_PKG}>.sysmlfile (whereLIBRARY_PKGissyside.reqif.LIBRARY_PKG), normalising any BOM and CRLF/CR line endings before comparison so a Windows checkout is not mistaken for a stale copy. If the canonical library content is already present nothing happens; otherwise the canonical SysMLv2 ReqIF library is written underopts.lib_dir(orsyside.reqif.LIBRARY_DIRwhen unset).Raises
ValueErrorif more than one<{LIBRARY_PKG}>.sysmlis found in the workspace, since a “first hit wins” rewrite would silently leave the other copies stale.Returns
0on success.
- lock() int
Lock unlocked ReqIF-tagged elements in the workspace SysMLv2 model.
Walks the model for elements carrying the ReqIF tag whose identifier or last-change fields have not yet been populated, generates fresh UUIDs and timestamps, and writes them back so subsequent ReqIF round-trips have stable identities.
Unlike the other entry points this function takes no options — it always operates on the workspace under the current working directory.
Returns
0on success.