losalamos.tools.ingest_variables#

Batch-creation tool for variable registry notes.

Reads a seed file (TOML, YAML, or JSON) and writes one Obsidian .md note per entry into a target vault folder using losalamos.notes.NoteVariable.

Codes are user-assigned and must appear in each entry. Shared fields (subject, tags, category, etc.) can be declared once in defaults and are merged into every entry automatically.

Usage#

python -m losalamos.tools.ingest_variables --variables <seed_file> [--overwrite]

Seed file#

The seed holds one or more batches. Each batch targets one vault folder and carries its own defaults and entries.

[[batch]]
vault = "/path/to/vault/hydrology"

[batch.defaults]
subject  = "[[Surface Hydrology]]"
tags     = ["hydrology"]
category = "physical"

[[batch.entries]]
code      = "F101V001"
name      = "Streamflow"
alias     = "streamflow"
units     = "m^3/s"
range     = "[0U)"
symbol    = "Q"
dimension = "L^{3}/T"


[[batch]]
vault = "/path/to/vault/climate"

[batch.parameters]
fallback_title = false

[batch.defaults]
subject = "[[Climatology]]"
tags    = ["climate"]
batch:
  - vault: /path/to/vault/hydrology
    defaults:
      subject:  "[[Surface Hydrology]]"
      tags:     [hydrology]
      category: physical
    entries:
      - code:      F101V001
        name:      Streamflow
        alias:     streamflow
        units:     m^3/s
        range:     "[0U)"
        symbol:    Q
        dimension: "L^{3}/T"

  - vault: /path/to/vault/climate
    parameters:
      fallback_title: false
    defaults:
      subject: "[[Climatology]]"
      tags:    [climate]
    entries:   []
[
  {
    "vault": "/path/to/vault/hydrology",
    "defaults": {
      "subject":  "[[Surface Hydrology]]",
      "tags":     ["hydrology"],
      "category": "physical"
    },
    "entries": [
      {
        "code":      "F101V001",
        "name":      "Streamflow",
        "alias":     "streamflow",
        "units":     "m^3/s",
        "range":     "[0U)",
        "symbol":    "Q",
        "dimension": "L^{3}/T"
      }
    ]
  },
  {
    "vault": "/path/to/vault/climate",
    "parameters": {"fallback_title": false},
    "defaults": {
      "subject": "[[Climatology]]",
      "tags":    ["climate"]
    },
    "entries": []
  }
]

Batch keys#

vault

Required per batch. Path to the destination vault folder.

parameters

Optional dict of batch-level behavioural flags.

fallback_title (bool, default true)

When true, entries whose title is absent or empty receive the value of name as their title automatically.

defaults

Fields applied to every entry in the batch. Entry-level values override on conflict, except for tags which are merged additively.

tags

Additive. defaults tags apply to every entry; entry-level tags extend them. The base tag variable-note is always prepended.

subject

Entry-level value overrides the default for that entry. Write as Obsidian wiki-link notation: [[Note Name]].

code

User-assigned. Not validated — omitting it leaves the field blank.

Functions

ingest_variables(seed_path[, overwrite])

Read a seed file (TOML, YAML, or JSON) and process all batches.

losalamos.tools.ingest_variables.ingest_variables(seed_path: Path, overwrite: bool = False) None[source]#

Read a seed file (TOML, YAML, or JSON) and process all batches.

The seed must be a list of batch dicts, each with a vault, optional defaults, and an entries list. TOML and YAML files may wrap batches under a top-level batch key; JSON files may be a bare list. A single batch dict is also accepted.

Parameters:
  • seed_path (pathlib.Path) – Path to the seed file (TOML, YAML, or JSON).

  • overwrite (bool) – If False (default), existing files are skipped.