{"id":22529,"library":"valohai-utils","title":"Valohai Utils","description":"Utilities for building and running machine learning pipelines on the Valohai platform. Version 0.7.0, stable but occasional updates for Valohai API changes.","status":"active","version":"0.7.0","language":"python","source_language":"en","source_url":"https://github.com/valohai/valohai-utils","tags":["ml","mldataset","pipeline","valohai","machine-learning","utils","mlops"],"install":[{"cmd":"pip install valohai-utils","lang":"bash","label":"PyPI"}],"dependencies":[{"reason":"Core client library for Valohai API interactions","package":"valohai","optional":false},{"reason":"Command-line interface framework","package":"click","optional":true}],"imports":[{"note":"valohai-utils is the PyPI package, but importable as valohai","wrong":"import valohai_utils","symbol":"valohai","correct":"import valohai"},{"note":"Renamed in older versions; always use valohai.task_context","wrong":"from valohai.utils import task_context","symbol":"task_context","correct":"from valohai import task_context"},{"note":"Inputs helper is in internals submodule, not direct import","wrong":"from valohai import Inputs","symbol":"Inputs","correct":"from valohai.internals.inputs import Inputs"}],"quickstart":{"code":"import valohai\nfrom valohai import task_context\n\nif __name__ == '__main__':\n    with task_context() as ctx:\n        # Access input files\n        for file_path in ctx.inputs['dataset']:\n            print(f\"Processing {file_path}\")\n        \n        # Write outputs\n        for output_name in ctx.outputs:\n            ctx.write_output(output_name, data=[], output_path='/some/path')","lang":"python","description":"Minimal Valohai pipeline step using task_context for input/output management."},"warnings":[{"fix":"After writing outputs, call ctx.upload_outputs() or use ctx.write_output() which handles upload.","message":"In v0.5+, task_context no longer auto-uploads outputs; you must explicitly call ctx.upload_outputs() or use write_output which auto-uploads.","severity":"breaking","affected_versions":">=0.5.0"},{"fix":"Use ctx.inputs['input_name'] exactly as defined in valohai.yaml under inputs:.","message":"Inputs are accessed via comma-separated values in the pipeline YAML. If you define an input as 'dataset', you must use ctx.inputs['dataset'] — case-sensitive and matches exactly the YAML key.","severity":"gotcha","affected_versions":"all"},{"fix":"Always test on Valohai or use valohai-utils in an environment with VALOHAI_TOKEN set.","message":"The local execution mode does not validate Valohai API tokens; scripts that work locally may fail on Valohai due to missing environment variables.","severity":"gotcha","affected_versions":"all"},{"fix":"Replace valohai.prepare_execution() with valohai.initialize() and use task_context.","message":"valohai.prepare_execution() is deprecated. Use valohai.initialize() or task_context instead.","severity":"deprecated","affected_versions":"<=0.4"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Install valohai-utils (pip install valohai-utils) then use 'import valohai'.","cause":"The import is 'valohai' not 'valohai_utils'. The package is installed as valohai-utils but import uses valohai.","error":"ModuleNotFoundError: No module named 'valohai'"},{"fix":"Ensure the input key in valohai.yaml matches exactly: e.g., inputs: [name: dataset] then code uses ctx.inputs['dataset'].","cause":"The input name in code does not match the key defined in valohai.yaml inputs section.","error":"KeyError: 'dataset' when accessing ctx.inputs['dataset']"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}