Skip to content

Commit 09d1b7e

Browse files
kutay-ogpuclaude
andcommitted
docs: rewrite mkdocs site for v0.2.1 and expand source docstrings
Replace the stale v0.2.0 docs tree (api/, advanced/, responses/, sources/, tasks/) with a new structure: getting-started, guides, reference, about. The reference pages are generated by mkdocstrings against the new v0.2.1 module layout (ogpu.client, ogpu.chain, ogpu.protocol, ogpu.types, ogpu.events, ogpu.agent, ogpu.ipfs, ogpu.service). Add Google-style docstrings (Args / Returns / Raises / Example) to every public class and method across the SDK so mkdocstrings has rich content to render. Examples use fenced ```python blocks instead of doctest-style prompts so they pick up syntax highlighting in the rendered docs. Each reference page also gets an intro prose section explaining the module's role, signer handling, and how it fits into the rest of the SDK. `mkdocs build --strict` is clean. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 9c811e8 commit 09d1b7e

69 files changed

Lines changed: 7655 additions & 4873 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

docs/about/changelog.md

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# Changelog
2+
3+
The canonical changelog lives in the repo root at
4+
[`CHANGELOG.md`](https://github.com/OpenGPU-Network/sdk-ogpu-py/blob/main/CHANGELOG.md).
5+
The current release is **v0.2.1**.
6+
7+
## v0.2.1 — highlights
8+
9+
### New features
10+
11+
- **`ogpu.chain`** — new top-level home for `ChainConfig`, `ChainId`,
12+
`Web3Manager`, `NonceManager`, ABI files, and RPC URL config.
13+
Role-agnostic, used by every SDK module. `from ogpu import ChainConfig`
14+
ergonomically re-exports the public surface.
15+
- **`ogpu.ipfs`** — public module (previously `_ipfs`) with
16+
`publish_to_ipfs` and `fetch_ipfs_json`, top-level re-exported:
17+
`from ogpu import publish_to_ipfs, fetch_ipfs_json`.
18+
- **Instance classes**`Source`, `Task`, `Response`, `Provider`,
19+
`Master` as live stateless proxies bound to contract addresses. Full
20+
read + write methods and `snapshot()` batch capture.
21+
- **Vault module** (`ogpu.protocol.vault`) — deposit, withdraw, lock,
22+
unbond, cancel_unbonding, claim, plus 9 reads and 2 constants.
23+
Previously 0% covered from Python.
24+
- **Event subscription** (`ogpu.events`) — 6 async generators for
25+
critical Nexus events. The one async island — rest of SDK stays sync.
26+
- **Agent package** (`ogpu.agent`) — scheduler wrappers for agent-role
27+
operations (`register_to`, `unregister_from`, `attempt`). Uses
28+
`AGENT_PRIVATE_KEY` env var fallback.
29+
- **Exception hierarchy** — 22 concrete exception classes under
30+
`OGPUError` base, grouped by domain (NotFound, State, Permission,
31+
Vault, Tx, Config, IPFS).
32+
- **`TxExecutor`** — unified transaction sender with nonce retry,
33+
underpriced backoff, and typed revert decoding. Replaces ~300 lines
34+
of duplicated retry logic.
35+
- **`Receipt` dataclass** — unified return type for all write operations.
36+
- **`ChainConfig.set_rpc / get_rpc / reset_rpc`** — custom RPC endpoint support.
37+
- **Type-safe status enums**`TaskStatus`, `SourceStatus`,
38+
`ResponseStatus`, `Environment`, `DeliveryMethod`.
39+
- **`Response.fetch_data()`** — follows the URL returned by
40+
`response.get_data()` and parses the JSON body.
41+
- **Pagination helper** — transparent internal chunking for all
42+
list-returning methods.
43+
44+
### Breaking changes
45+
46+
- **`publish_source()` now returns `Source`** (was `str`). Use `.address`
47+
for the raw address.
48+
- **`publish_task()` now returns `Task`** (was `str`).
49+
- **Default chain flipped to `OGPU_MAINNET`** (was `OGPU_TESTNET`).
50+
Testnet users must prepend
51+
`ChainConfig.set_chain(ChainId.OGPU_TESTNET)`.
52+
- **`get_confirmed_response()` standalone function deleted.** Use
53+
`Task(addr).get_confirmed_response()` instead (chain-only, no HTTP).
54+
- **`get_task_responses()` returns `list[Response]` instances** (was
55+
list of old dataclass).
56+
- **`ogpu.agent` module previously existed for `set_agent` — that has
57+
been replaced.** `set_agent` is now at `ogpu.protocol.terminal.set_agent`
58+
or `ogpu.client.set_agent`; `ogpu.agent` is now the scheduler-role
59+
high-level package.
60+
- **`ImageMetadata` renamed to `SourceMetadata`.**
61+
- **Old `Response` and `ConfirmedResponse` dataclasses deleted.**
62+
Replaced by `Response` instance class.
63+
- **`requires-python` bumped to `>=3.10`.**
64+
- **No HTTP dependency for contract reads.** The management-backend
65+
HTTP call in the old `get_confirmed_response` is removed entirely.
66+
- **Chain infrastructure moved out of `ogpu.client`** (clean break):
67+
- `from ogpu.client import ChainConfig``from ogpu import ChainConfig`
68+
- `from ogpu.client.chain_config import ChainId``from ogpu.chain.config import ChainId`
69+
- `from ogpu.client import fix_nonce``from ogpu import fix_nonce`
70+
- ABI files moved from `ogpu/client/abis/` to `ogpu/chain/abis/`
71+
- **`SourceInfo.to_source_params` / `TaskInfo.to_task_params` deleted.**
72+
These type-methods triggered hidden IPFS uploads. The work is now in
73+
private helpers in `ogpu.client` — user-facing API is unchanged, but
74+
`SourceInfo` and `TaskInfo` are now pure dataclasses.
75+
76+
See the [full changelog](https://github.com/OpenGPU-Network/sdk-ogpu-py/blob/main/CHANGELOG.md) for every entry.

docs/about/contributing.md

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
# Contributing
2+
3+
The SDK is open source under the MIT license. Contributions welcome.
4+
5+
## Development setup
6+
7+
```bash
8+
git clone https://github.com/OpenGPU-Network/sdk-ogpu-py.git
9+
cd sdk-ogpu-py
10+
pip install -e ".[dev]"
11+
```
12+
13+
This pulls in `pytest`, `pytest-asyncio`, `pytest-cov`, `mypy`, `ruff`,
14+
and `nbformat`.
15+
16+
## Running the test suite
17+
18+
```bash
19+
pytest tests/ # full suite (all mocked, no chain)
20+
pytest tests/unit/test_vault.py # one module
21+
pytest tests/ -k "vault" # by keyword
22+
```
23+
24+
Every test in `tests/unit/` is mock-based — nothing hits a real chain.
25+
The suite runs in under 2 seconds.
26+
27+
## Type checking and lint
28+
29+
```bash
30+
mypy ogpu/ # strict mode, configured in pyproject.toml
31+
ruff check ogpu/ # lint
32+
ruff format ogpu/ # format
33+
```
34+
35+
Run all three before opening a PR.
36+
37+
## Layer discipline
38+
39+
The SDK is organized by layer:
40+
41+
```
42+
types chain ipfs ← leaves, no outward dependencies
43+
44+
protocol ← 1:1 contract wrappers
45+
46+
client / agent / events ← role-first workflows
47+
```
48+
49+
New code must respect this direction:
50+
51+
- Nothing under `ogpu/types/` may import from higher layers
52+
- `ogpu/protocol/` may import from `types`, `chain`, `ipfs` but not `client`
53+
- `ogpu/client/`, `ogpu/agent/`, `ogpu/events/` sit at the top
54+
55+
If you find yourself wanting to import a higher layer from a lower one,
56+
the code probably belongs in the higher layer.
57+
58+
## Adding a new method on an instance class
59+
60+
Example: adding `Task.get_something_new()`.
61+
62+
1. Check the `TaskAbi.json` to find the underlying function name
63+
2. Add the method to `ogpu/protocol/task.py`:
64+
```python
65+
def get_something_new(self) -> int:
66+
return int(self._contract().functions.somethingNew().call())
67+
```
68+
3. Add a unit test in `tests/unit/test_instance_task.py`:
69+
```python
70+
def test_get_something_new(self):
71+
c = _mc(somethingNew=42)
72+
t, p = self._t(c)
73+
with p:
74+
assert t.get_something_new() == 42
75+
```
76+
4. If it's a write method, update `REVERT_PATTERN_MAP` in `_base.py`
77+
with any new revert strings.
78+
5. Run `pytest`, `mypy`, `ruff`.
79+
80+
## Documentation
81+
82+
Docs live in `docs/` and build with mkdocs-material:
83+
84+
```bash
85+
pip install -r docs-requirements.txt
86+
mkdocs serve # local preview at http://localhost:8000
87+
mkdocs build --strict # CI-equivalent build
88+
```
89+
90+
API reference pages use `mkdocstrings` to pull docstrings from source.
91+
Adding a new method with a Google-style docstring is enough — it will
92+
appear in the reference automatically.
93+
94+
## Commit conventions
95+
96+
The repo uses conventional commits (`feat:`, `fix:`, `docs:`, `chore:`,
97+
`refactor:`, `test:`).
98+
99+
## Reporting issues
100+
101+
File issues at
102+
[github.com/OpenGPU-Network/sdk-ogpu-py/issues](https://github.com/OpenGPU-Network/sdk-ogpu-py/issues).
103+
104+
Please include:
105+
106+
- Python version
107+
- SDK version (`python -c "import ogpu; print(ogpu.__file__)"`)
108+
- Minimal reproduction code
109+
- Expected vs actual behavior
110+
- Full traceback if it's a crash
111+
112+
## License
113+
114+
MIT. See [LICENSE](https://github.com/OpenGPU-Network/sdk-ogpu-py/blob/main/LICENSE).

docs/advanced/index.md

Lines changed: 0 additions & 45 deletions
This file was deleted.

0 commit comments

Comments
 (0)