Skip to content

Commit

Permalink
Conda exception in setup.py, bump version number
Browse files Browse the repository at this point in the history
if conda, don't precompile models
  • Loading branch information
swotai committed Mar 25, 2024
1 parent e210705 commit 1529855
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 19 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
14 changes: 8 additions & 6 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 Down

0 comments on commit 1529855

Please sign in to comment.