Skip to content

[recipes] obsidian-vault-import: --source-label to override metadata.source#302

Open
dhanjit wants to merge 1 commit into
NateBJones-Projects:mainfrom
dhanjit:contrib/dhanjit/source-label-flag
Open

[recipes] obsidian-vault-import: --source-label to override metadata.source#302
dhanjit wants to merge 1 commit into
NateBJones-Projects:mainfrom
dhanjit:contrib/dhanjit/source-label-flag

Conversation

@dhanjit
Copy link
Copy Markdown

@dhanjit dhanjit commented May 14, 2026

Summary

Adds a --source-label flag to recipes/obsidian-vault-import/import-obsidian.py so the operator can stamp a more specific origin tag in metadata.source. Default is unchanged (obsidian), so existing scripts behave identically.

Motivation

The recipe currently hardcodes metadata.source = "obsidian". That's accurate when the vault is a hand-curated Obsidian vault, but increasingly people pipeline other tools (Apple Journal exporters, Day One exporters, Roam dumps) through Obsidian-style markdown and into OB1 via this recipe.

After import, all those thoughts read as just "obsidian" — provenance is lost. There's no way to query "all Apple Journal entries" or "all Day One imports" separately.

Change

+ parser.add_argument("--source-label", type=str, default="obsidian", ...)
  ...
  'metadata': {
-     'source': 'obsidian',
+     'source': args.source_label,
      ...
  }

Plus a README subsection documenting it.

Usage

# default: unchanged (source = "obsidian")
python import-obsidian.py /path/to/vault

# new: stamp a specific origin
python import-obsidian.py /path/to/journal-vault --source-label apple-journal
python import-obsidian.py /path/to/dayone-vault  --source-label day-one

After import: metadata->>'source' = 'apple-journal' retrieves only Apple Journal-originated thoughts.

Backward compatibility

100%. Default value matches the previous hardcoded constant. Anyone not passing the flag sees zero behavioral change.

Test plan

  • --help shows the new flag
  • Default value is obsidian (preserves existing behavior)
  • Passing --source-label apple-journal sets metadata.source accordingly on all inserted rows
  • No other metadata key is affected

Related

Complementary to #301 (preserve full frontmatter under metadata.frontmatter). With both merged, a single Obsidian vault can carry multi-source provenance: metadata.source says where the thought came from, and metadata.frontmatter.* carries the per-note original YAML.

…ata.source

By default, every imported thought gets metadata.source = "obsidian".
When a vault aggregates notes from multiple upstream tools (e.g. an
Apple Journal exporter, a Day One exporter, an old Roam dump), there
was no way to tell them apart in OB1 after import — they all read as
just "obsidian", losing provenance.

This adds --source-label (default unchanged: "obsidian") so the
operator can stamp a more specific origin tag:

    python import-obsidian.py /path/to/journal-vault \
        --source-label apple-journal

After import, metadata->>'source' = 'apple-journal' filters those
thoughts specifically. No other behavior changes; existing scripts
that don't pass the flag get the default.

README updated with a "Customizing the source label" subsection.
@github-actions github-actions Bot added the recipe Contribution: step-by-step recipe label May 14, 2026
@alanshurafa alanshurafa added area: recipes Review area: recipes review: ready-for-maintainer Community reviewer recommends maintainer review alan-reviewed Reviewed by Alan Shurafa in Community Reviewer role labels May 20, 2026
@alanshurafa
Copy link
Copy Markdown
Collaborator

Thanks for the contribution. Clean additive feature — --source-label lets imports from different upstream tools be tagged distinctly in metadata.source, with the default staying "obsidian". Well-documented. Recommend maintainer review.

— Alan (community reviewer; non-binding)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

alan-reviewed Reviewed by Alan Shurafa in Community Reviewer role area: recipes Review area: recipes recipe Contribution: step-by-step recipe review: ready-for-maintainer Community reviewer recommends maintainer review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants