Remove `pystan` backend, move to `cmdstanpy`
See original GitHub issueContext
Pystan 3+ makes some breaking changes to Prophet python package:
- MAP estimation is removed.
- Windows support is removed.
We’ve been continuing to use Pystan 2.19.1.1, but this is only supported up to Python 3.8 and no longer receives development. Many of our issues also relate to pystan issues, which will become harder to debug over time and may need hacky patches.
The current installation process with pystan is as follows:
Mac OS / Linux
- End users usually use prophet from PyPi.
- End user must install
pystan=2.19.1.1
first, as it is required for building the wheel - End user installs
prophet
, which includes compiling the pystan model on their machine.
Windows
- End users usually use prophet from
conda-forge
.
Proposal
- Use
cmdstan
+cmdstanpy
to build binary distributions for Pypi (using Github Actions) and conda-forge, across all platforms.- Packaging pre-compiled stan models per platform + python version means the end-user does not need to perform the build process on their machine. They won’t even need their own
cmdstan
installation since we will package the necessary executables into Prophet itself. - Only the lightweight wrapper library
cmdstanpy
is required as a dependency.
- Packaging pre-compiled stan models per platform + python version means the end-user does not need to perform the build process on their machine. They won’t even need their own
- Remove the dependency on
pystan
altogether.
This should not change how end-users typically interact with the Prophet package. The general flow of
m = Prophet()
m.fit(df)
future = m.make_future_dataframe()
m.predict(future)
will remain unchanged, and all other diagnostic functions will work as normal.
It’s just that behind the scenes, the model object will now be a cmdstanpy
object rather than a pystan
one. The argument stan_backend='PYSTAN'
will also be deprecated. This will affect end users who retrieve the actual pystan
object and work with it directly, but we expect this to be the minority.
We have already refactored the setup.py script to accomodate this new process (it currently supports both pystan 2.19.1.1
and cmdstanpy
for backwards compatibility).
We have also built and tested PyPi wheels for macOS and Linux for Python versions 3.6-3.8. If you follow the instructions here, you can test these binary distributions on your machine.
Work required
For the next minor release (prophet 1.1.0), we should consider the following:
- Update existing conda build scripts to use the
cmdstan
+cmdstanpy
backend. - Remove the
pystan
model compilation from the build process and removepystan
as a Prophet dependency. - (Optional) Add support for a Windows wheel on PyPi.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:9
- Comments:18 (11 by maintainers)
Top GitHub Comments
@tcuongd and @mitzimorris , FYI the 1.0 release of cmdstanpy is available on pypi
https://pypi.org/project/cmdstanpy/
related discussion: https://github.com/stan-dev/cmdstanpy/issues/475
In #2088 we discussed the next steps. Beyond just removing the PyStan references, there is also some refactoring work which can be done since the abstraction of a “backend” is not really needed any longer. I don’t think that would need to happen right away though, it’s probably fine to leave IStanBackend (and just only have one option for it) for the time being