Skip to content

v0.6.0-rc1

Pre-release
Pre-release

Choose a tag to compare

@amc-corey-cox amc-corey-cox released this 23 Oct 20:41
1323cc8

This release makes output match the target schema, catches more spec mistakes before a run, and replaces Session with a shorter way to set up a transformer from Python, along with a rewrite of the docs and tutorials.

The output-typing and identifier changes were validated against dm-bip before release. Every BDC cohort ran end to end and was checked against BDCHM, with no map-time or validation failure traced to linkml-map.

Heads up: output changes

These make output valid against the target schema where it wasn't before, but a downstream consumer may see different values.

  • Values take the target schema's type. When a slot derivation declares no range, values are now coerced to the target slot's range from --target-schema. This covers populated_from, expr: and value: results. '52.3' from a TSV becomes a number, "false" becomes False, and a value that can't be parsed fails at mapping time instead of at validation. An explicit spec range still wins. (#361, #366)
  • Enum-ranged slots emit the permissible value key. A spec can spell a value by its key, meaning, title or an alias. FEMALE and OMOP:8532 both come out as the key. A value matching no permissible value passes through with a warning, or fails under --strict. (#373)
  • Decimals are exact everywhere. range: decimal values become exact decimals and are written as exact numbers in JSON, YAML, TSV/CSV, Parquet and DuckDB. Trailing zeros are kept (52.30 stays 52.30). (#355)
  • Streaming YAML drops null slots, like the JSON writers already did. (#367)
  • Tabular runs apply is_a inheritance. A class derivation's is_a/mixins parents were applied when mapping single objects but ignored when streaming TSV/CSV input, so inherited slot derivations and joins were missing from the output. (#388)

Heads up: identifiers are opt-in

A class derivation whose target class has an identifier slot it doesn't derive is now an error, unless you set mint_ids: true on the spec, in class_defaults.<Class>, or on the class derivation. With it set, the record gets a content-hash id: uuid5 of the record's canonical content, so the same record always gets the same id. These are content hashes, not stable identifiers. Entities other records refer to (participants, visits) should keep deriving natural-key ids. (#357, #365)

Heads up: runs that silently did nothing now fail

  • No input data is an error. If no class derivation finds its table in the input, map-data now fails with No input data for any class derivation: expected one of ['Person'], found ['people']. It used to write nothing and exit 0. Runs where only some derivations find data are unchanged. (#379)
  • A single input file is read as --source-type. Tables are named by file stem, so map-data --source-type Person people.tsv looked for a Person table, found people, and produced nothing. A single file now takes the --source-type name. (#379)
  • Statement blocks under --unrestricted-eval run as written. A multi-statement expression used to run only its first statement and ignore assignments. It now runs in full, reading slots as src.<slot>. A {slot} or bare slot name there is undefined, and fails the row instead of quietly returning None or a wrong value. Single expressions are unchanged. (#383)

Removed and deprecated

  • Session is deprecated. Construct an ObjectTransformer instead (below). It now carries the standard @deprecated marker, so type checkers and IDEs flag its use. (#377, #387)
  • The function-based stream writers are removed: yaml_stream, json_stream, jsonl_stream, tsv_stream, csv_stream, get_stream_writer and TabularStreamWriter.stream, deprecated since 0.5.4. Use make_stream_writer and StreamWriter.process, or MultiStreamWriter. (#385)
  • from linkml_map import * no longer exports Session. It raised AttributeError before, since __all__ listed a name the package never imported. (#351)

Setting up a transformer in Python

The constructor takes the spec and schemas as paths, dicts or loaded objects, replacing Session. load_specification is exported too. (#376, #379)

from linkml_map import ObjectTransformer

tr = ObjectTransformer(specification="spec.yaml", source_schemaview="source.yaml", target_schemaview="target.yaml")
tr.map_object(row)

Constant records are emitted once

A class derivation with no populated_from whose slots are all constant value:s now yields one object and reads no input, instead of one copy per row of some table. (#390)

validate-spec catches more before you run

These checks also run in the map-data pre-flight.

  • value: and value_mappings literals that aren't permissible values of the target enum. (#374)
  • A spec range that overrides a conflicting target range, such as range: string on an enum slot. (#375)
  • A range: that names no type, class or enum. (#383)
  • Misspelled keys in a derivation's own joins: block. These used to pass, and then every joined value came out null. (#382)
  • Fewer false errors: on dotted references through joined tables (#378), constant value: slots (#350), and is_a-only parent derivations (#359).

Docs

The docs are split into a Quick Start, a Python Tutorial, a Writing Specifications guide and a Command-Line Reference, with every example re-run. The tutorials no longer use Session. Schema reference pages moved to per-kind folders, so links like schema/ClassDerivation/ are now schema/classes/ClassDerivation/. (#377, #384)

Other fixes

  • multi_file_transformer resolved inputs against the output directory when given a string output_directory. (#352)
  • CSV output didn't quote list and dict cells, so a multi-item list split across columns. (#355)

Dependencies

  • linkml and linkml-runtime are locked at 1.12.1. The >=1.11.0 floor is unchanged.
  • New: simplejson (exact decimals in JSON) and typing-extensions (the @deprecated marker).