"CLI-Anything: Making ALL Software Agent-Native" -- CLI-Hub: https://clianything.cc/
Python
docs: add required PR checklist files for unimol_tools
=309c921fef9c
diff --git a/registry.json b/registry.jsonindex 1ec3a3a1e..3ec2228b3 100644--- a/registry.json+++ b/registry.json@@ -844,6 +844,25 @@"url": "https://github.com/dorukozgen"}]+ },+ {+ "name": "unimol_tools",+ "display_name": "Uni-Mol Tools",+ "version": "1.0.0",+ "description": "Molecular property prediction — train and predict with 5 task types (classification, regression, multiclass, multilabel) for drug discovery",+ "requires": "PyTorch 1.12+, Uni-Mol Tools backend",+ "homepage": "https://github.com/dptech-corp/Uni-Mol/tree/main/unimol_tools",+ "source_url": null,+ "install_cmd": "pip install git+https://github.com/HKUDS/CLI-Anything.git#subdirectory=unimol_tools/agent-harness",+ "entry_point": "cli-anything-unimol-tools",+ "skill_md": "unimol_tools/agent-harness/cli_anything/unimol_tools/SKILL.md",+ "category": "science",+ "contributors": [+ {+ "name": "545487677",+ "url": "https://github.com/545487677"+ }+ ]}]}diff --git a/unimol_tools/agent-harness/UNIMOL_TOOLS.md b/unimol_tools/agent-harness/UNIMOL_TOOLS.mdnew file mode 100644index 000000000..283c14333--- /dev/null+++ b/unimol_tools/agent-harness/UNIMOL_TOOLS.md@@ -0,0 +1,181 @@+# Uni-Mol Tools CLI-Anything SOP++## Overview++Uni-Mol Tools is a molecular property prediction framework that provides easy-to-use interfaces for training and inference of molecular models. This CLI-Anything harness enables interactive molecular property prediction through conversational AI.++## Supported Task Types++1. **Binary Classification** - Classify molecules into two categories (e.g., active/inactive)+2. **Regression** - Predict continuous properties (e.g., binding affinity)+3. **Multiclass Classification** - Classify into multiple categories+4. **Multilabel Classification** - Assign multiple binary labels+5. **Multilabel Regression** - Predict multiple continuous values++## Standard Operating Procedures++### 1. Project Management++#### Create a New Project+```bash+python3 -m cli_anything.unimol_tools --json project create --name my_project+```++#### List All Projects+```bash+python3 -m cli_anything.unimol_tools --json project list+```++#### Switch Project+```bash+python3 -m cli_anything.unimol_tools --json project switch --name my_project+```++### 2. Training Models++#### Train a Binary Classification Model+```bash+python3 -m cli_anything.unimol_tools --json train \+ --data-path /path/to/train.csv \+ --target-col target \+ --task-type classification \+ --epochs 10 \+ --learning-rate 0.0001+```++#### Train a Regression Model+```bash+python3 -m cli_anything.unimol_tools --json train \+ --data-path /path/to/train.csv \+ --target-col score \+ --task-type regression \+ --epochs 10 \+ --learning-rate 0.0001+```++### 3. Model Management++#### List All Models+```bash+python3 -m cli_anything.unimol_tools --json models list+```++#### Show Model Details+```bash+python3 -m cli_anything.unimol_tools --json models show --model-id <id>+```++#### Rank Models by Performance+```bash+python3 -m cli_anything.unimol_tools --json models rank+```++### 4. Storage Management++#### Check Storage Usage+```bash+python3 -m cli_anything.unimol_tools --json storage analyze+```++#### Clean Up Poor Performers+```bash+python3 -m cli_anything.unimol_tools --json cleanup auto+```++### 5. Prediction++#### Make Predictions+```bash+python3 -m cli_anything.unimol_tools --json predict \+ --model-id <id> \+ --data-path /path/to/test.csv+```++## Data Format Requirements++### CSV File Structure+- Must contain a `SMILES` column with molecular structures+- Must contain target column(s) for training+- Example:++```csv+SMILES,target+CCO,1+CCCO,0+CC(C)O,1+```++### Task-Specific Formats++**Binary Classification**: Target values are 0/1 or True/False+**Regression**: Target values are floating-point numbers+**Multiclass**: Target values are integers (0, 1, 2, ...)+**Multilabel**: Multiple target columns with 0/1 values+**Multilabel Regression**: Multiple target columns with float values++## Session Management++The CLI maintains session state for:+- Current project+- Recently trained models+- Command history+- Storage statistics++### Interactive Mode+```bash+python3 -m cli_anything.unimol_tools+```++### One-Shot Mode+```bash+python3 -m cli_anything.unimol_tools --json <command> [options]+```++## Best Practices++1. **Create Projects for Different Experiments**: Keep models organized by research goals+2. **Monitor Storage**: Use `storage analyze` regularly to track disk usage+3. **Clean Up Old Models**: Use `cleanup auto` to remove underperforming models+4. **Check Model Rankings**: Use `models rank` to compare performance+5. **Use JSON Mode for Automation**: Add `--json` flag for programmatic access++## Troubleshooting++### Issue: Training fails with "CUDA out of memory"+**Solution**: Reduce batch size or use CPU mode++### Issue: CSV file not recognized+**Solution**: Ensure SMILES column exists and is properly formatted++### Issue: Model not found+**Solution**: Run `models list` to verify model ID++### Issue: Storage full+**Solution**: Run `cleanup auto` or manually delete old models with `models delete`++## Performance Optimization++- **Batch Size**: Default is 32, reduce if memory issues occur+- **Epochs**: Start with 10, increase if underfitting+- **Learning Rate**: Default is 0.0001, adjust based on loss curves+- **Data Split**: Default train/val split is 80/20++## Testing++Run the test suite to verify functionality:++```bash+# Unit tests (no backend required)+cd unimol_tools/agent-harness/docs/test+bash run_tests.sh --unit -v++# Full test suite+bash run_tests.sh --full -v+```++## Additional Resources++- **Quick Start Guide**: [docs/guides/02-QUICK-START.md](docs/guides/02-QUICK-START.md)+- **API Reference**: [docs/architecture/API.md](docs/architecture/API.md)+- **Test Data**: https://github.com/545487677/CLI-Anything-unimol-tools/tree/main/unimol_tools/examples+- **Uni-Mol Paper**: https://arxiv.org/abs/2209.11126diff --git a/unimol_tools/agent-harness/cli_anything/unimol_tools/SKILL.md b/unimol_tools/agent-harness/cli_anything/unimol_tools/SKILL.mdnew file mode 100644index 000000000..a5ff7a71e--- /dev/null+++ b/unimol_tools/agent-harness/cli_anything/unimol_tools/SKILL.md@@ -0,0 +1,176 @@+# Uni-Mol Tools - Molecular Property Prediction CLI++**Package**: `cli-anything-unimol-tools`+**Command**: `python3 -m cli_anything.unimol_tools`++## Description++Interactive CLI for training and inference of molecular property prediction models using Uni-Mol Tools. Supports 5 task types: binary classification, regression, multiclass, multilabel classification, and multilabel regression.++## Key Features++- **Project Management**: Organize experiments with named projects+- **5 Task Types**: Classification, regression, multiclass, multilabel variants+- **Model Tracking**: Automatic performance history and rankings+- **Smart Storage**: Analyze usage and clean up underperformers+- **JSON API**: Full automation support with `--json` flag++## Common Commands++### Project Management+```bash+# Create a new project+project create --name drug_discovery++# List all projects+project list++# Switch to a project+project switch --name drug_discovery+```++### Training+```bash+# Train a classification model+train --data-path train.csv --target-col active --task-type classification --epochs 10++# Train a regression model+train --data-path train.csv --target-col affinity --task-type regression --epochs 10+```++### Model Management+```bash+# List all trained models+models list++# Show model details and performance+models show --model-id <id>++# Rank models by performance+models rank+```++### Storage & Cleanup+```bash+# Analyze storage usage+storage analyze++# Automatic cleanup of poor performers+cleanup auto++# Manual cleanup with criteria+cleanup manual --max-models 10 --min-score 0.7+```++### Prediction+```bash+# Make predictions with a trained model+predict --model-id <id> --data-path test.csv+```++## Data Format++CSV files must contain:+- `SMILES` column: Molecular structures in SMILES format+- Target column(s): Values to predict (name specified via `--target-col`)++Example:+```csv+SMILES,target+CCO,1+CCCO,0+CC(C)O,1+```++## Task Types++1. **classification**: Binary classification (0/1)+2. **regression**: Continuous value prediction+3. **multiclass**: Multiple class classification+4. **multilabel_classification**: Multiple binary labels+5. **multilabel_regression**: Multiple continuous values++## JSON Mode++Add `--json` flag to any command for machine-readable output:+```bash+python3 -m cli_anything.unimol_tools --json models list+```++Output format:+```json+{+ "status": "success",+ "data": [...],+ "message": "..."+}+```++## Interactive Mode++Launch without commands for interactive REPL:+```bash+python3 -m cli_anything.unimol_tools+```++Features:+- Tab completion+- Command history+- Contextual help+- Project state persistence++## Test Data++Example datasets available at:+https://github.com/545487677/CLI-Anything-unimol-tools/tree/main/unimol_tools/examples++Includes data for all 5 task types.++## Requirements++- Python 3.8++- PyTorch 1.12++- Uni-Mol Tools backend+- 4GB+ RAM (8GB+ recommended for training)++## Installation++```bash+cd unimol_tools/agent-harness+pip install -e .+```++## Documentation++- **SOP**: [UNIMOL_TOOLS.md](../UNIMOL_TOOLS.md)+- **Quick Start**: [docs/guides/02-QUICK-START.md](../docs/guides/02-QUICK-START.md)+- **Full Documentation**: [docs/README.md](../docs/README.md)++## Testing++```bash+cd docs/test+bash run_tests.sh --unit -v # Unit tests (67 tests)+bash run_tests.sh --full -v # Full test suite+```++## Performance Tips++- Start with 10 epochs for initial experiments+- Use smaller batch sizes if memory is limited+- Monitor storage with `storage analyze`+- Use `models rank` to identify best performers+- Clean up regularly with `cleanup auto`++## Troubleshooting++- **CUDA errors**: Reduce batch size or use CPU mode+- **CSV not recognized**: Verify SMILES column exists+- **Low accuracy**: Try more epochs or adjust learning rate+- **Storage full**: Run `cleanup auto` to free space++## Related++- **Uni-Mol Tools**: https://github.com/dptech-corp/Uni-Mol/tree/main/unimol_tools+- **Uni-Mol Paper**: https://arxiv.org/abs/2209.11126+- **CLI-Anything**: https://github.com/HKUDS/CLI-Anythingdiff --git a/unimol_tools/agent-harness/cli_anything/unimol_tools/tests/test_full_e2e.py b/unimol_tools/agent-harness/cli_anything/unimol_tools/tests/test_full_e2e.pynew file mode 100644index 000000000..345f43b94--- /dev/null+++ b/unimol_tools/agent-harness/cli_anything/unimol_tools/tests/test_full_e2e.py@@ -0,0 +1,245 @@+"""+End-to-End tests for Uni-Mol Tools CLI+Requires the full Uni-Mol Tools backend to be installed.+"""+import subprocess+import json+import pytest+import tempfile+import os+from pathlib import Path+++def run_cli_command(args, json_output=True):+ """Run CLI command and return result."""+ cmd = ["python3", "-m", "cli_anything.unimol_tools"]+ if json_output:+ cmd.append("--json")+ cmd.extend(args)++ result = subprocess.run(+ cmd,+ capture_output=True,+ text=True,+ timeout=60+ )++ if json_output:+ return json.loads(result.stdout)+ return result.stdout+++def temp_csv_file():+ """Create a temporary CSV file with sample data."""+ content = """SMILES,target+CCO,1+CCCO,0+CC(C)O,1+CCCCO,0+CC(C)CO,1+"""+ with tempfile.NamedTemporaryFile(mode='w', suffix='.csv', delete=False) as f:+ f.write(content)+ temp_path = f.name++ yield temp_path++ if os.path.exists(temp_path):+ os.unlink(temp_path)+++def test_project():+ """Create a test project and clean up after."""+ project_name = "test_e2e_project"++ # Create project+ result = run_cli_command(["project", "create", "--name", project_name])+ assert result["status"] == "success"++ yield project_name++ # Cleanup: Delete project (if implemented)+ try:+ run_cli_command(["project", "delete", "--name", project_name])+ except:+ pass+++class TestProjectManagement:+ """Test project management commands."""++ def test_create_project(self):+ """Test creating a new project."""+ result = run_cli_command(["project", "create", "--name", "test_create"])+ assert result["status"] == "success"+ assert "created" in result["message"].lower()++ def test_list_projects(self):+ """Test listing all projects."""+ result = run_cli_command(["project", "list"])+ assert result["status"] == "success"+ assert isinstance(result["data"], list)++ def test_switch_project(self, test_project):+ """Test switching to a project."""+ result = run_cli_command(["project", "switch", "--name", test_project])+ assert result["status"] == "success"+++class TestModelTraining:+ """Test model training functionality."""++ @pytest.mark.slow+ def test_train_classification(self, test_project, temp_csv_file):+ """Test training a classification model."""+ result = run_cli_command([+ "train",+ "--data-path", temp_csv_file,+ "--target-col", "target",+ "--task-type", "classification",+ "--epochs", "2", # Small for testing+ "--learning-rate", "0.0001"+ ])++ assert result["status"] == "success"+ assert "model_id" in result["data"]+ assert "performance" in result["data"]++ @pytest.mark.slow+ def test_train_regression(self, test_project, temp_csv_file):+ """Test training a regression model."""+ result = run_cli_command([+ "train",+ "--data-path", temp_csv_file,+ "--target-col", "target",+ "--task-type", "regression",+ "--epochs", "2",+ "--learning-rate", "0.0001"+ ])++ assert result["status"] == "success"+ assert "model_id" in result["data"]+++class TestModelManagement:+ """Test model management commands."""++ def test_list_models(self, test_project):+ """Test listing all models."""+ result = run_cli_command(["models", "list"])+ assert result["status"] == "success"+ assert isinstance(result["data"], list)++ def test_rank_models(self, test_project):+ """Test ranking models by performance."""+ result = run_cli_command(["models", "rank"])+ assert result["status"] == "success"+ assert isinstance(result["data"], list)+++class TestStorageManagement:+ """Test storage management commands."""++ def test_storage_analyze(self, test_project):+ """Test storage analysis."""+ result = run_cli_command(["storage", "analyze"])+ assert result["status"] == "success"+ assert "total_size" in result["data"]+ assert "model_count" in result["data"]+++class TestPrediction:+ """Test prediction functionality."""++ @pytest.mark.slow+ def test_predict(self, test_project, temp_csv_file):+ """Test making predictions with a trained model."""+ # First train a model+ train_result = run_cli_command([+ "train",+ "--data-path", temp_csv_file,+ "--target-col", "target",+ "--task-type", "classification",+ "--epochs", "2"+ ])++ assert train_result["status"] == "success"+ model_id = train_result["data"]["model_id"]++ # Now make predictions+ pred_result = run_cli_command([+ "predict",+ "--model-id", model_id,+ "--data-path", temp_csv_file+ ])++ assert pred_result["status"] == "success"+ assert "predictions" in pred_result["data"]+ assert len(pred_result["data"]["predictions"]) > 0+++class TestCleanup:+ """Test cleanup functionality."""++ def test_cleanup_auto(self, test_project):+ """Test automatic cleanup."""+ result = run_cli_command(["cleanup", "auto"])+ assert result["status"] == "success"+ assert "deleted_count" in result["data"]+++class TestJSONMode:+ """Test JSON output mode for all commands."""++ def test_json_project_list(self):+ """Test JSON output for project list."""+ result = run_cli_command(["project", "list"], json_output=True)+ assert "status" in result+ assert "data" in result+ assert result["status"] in ["success", "error"]++ def test_json_models_list(self):+ """Test JSON output for models list."""+ result = run_cli_command(["models", "list"], json_output=True)+ assert "status" in result+ assert "data" in result+++class TestErrorHandling:+ """Test error handling and validation."""++ def test_invalid_task_type(self, temp_csv_file):+ """Test error handling for invalid task type."""+ result = run_cli_command([+ "train",+ "--data-path", temp_csv_file,+ "--target-col", "target",+ "--task-type", "invalid_type",+ "--epochs", "2"+ ])+ assert result["status"] == "error"++ def test_missing_data_file(self):+ """Test error handling for missing data file."""+ result = run_cli_command([+ "train",+ "--data-path", "/nonexistent/file.csv",+ "--target-col", "target",+ "--task-type", "classification",+ "--epochs", "2"+ ])+ assert result["status"] == "error"++ def test_invalid_model_id(self):+ """Test error handling for invalid model ID."""+ result = run_cli_command([+ "models", "show",+ "--model-id", "nonexistent_id"+ ])+ assert result["status"] == "error"+++if __name__ == "__main__":+ pytest.main([__file__, "-v", "-m", "not slow"])