Skip to content

Commit 2266213

Browse files
author
linkmluser
committed
initial commit
0 parents  commit 2266213

40 files changed

+26009
-0
lines changed

.coverage

52 KB
Binary file not shown.

.github/codespell-ignore.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
ehr
2+
assertIn
3+
nin

.github/workflows/codespell.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: Codespell
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
codespell:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
- uses: codespell-project/actions-codespell@v2
15+
with:
16+
check_filenames: true
17+
check_hidden: true
18+
skip: ".git,*.pdf,*.svg,*.lock,uv.lock"
19+
ignore_words_file: .github/codespell-ignore.txt
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Deploy Documentation
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
workflow_dispatch:
8+
9+
permissions:
10+
contents: read
11+
pages: write
12+
id-token: write
13+
14+
concurrency:
15+
group: "pages"
16+
cancel-in-progress: true
17+
18+
jobs:
19+
# Build job
20+
build:
21+
runs-on: ubuntu-latest
22+
steps:
23+
- name: Checkout
24+
uses: actions/checkout@v4
25+
26+
- name: Install uv
27+
uses: astral-sh/setup-uv@v5
28+
29+
- name: Setup Python
30+
uses: actions/setup-python@v5
31+
with:
32+
python-version: '3.12'
33+
34+
- name: Install dependencies
35+
run: uv sync --all-extras
36+
37+
- name: Build with MkDocs
38+
run: uv run mkdocs build
39+
40+
- name: Upload artifact
41+
uses: actions/upload-pages-artifact@v3
42+
with:
43+
path: ./site
44+
45+
# Deployment job
46+
deploy:
47+
environment:
48+
name: github-pages
49+
url: ${{ steps.deployment.outputs.page_url }}
50+
runs-on: ubuntu-latest
51+
needs: build
52+
steps:
53+
- name: Deploy to GitHub Pages
54+
id: deployment
55+
uses: actions/deploy-pages@v4

.github/workflows/main.yaml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: Build and test
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
7+
pull_request:
8+
types:
9+
- opened
10+
- reopened
11+
- synchronize
12+
- ready_for_review
13+
14+
jobs:
15+
lint:
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: actions/checkout@v4
19+
20+
- name: Set up Python
21+
uses: actions/setup-python@v5
22+
with:
23+
python-version: '3.12'
24+
25+
- name: Install uv
26+
uses: astral-sh/setup-uv@v5
27+
28+
- name: Install dependencies
29+
run: uv sync --all-extras
30+
31+
- name: Check code quality with ruff
32+
run: uv run ruff check .
33+
34+
- name: Check formatting with ruff
35+
run: uv run ruff format --check .
36+
37+
test:
38+
runs-on: ubuntu-latest
39+
strategy:
40+
matrix:
41+
python-version: [ '3.10', '3.11', '3.12', '3.13' ]
42+
43+
steps:
44+
- uses: actions/checkout@v4
45+
46+
- name: Install uv
47+
uses: astral-sh/setup-uv@v5
48+
49+
- uses: actions/setup-python@v5
50+
with:
51+
python-version: ${{ matrix.python-version }}
52+
53+
- name: Install dependencies
54+
run: uv sync --all-extras
55+
56+
- name: Run test suite
57+
run: uv run pytest
58+
59+
- name: Upload coverage to Codecov
60+
uses: codecov/codecov-action@v4
61+
with:
62+
token: ${{ secrets.CODECOV_TOKEN }}
63+
file: ./coverage.xml
64+
fail_ci_if_error: false
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Publish Python Package
2+
3+
on:
4+
workflow_dispatch:
5+
release:
6+
types: [created]
7+
8+
jobs:
9+
build-n-publish:
10+
name: Build and publish Python 🐍 distributions 📦 to PyPI
11+
runs-on: ubuntu-latest
12+
environment: release
13+
permissions:
14+
id-token: write
15+
steps:
16+
- uses: actions/checkout@v4
17+
18+
- name: Install uv
19+
uses: astral-sh/setup-uv@v5
20+
21+
- name: Set up Python
22+
uses: actions/setup-python@v5
23+
with:
24+
python-version: '3.12'
25+
26+
- name: Install dependencies
27+
run: uv sync --all-extras
28+
29+
- name: Build source and wheel archives
30+
run: uv build
31+
32+
- name: Publish
33+
uses: pypa/gh-action-pypi-publish@release/v1
34+
with:
35+
verbose: true

