-
Notifications
You must be signed in to change notification settings - Fork 133
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes installation with pre-compile approach on stan files
- Fix installation issue on various platforms fixes #845 #846 ; Now support up to Python 3.11 with macos, linux and windows - Updates cmdstanpy in setup.py and stan.py to fix issues plaguing installation on various platforms including windows, linux, and macos. - Update deployment method to sdist to ensure cmdstan requirements are properly installed. - Update cmdstan to install on default directory for simpler workflow Co-Authored-By: Edwin Ng <[email protected]> Co-Authored-By: szmark001 <[email protected]> Co-Authored-By: swotai <[email protected]>
- Loading branch information
1 parent
e007113
commit 875c7ca
Showing
21 changed files
with
374 additions
and
339 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,12 +24,25 @@ jobs: | |
pip install setuptools wheel twine | ||
pip install build | ||
pip install auditwheel | ||
- name: Build package | ||
run: | ||
# - name: Build package | ||
# run: | ||
# python -m build | ||
# - name: Convert linux wheel to manylinux wheels | ||
# run: | ||
# auditwheel repair --plat manylinux2014_x86_64 -w dist dist/*linux_x86_64.whl | ||
# - name: Remove platform specific linux wheels | ||
# run: | ||
# rm dist/*-linux_x86_64.whl | ||
# - name: Publish package | ||
# uses: pypa/[email protected] | ||
# with: | ||
# user: __token__ | ||
# password: ${{ secrets.PYPI_PASSWORD }} | ||
- name: Build and publish | ||
env: | ||
TWINE_USERNAME: __token__ | ||
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} | ||
run: | | ||
pip install . | ||
python -m build | ||
auditwheel repair dis/*linux_x86_64.whl | ||
- name: Publish package | ||
uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29 | ||
with: | ||
user: __token__ | ||
password: ${{ secrets.PYPI_PASSWORD }} | ||
python -m twine upload dist/*.tar.gz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import json | ||
import os | ||
import platform | ||
import shutil | ||
from multiprocessing import cpu_count | ||
|
||
import cmdstanpy | ||
|
||
with open("orbit/config.json") as f: | ||
config = json.load(f) | ||
CMDSTAN_VERSION = config["CMDSTAN_VERSION"] | ||
IS_WINDOWS = platform.platform().startswith("Win") | ||
|
||
|
||
def remove_older_cmdstan(cmdstan_version): | ||
""" | ||
Checks the default CmdStan path (~/.cmdstan) for folders with older versions | ||
and removes them. | ||
Args: | ||
cmdstan_version (str): The current CmdStan version. | ||
""" | ||
default_path = os.path.expanduser("~/.cmdstan") | ||
|
||
if not os.path.exists(default_path): | ||
# Path doesn't exist, nothing to remove | ||
return | ||
|
||
for folder in os.listdir(default_path): | ||
if folder.startswith("cmdstan-"): | ||
# Extract version number from folder name | ||
folder_version = folder.split("-")[1] | ||
if folder_version < cmdstan_version: | ||
# Remove folder if version is older | ||
full_path = os.path.join(default_path, folder) | ||
try: | ||
print(f"Removing older CmdStan version: {folder} : {full_path}") | ||
shutil.rmtree(full_path) | ||
print(f"Done.") | ||
except OSError as e: | ||
print(f"Error removing {folder}: {e}") | ||
|
||
|
||
def install_stan(): | ||
""" | ||
Compile and install stan backend | ||
Reference from prophet | ||
""" | ||
|
||
remove_older_cmdstan(CMDSTAN_VERSION) | ||
|
||
if not cmdstanpy.install_cmdstan( | ||
version=CMDSTAN_VERSION, | ||
overwrite=True, | ||
verbose=True, | ||
cores=cpu_count(), | ||
progress=True, | ||
compiler=IS_WINDOWS, | ||
): | ||
raise RuntimeError("CmdStan failed to install.") | ||
|
||
print(f"Installed cmdstanpy (cmdstan v.{CMDSTAN_VERSION}) and compiler.") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
__version__ = "1.1.4.3" | ||
__version__ = "1.1.4.4.dev14" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"CMDSTAN_VERSION": "2.34.1", | ||
"ORBIT_MODELS": [ | ||
[ | ||
"dlt", | ||
"ets", | ||
"ktrlite", | ||
"lgt" | ||
] | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -147,4 +147,4 @@ class CompiledStanModelPath: | |
""" | ||
|
||
PARENT = "orbit" | ||
CHILD = "stan_compiled" | ||
CHILD = "stan" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.