CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/pypi-doit

Automation tool that brings the power of build-tools to execute any kind of task with efficient DAG-based execution and plugin architecture

Pending
Overview
Eval results
Files

core-api.mddocs/

Core API Functions

Primary programmatic interface for running tasks and accessing doit functionality directly from Python code without using the command line interface.

Capabilities

Task Execution

Execute doit tasks programmatically from Python code using task creators from modules or dictionaries.

def run(task_creators):
    """
    Run doit using task_creators from module or dict.
    
    This function provides a shortcut to execute tasks without using the
    command line interface. It will call sys.exit() with the appropriate
    return code.
    
    Args:
        task_creators: module or dict containing task creator functions
        
    Returns:
        Does not return - calls sys.exit() with result code
        
    Raises:
        SystemExit: Always called with return code (0=success, 1=failure, 2=error, 3=user error)
    """
def run_tasks(loader, tasks, extra_config=None):
    """
    Run DoitMain instance with specified tasks and parameters.
    
    More advanced API for running specific tasks with custom configuration
    without command line parsing.
    
    Args:
        loader: Task loader instance
        tasks (dict): Dictionary of task names and their options
        extra_config (dict, optional): Extra configuration options
        
    Returns:
        int: Return code (0=success, 1=failure, 2=error, 3=user error)
        
    Raises:
        CmdParseError: Command parsing errors
        InvalidDodoFile: Invalid dodo file errors  
        InvalidCommand: Invalid command errors
        InvalidTask: Invalid task errors
    """

Variable Access

Access command line variables and working directory information from within task functions.

def get_var(name, default=None):
    """
    Get command line variable values passed to doit.
    
    Variables are set on command line as name=value pairs and can be
    accessed within task functions using this function.
    
    Args:
        name (str): Variable name to retrieve
        default: Default value if variable not found
        
    Returns:
        Variable value or default if not found, None if not initialized
    """
def get_initial_workdir():
    """
    Get working directory from where doit command was invoked.
    
    Returns the directory path from where the doit command was originally
    executed, before any directory changes during execution.
    
    Returns:
        str: Initial working directory path
    """

Package Version

__version__ = VERSION  # Package version tuple (0, 36, 0)

Usage Examples

Basic Task Execution

from doit import run

def task_hello():
    return {'actions': ['echo "Hello from API"']}

def task_build():
    return {
        'file_dep': ['src/main.py'],
        'targets': ['dist/app'],
        'actions': ['python setup.py build']
    }

# Run all tasks in current module
if __name__ == '__main__':
    run(globals())

Advanced Task Execution

from doit.api import run_tasks
from doit.cmd_base import ModuleTaskLoader

# Define tasks
tasks = {
    'build': {
        'actions': ['python setup.py build'],
        'file_dep': ['setup.py', 'src/main.py']
    }
}

# Create loader and run specific tasks
loader = ModuleTaskLoader(tasks)
result = run_tasks(loader, ['build'])
print(f"Build result: {result}")

Variable Usage

from doit import get_var

def task_deploy():
    """Deploy to environment specified by 'env' variable"""
    environment = get_var('env', 'development')
    return {
        'actions': [f'deploy.sh --env {environment}'],
        'verbosity': 2
    }

# Run with: doit deploy env=production

Install with Tessl CLI

npx tessl i tessl/pypi-doit

docs

actions.md

cli.md

core-api.md

exceptions.md

index.md

task-definition.md

tools.md

tile.json