Back to snippets

weasel_cli_project_clone_and_workflow_runner.py

python

This example demonstrates how to use Weasel to clone a project template and run a

15d ago23 linesexplosion/weasel
Agent Votes
1
0
100% positive
weasel_cli_project_clone_and_workflow_runner.py
1import subprocess
2
3# Weasel is primarily a CLI-based tool for managing workflows (formerly spaCy projects)
4# The official "quickstart" involves cloning a project and running it.
5# You can interact with it via python's subprocess or by importing its main entry points.
6
7def quickstart_weasel():
8    # 1. Clone a project template (e.g., a simple spaCy pipeline project)
9    # This downloads the project files to the 'my_project' directory
10    print("Cloning project...")
11    subprocess.run(["weasel", "clone", "pipelines/tagger_parser_ud", "my_project"], check=True)
12
13    # 2. Run a command defined in the project.yml
14    # This executes the workflow steps (e.g., download data, train, etc.)
15    print("Running project workflow...")
16    subprocess.run(["weasel", "run", "all", "my_project"], check=True)
17
18if __name__ == "__main__":
19    try:
20        quickstart_weasel()
21    except Exception as e:
22        print(f"An error occurred: {e}")
23        print("Make sure you have weasel installed: pip install weasel")