Skip to content

Commit

Permalink
Merge pull request #866 from uber/conda-fix
Browse files Browse the repository at this point in the history
Conda exception in setup.py, bump version number
  • Loading branch information
edwinnglabs committed Mar 29, 2024
2 parents e210705 + f5e4e94 commit da50bfe
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 50 deletions.
2 changes: 1 addition & 1 deletion orbit/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "1.1.4.7"
__version__ = "1.1.4.8"
16 changes: 4 additions & 12 deletions orbit/utils/stan.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from datetime import datetime
import json
import os
import platform
Expand Down Expand Up @@ -31,12 +30,6 @@
os.environ["Path"] += ";" + os.path.normpath(os.path.expanduser(path_string))


def get_file_time(path: str):
return datetime.fromtimestamp(os.path.getmtime(path)).replace(
second=0, microsecond=0
)


def get_compiled_stan_model(
stan_model_name: str = "",
stan_file_path: Optional[str] = None,
Expand Down Expand Up @@ -78,14 +71,13 @@ def get_compiled_stan_model(
)
# Check if exe is older than .stan file.
# This behavior is default on CmdStanModel if we don't have to specify the exe_file.
if not os.path.isfile(exe_file) or (
get_file_time(exe_file) <= get_file_time(stan_file)
):
force_compile = True
# if not os.path.isfile(exe_file) or (
# os.path.getmtime(exe_file) <= os.path.getmtime(stan_file)
# ):

if not os.path.isfile(exe_file) or force_compile:
logger.info(f"Compiling stan model:{stan_file}. ETA 3 - 5 mins.")
sm = CmdStanModel(stan_file=stan_file, force_compile=force_compile)
sm = CmdStanModel(stan_file=stan_file)
else:
sm = CmdStanModel(stan_file=stan_file, exe_file=exe_file)

Expand Down
35 changes: 17 additions & 18 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.black]
line-length = 88
target-version = ['py38', 'py39']
target-version = ['py39', 'py310']
include = '\.pyi?$'
extend-exclude = '''
# A regex preceded with ^/ will apply only to files and directories
Expand All @@ -19,39 +19,38 @@ build-backend = "setuptools.build_meta"
[project]
name = "orbit-ml"
authors = [
{name="Edwin Ng", email="[email protected]"},
{name="Edwin Ng"},
{name="Zhishi Wang"},
{name="Steve Yang"},
{name="Yifeng Wu"},
{name="Jing Pan"}
{name="Jing Pan"},
]
maintainers = [
{name = "Edwin Ng", email = "[email protected]"},
]
dynamic = ["version"]
description = "Orbit is a package for Bayesian time series modeling and inference."
readme = "README.md"
requires-python = ">=3.7"
requires-python = ">=3.9"
dependencies = [
"arviz",
"arviz>=0.17.1",
"cmdstanpy>=1.2.1",
"importlib_resources",
"matplotlib>=3.3.2",
"numpy>=1.18",
"pandas>=1.0.3",
"pyro-ppl>=1.4.0",
"scipy>=1.4.1",
"seaborn>=0.10.0",
"statsmodels>=0.11.1",
"torch>=1.11.0",
"tqdm>=4.36.1",
"importlib_resources>=6.4.0",
"ipywidgets",
"matplotlib>=3.8.3",
"numpy>=1.26.4",
"pandas>=2.2.1",
"pyro-ppl>=1.9.0",
"scipy>=1.12.0",
"seaborn>=0.13.2",
"setuptools>=42",
"statsmodels>=0.14.1",
"torch>=2.2.1",
"tqdm>=4.66.2",
]
license = {text = "Apache License 2.0"}
classifiers = [
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
Expand Down
22 changes: 11 additions & 11 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
arviz
arviz>=0.17.1
cmdstanpy>=1.2.1
importlib_resources
importlib_resources>=6.4.0
ipywidgets
matplotlib>=3.3.2
numpy>=1.18
pandas>=1.0.3
pyro-ppl>=1.4.0
scipy>=1.4.1
seaborn>=0.10.0
matplotlib>=3.8.3
numpy>=1.26.4
pandas>=2.2.1
pyro-ppl>=1.9.0
scipy>=1.12.0
seaborn>=0.13.2
setuptools>=42
statsmodels>=0.11.1
torch>=1.11.0
tqdm>=4.36.1
statsmodels>=0.14.1
torch>=2.2.1
tqdm>=4.66.2
16 changes: 8 additions & 8 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import os
import platform
import shutil
import sys
from pathlib import Path

from setuptools import find_packages, setup
Expand Down Expand Up @@ -65,6 +66,7 @@ def install_stan():
Reference from prophet
"""
from multiprocessing import cpu_count

import cmdstanpy

remove_older_cmdstan(CMDSTAN_VERSION)
Expand Down Expand Up @@ -93,12 +95,12 @@ def build_model(model: str, model_dir: str):


def build_stan_models():
for model in MODELS:
# note: ensure copy target is a directory not a file.
build_model(
model=model,
model_dir=MODEL_SOURCE_DIR,
)
if "conda" not in sys.prefix.lower():
for model in MODELS:
build_model(
model=model,
model_dir=MODEL_SOURCE_DIR,
)


class BuildPyCommand(build_py):
Expand All @@ -108,15 +110,13 @@ def run(self):
print("Running build py command.")
if not self.dry_run:
print("Not a dry run, run with build")
# build_stan_model(target_dir)

# install cmdstan and compilers, in the default directory for simplicity
install_stan()

# build all stan models
build_stan_models()

print("Dry run.")
build_py.run(self)


Expand Down

0 comments on commit da50bfe

Please sign in to comment.