.gitignore

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
tests/output
2+
3+
.coverage
4+
coverage.xml
5+
tests/.coverage
6+
tests/coverage.xml
7+
8+
# Python
9+
__pycache__/
10+
*.py[cod]
11+
*$py.class
12+
*.so
13+
.Python
14+
build/
15+
develop-eggs/
16+
dist/
17+
downloads/
18+
eggs/
19+
.eggs/
20+
lib/
21+
lib64/
22+
parts/
23+
sdist/
24+
var/
25+
wheels/
26+
*.egg-info/
27+
.installed.cfg
28+
*.egg
29+
30+
# Virtual Environment
31+
venv/
32+
env/
33+
ENV/
34+
35+
# IDE
36+
.idea/
37+
.vscode/
38+
*.swp
39+
*.swo
40+
41+
# Logs
42+
*.log
43+
logs/
44+
45+
# Local development
46+
.env
47+
.env.local
48+
49+
**/.claude/settings.local.json

.python-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.10

CLAUDE.md

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4+
5+
## Project Overview
6+
7+
OWL-Server is a Python server for managing OWL (Web Ontology Language) ontologies. It provides a simplified API for common operations like adding/removing axioms, finding axioms by pattern, and managing prefix mappings.
8+
9+
The project uses:
10+
- py-horned-owl for OWL ontology manipulation
11+
- watchdog for file monitoring
12+
- click for command-line interface
13+
- FastMCP for Model-Context-Protocol integration
14+
15+
## Architecture
16+
17+
The codebase is organized into these main components:
18+
19+
1. **SimpleOwlAPI** (`owl_api.py`): Core class that provides thread-safe ontology management:
20+
- Handles file synchronization with disk
21+
- Provides observer pattern for change notifications
22+
- Manages prefix mappings
23+
- Supports adding/removing/finding axioms
24+
- Respects readonly settings from configuration
25+
26+
2. **Axiom Parser** (`axiom_parser.py`): Handles conversion between string representations of OWL axioms and py-horned-owl objects.
27+
28+
3. **Server CLI** (`server.py`): Command-line interface for starting the server and initializing ontology files.
29+
30+
4. **MCP Tools** (`mcp_tools.py`): ModelContextProtocol wrapper around the core API:
31+
- Provides MCP tools for OWL operations
32+
- Handles API instance caching and management
33+
- Exposes file-path based interfaces for OWL manipulation
34+
- Includes configuration management tools
35+
36+
5. **Configuration System** (`config.py`): Manages session-wide configuration:
37+
- Stores ontology paths, metadata, and settings in `~/.owl-mcp/config.yaml`
38+
- Provides named access to frequently used ontologies
39+
- Supports readonly ontologies and metadata axioms
40+
- Offers session-wide settings like default serialization format
41+
42+
## Common Commands
43+
44+
### Installation
45+
46+
```bash
47+
# Install dependencies and set up development environment
48+
make install
49+
```
50+
51+
### Running Tests
52+
53+
```bash
54+
# Run all tests
55+
make test
56+
57+
# Run a specific test
58+
uv run pytest tests/test_owl_api.py::test_add_axiom
59+
60+
# Run tests with verbose output
61+
uv run pytest -v
62+
63+
# Run only MCP tool tests
64+
uv run pytest tests/test_mcp_tools.py
65+
```
66+
67+
### Development Workflow
68+
69+
```bash
70+
# Clean up build artifacts
71+
make clean
72+
73+
# Run example script
74+
make example
75+
```
76+
77+
### Code Quality
78+
79+
```bash
80+
# Format code with black
81+
uv run black src tests
82+
83+
# Sort imports
84+
uv run isort src tests
85+
86+
# Type checking with mypy
87+
uv run mypy src
88+
```
89+
90+
### Running the MCP Server
91+
92+
```bash
93+
# Run the MCP server with stdio transport
94+
python -m owl_server.mcp_tools
95+
```
96+
97+
## Known Issues
98+
99+
The project has compatibility issues with py-horned-owl API as documented in KNOWN_ISSUES.md:
100+
101+
1. Methods like `add_default_prefix_names()` and `clazz()` are referenced in the code but may not be available in the installed version of py-horned-owl.
102+
2. Adaptations may be needed for axiom types (SubClassOf, etc.).

0 commit comments

Comments
 (0)