question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Remove `pystan` backend, move to `cmdstanpy`

See original GitHub issue

Context

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.
  • 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 remove pystan as a Prophet dependency.
  • (Optional) Add support for a Windows wheel on PyPi.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:9
  • Comments:18 (11 by maintainers)

github_iconTop GitHub Comments

3reactions
akosfurtoncommented, Dec 3, 2021

@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

1reaction
WardBriancommented, Apr 5, 2022

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

Getting Started — CmdStanPy 0.9.64 documentation
If you already have PyStan installed, you should take care to install CmdStanPy in its own virtual environment. User can install optional packages...
Read more >
CmdStanPy; compiling in parallel on Dask - The Stan Forums
We've set up a workflow to run Stan, with Prefect and Dask and are experiencing a lot of flakyness from the running of...
Read more >
prophet-nogpl · PyPI
PyStan has its own installation instructions. Install pystan with pip before using pip to install prophet. Experimental backend - cmdstanpy. You ...
Read more >
Prophet: Automatic Forecasting Procedure - Morioh
It is also possible to install Prophet with two backends: # bash $ CMDSTAN=/tmp/cmdstan-2.22.1 STAN_BACKEND=PYSTAN,CMDSTANPY pip install prophet.
Read more >
Facebook Prophet Error - Page 2 - Alteryx Community
DEBUG:fbprophet:Unable to load backend CMDSTANPY (no such file ... In my case pystan path was not correct due to some past (wrong) attempts ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found