Skip to content

Commit

Permalink
Remove PyMC adapter
Browse files Browse the repository at this point in the history
It's now supported by PyMC directly, since v5.1.1.

Closes #11 because adapters should no longer be located here.
  • Loading branch information
michaelosthege committed Mar 30, 2023
1 parent 114f38d commit 5dca137
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 429 deletions.
17 changes: 7 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ isinstance(backend, mcbackend.Backend)
```

### Part 3: PPL adapters
Anything that is a `Backend` can be wrapped by an [adapter ](https://en.wikipedia.org/wiki/Adapter_pattern) that makes it compatible with your favorite PPL.
Anything that is a `Backend` can be wrapped by an [adapter](https://en.wikipedia.org/wiki/Adapter_pattern) that makes it compatible with your favorite PPL.

In the example below, a `ClickHouseBackend` is initialized to store MCMC draws from a PyMC model in a [ClickHouse](http://clickhouse.com/) database.
See below for [how to run it in Docker](#development).
Expand All @@ -56,17 +56,15 @@ ch_client = clickhouse_driver.Client("localhost")
backend = mcbackend.ClickHouseBackend(ch_client)

with pm.Model():
# 3. Create your model
# 2. Create your model
...
# 4. Wrap the PyMC adapter around an `mcbackend.Backend`
# This generates and prints a short `trace.run_id` by which
# this MCMC run is identified in the (database) backend.
trace = mcbackend.pymc.TraceBackend(backend)

# 5. Hit the inference button ™
pm.sample(trace=trace)
# 3. Hit the inference button ™ while passing the backend!
pm.sample(trace=backend)
```

In case of PyMC the adapter lives in the PyMC codebase [since version 5.1.1](https://github.com/pymc-devs/pymc/releases/tag/v5.1.1),
so all you need to do is pass any `mcbackend.Backend` via the `pm.sample(trace=...)` parameter!

Instead of using PyMC's built-in NumPy backend, the MCMC draws now end up in ClickHouse.

### Retrieving the `draws` & `stats`
Expand Down Expand Up @@ -103,7 +101,6 @@ For example:
* Schema discussion: Which metadata is needed? (related: [PyMC #5160](https://github.com/pymc-devs/pymc/issues/5160))
* Interface discussion: How should `Backend`/`Run`/`Chain` evolve?
* Python Backends for disk storage (HDF5, `*.proto`, ...)
* An `emcee` adapter (#11).
* C++ `Backend`/`Run`/`Chain` interfaces
* C++ ClickHouse backend (via [`clickhouse-cpp`](https://github.com/ClickHouse/clickhouse-cpp))

Expand Down
2 changes: 1 addition & 1 deletion mcbackend/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@
except ModuleNotFoundError:
pass

__version__ = "0.4.0"
__version__ = "0.5.0"
Empty file removed mcbackend/adapters/__init__.py
Empty file.
260 changes: 0 additions & 260 deletions mcbackend/adapters/pymc.py

This file was deleted.

Loading

0 comments on commit 5dca137

Please sign in to comment.