Viash component authoring
Skill Rebell-Leader/SpatialAI_MCP/.codex/skills/viash-component-authoring
Author or modify a Viash component (config.vsh.yaml + script) for an OpenProblems method, especially a task_ist_preprocessing stage. Use when the user wants to add/implement a spatial method, scaffold a component, or fix a config.vsh.yaml.From its SKILL.md
npx -y skills add Rebell-Leader/SpatialAI_MCP --skill viash-component-authoringAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- 4 stars4 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
SKILL.md
3.6 KB, as published. Nobody here has run it
Viash component authoring
A Viash component = a config.vsh.yaml (metadata: arguments, resources, engines)
- a script (Python/R/Bash). Viash compiles it into a CLI, a Docker image, and a Nextflow module.
Steps
-
Identify the stage and its interface. OpenProblems components conform to a
comp_*API merged in via__merge__: /src/api/comp_<stage>.yaml. Find the right interface for the pipeline stage you're implementing (seecontext/ist-preprocessing-pipeline.md) and match its inputs/outputs exactly. -
Write
config.vsh.yaml. Use the modern flat config (nofunctionality:wrapper) withengines:/runners:(not the legacyplatforms:). Follow OpenProblems conventions: merge the stage API, build on the shared base image with a setup partial, include the standard metadata block, and label the nextflow runner with resource directives. This mirrors a realtask_ist_preprocessingcomponent:__merge__: /src/api/comp_<stage>.yaml name: my_method label: "My Method" summary: "One-line biological purpose." description: "Longer description with method context." links: documentation: "https://github.com/openproblems-bio/task_ist_preprocessing" repository: "https://github.com/openproblems-bio/task_ist_preprocessing" references: doi: "10.xxxx/xxxxx" # the method's paper arguments: - name: "--some_param" type: double default: 1.0 description: "Biologically meaningful parameter." # Note: --input/--output are usually inherited from the merged comp_<stage> API. resources: - type: python_script path: script.py engines: - type: docker image: openproblems/base_python:1 # shared base, not raw python:* __merge__: - /src/base/setup_spatialdata_partial.yaml # extra deps via setup partial - type: native runners: - type: executable - type: nextflow directives: label: [ midtime, lowcpu, lowmem ] # resource labelsConfirm the exact
__merge__paths (the stage API and the base setup partial) and the current Viash schema against the live repo before building — keys evolve between major Viash versions. -
Write the script with the dev parameter block:
import spatialdata as sd ## VIASH START par = {"input": "resources_test/.../dataset.zarr", "output": "output.zarr", "some_param": 1.0} ## VIASH END sdata = sd.read_zarr(par["input"]) # ... implement; keep coordinate systems consistent ... result.write(par["output"])Fail loudly: log the error and
sys.exit(1)on failure. -
Validate before building. Run
analyze_workflow_configurationon theconfig.vsh.yamlto catch structural/dependency issues. -
Build & test with the user's local Viash (the server does not run it):
viash ns buildviash run config.vsh.yaml -- --input <test>.zarr --output tmp/out.zarr- unit test: add a
test_resourcesscript (e.g.test.py) to the config and runviash test config.vsh.yaml— every OpenProblems component ships a test. - integration:
nextflow run main.nf -profile test,docker
Don't
- Don't invent
create_spatial_component/build_viash_componenttool calls — they're roadmap, not implemented. Generate files and runviashin the terminal.