Get started
Install
Install from the repository (the v0.1.6 tag predates the 2026-08-13 rename and still packages the old salmonpy name; the first tag installable as metasalmonpy will be the next parity release):
python -m pip install \
"metasalmonpy @ git+https://github.com/salmon-data-mobilization/metasalmonpy@main"For development, clone the repository and install the test dependencies:
git clone https://github.com/salmon-data-mobilization/metasalmonpy.git
cd metasalmonpy
python -m venv .venv
. .venv/bin/activate
python -m pip install -e ".[test]"The optional context extra adds Excel and PDF readers for LLM context:
python -m pip install -e ".[context,test]"Create a package
Use create_sdp() for the standard one-call workflow. A single DataFrame uses table_id; a mapping of DataFrames uses each mapping key as its table id.
import pandas as pd
from metasalmonpy import create_sdp
catch = pd.DataFrame(
{
"survey_year": [2024, 2025],
"species": ["Coho", "Coho"],
"catch_count": [42, 57],
}
)
path = create_sdp(
catch,
path="coho-catch-sdp",
dataset_id="coho-catch",
table_id="catch",
seed_semantics=False,
)Setting seed_semantics=False makes this example fully local. Semantic retrieval can contact configured ontology services; LLM review remains off unless llm_assess=True.
Review the output
The canonical layout is:
coho-catch-sdp/
|-- .metasalmonpy-package
|-- README-review.txt
|-- datapackage.json
|-- data/
| `-- catch.csv
`-- metadata/
|-- dataset.csv
|-- tables.csv
|-- column_dictionary.csv
`-- codes.csv
Review the metadata in this order:
- Complete
metadata/dataset.csvandmetadata/tables.csv. - Confirm roles, types, definitions, and semantic IRIs in
metadata/column_dictionary.csv. - Confirm controlled values and IRIs in
metadata/codes.csv. - Replace every
MISSINGplaceholder andREVIEW:IRI. - Run strict validation.
from metasalmonpy import validate_salmon_datapackage
result = validate_salmon_datapackage(path, require_iris=True)
print(result)Strict validation fails while unresolved review markers remain. This protects the boundary between machine suggestions and curator-approved metadata.
Read the package
from metasalmonpy import read_salmon_datapackage
package = read_salmon_datapackage(path)
dictionary = package["dictionary"]
resources = package["resources"]Continue with the package lifecycle for multi-table packages and manual assembly, or the semantic review guide for ontology suggestions.