|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
| 4 | + |
| 5 | +## Essential Commands |
| 6 | + |
| 7 | +This project uses **Task** (not Make) for build automation. All commands are defined in `Taskfile.yaml`: |
| 8 | + |
| 9 | +- `task check` - Run all quality checks (lint, format, type-check, test) |
| 10 | +- `task lint` - Run ruff linting |
| 11 | +- `task format` - Auto-format code with ruff |
| 12 | +- `task type-check` - Run mypy type checking |
| 13 | +- `task test` - Run pytest unit tests |
| 14 | +- `task test:integration` - Run integration tests (requires CMEM instance) |
| 15 | +- `task build` - Build wheel package with poetry |
| 16 | +- `task install` - Install package in development mode |
| 17 | +- `task pre-commit` - Install pre-commit hooks |
| 18 | + |
| 19 | +## Architecture Overview |
| 20 | + |
| 21 | +### Core Components |
| 22 | + |
| 23 | +**cmem_plugin_loopwf/task.py** - Main plugin implementation: |
| 24 | +- `StartWorkflow` class extends `WorkflowPlugin` from cmem-plugin-base |
| 25 | +- Takes input entities and starts sub-workflow for each entity |
| 26 | +- `WorkflowExecution` dataclass manages individual workflow execution status |
| 27 | +- `WorkflowExecutionList` handles queue-based execution with configurable parallelism |
| 28 | +- Implements polling-based workflow status monitoring with async execution |
| 29 | +- Supports both entity metadata and file content processing |
| 30 | + |
| 31 | +**cmem_plugin_loopwf/workflow_type.py** - Workflow type definitions and utilities: |
| 32 | +- Custom parameter types for workflow selection |
| 33 | +- Dynamic value fetching and autocomplete integration |
| 34 | + |
| 35 | +**cmem_plugin_loopwf/exceptions.py** - Custom exception classes: |
| 36 | +- Plugin-specific error handling and exception types |
| 37 | + |
| 38 | +### Key Patterns |
| 39 | + |
| 40 | +- **Dataclass Configuration**: Uses `@dataclass` for parameter models with type hints |
| 41 | +- **Decorator-Based Registration**: Plugins use `@Plugin` decorator from cmem-plugin-base |
| 42 | +- **Autocomplete Integration**: Custom parameter types with dynamic value fetching |
| 43 | +- **Async Workflow Execution**: Non-blocking workflow starts with status polling |
| 44 | + |
| 45 | +### Project Structure |
| 46 | + |
| 47 | +``` |
| 48 | +cmem_plugin_loopwf/ |
| 49 | +├── task.py # Main plugin logic |
| 50 | +├── workflow_type.py # Workflow type definitions and utilities |
| 51 | +├── exceptions.py # Custom exception classes |
| 52 | +├── loopwf.svg # Plugin icon |
| 53 | +└── __init__.py # Plugin registration |
| 54 | +tests/ # Unit and integration tests |
| 55 | +├── conftest.py # Test configuration |
| 56 | +├── test_task.py # Task plugin tests |
| 57 | +├── test_discovery.py # Plugin discovery tests |
| 58 | +├── test_workflow_type.py # Workflow type tests |
| 59 | +├── test_workflow_execution_list.py # Execution list tests |
| 60 | +└── utils.py # Test utilities |
| 61 | +``` |
| 62 | + |
| 63 | +## Development Workflow |
| 64 | + |
| 65 | +### Dependencies |
| 66 | +- **Poetry** for package management (not pip/requirements.txt) |
| 67 | +- **Ruff** for linting and formatting (replaces black/isort/flake8) |
| 68 | +- **MyPy** for type checking |
| 69 | +- **Pre-commit** hooks for quality gates |
| 70 | + |
| 71 | +### Testing |
| 72 | +- Unit tests in `tests/` directory using pytest |
| 73 | +- Integration tests require running CMEM instance |
| 74 | +- Test configuration in `pyproject.toml` under `[tool.pytest.ini_options]` |
| 75 | + |
| 76 | +### Plugin Development |
| 77 | +- Extend `WorkflowPlugin` base class from cmem-plugin-base |
| 78 | +- Use type hints extensively - this is a strongly typed codebase |
| 79 | +- Follow the existing parameter model pattern with dataclasses |
| 80 | +- All plugins must be registered in `__init__.py` |
| 81 | + |
| 82 | +### CMEM Integration |
| 83 | +- Plugin outputs must be compatible with CMEM's RDF/entity model |
| 84 | +- Uses `cmempy` library for CMEM API interactions (config, get_json, execute_workflow_io, get_workflows_io) |
| 85 | +- Authentication handled through user context propagation via `setup_cmempy_user_access` |
| 86 | +- All operations are project-scoped within CMEM instance |
| 87 | +- Supports async workflow execution via `/api/workflow/executeAsync` endpoint |
| 88 | +- Entity conversion to JSON for workflow input via replaceable datasets |
| 89 | +- File processing support with configurable MIME types for file-to-workflow scenarios |
0 commit comments