Merge pull request #242952 from TomaSajt/prophet

python310Packages.prophet: init at 1.1.4
This commit is contained in:
OTABI Tomoya 2023-08-09 18:53:17 +09:00 committed by GitHub
commit c23c48c5d5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 237 additions and 0 deletions

View file

@ -0,0 +1,82 @@
{ lib
, buildPythonPackage
, fetchFromGitHub
, substituteAll
, cmdstan
, pandas
, numpy
, tqdm
, xarray
, pytestCheckHook
}:
buildPythonPackage rec {
pname = "cmdstanpy";
version = "1.1.0";
format = "setuptools";
src = fetchFromGitHub {
owner = "stan-dev";
repo = "cmdstanpy";
rev = "refs/tags/v${version}";
hash = "sha256-9kAd3rbSctWEhAzB6RiQlbg5/uVxGIghYLus8hWzBFQ=";
};
patches = [
(substituteAll {
src = ./use-nix-cmdstan-path.patch;
cmdstan = "${cmdstan}/opt/cmdstan";
})
];
postPatch = ''
# conftest.py would have used git to clean up, which is unnecessary here
rm test/conftest.py
'';
propagatedBuildInputs = [
pandas
numpy
tqdm
];
passthru.optional-dependencies = {
all = [ xarray ];
};
preCheck = ''
export HOME=$(mktemp -d)
'';
nativeCheckInputs = [
pytestCheckHook
] ++ passthru.optional-dependencies.all;
disabledTestPaths = [
# No need to test these when using Nix
"test/test_install_cmdstan.py"
"test/test_cxx_installation.py"
];
disabledTests = [
"test_lp_good" # Fails for some reason
"test_serialization" # Pickle class mismatch errors
# These tests use the flag -DSTAN_THREADS which doesn't work in cmdstan (missing file)
"test_multi_proc_threads"
"test_compile_force"
];
pythonImportsCheck = [ "cmdstanpy" ];
meta = {
homepage = "https://github.com/stan-dev/cmdstanpy";
description = "A lightweight interface to Stan for Python users";
changelog = "https://github.com/stan-dev/cmdstanpy/releases/tag/v${version}";
license = lib.licenses.bsd3;
platforms = lib.platforms.linux;
maintainers = with lib.maintainers; [ tomasajt ];
};
}

View file

@ -0,0 +1,25 @@
diff --git a/cmdstanpy/utils/cmdstan.py b/cmdstanpy/utils/cmdstan.py
index 227d97a..27c3ccc 100644
--- a/cmdstanpy/utils/cmdstan.py
+++ b/cmdstanpy/utils/cmdstan.py
@@ -163,19 +163,7 @@ def cmdstan_path() -> str:
if 'CMDSTAN' in os.environ and len(os.environ['CMDSTAN']) > 0:
cmdstan = os.environ['CMDSTAN']
else:
- cmdstan_dir = os.path.expanduser(os.path.join('~', _DOT_CMDSTAN))
- if not os.path.exists(cmdstan_dir):
- raise ValueError(
- 'No CmdStan installation found, run command "install_cmdstan"'
- 'or (re)activate your conda environment!'
- )
- latest_cmdstan = get_latest_cmdstan(cmdstan_dir)
- if latest_cmdstan is None:
- raise ValueError(
- 'No CmdStan installation found, run command "install_cmdstan"'
- 'or (re)activate your conda environment!'
- )
- cmdstan = os.path.join(cmdstan_dir, latest_cmdstan)
+ cmdstan = '@cmdstan@'
os.environ['CMDSTAN'] = cmdstan
validate_cmdstan_path(cmdstan)
return os.path.normpath(cmdstan)

View file

@ -0,0 +1,40 @@
{ lib
, buildPythonPackage
, fetchFromGitHub
, python-dateutil
, ephem
, pytz
, pytestCheckHook
}:
buildPythonPackage rec {
pname = "lunarcalendar";
version = "0.0.9";
format = "setuptools";
src = fetchFromGitHub {
owner = "wolfhong";
repo = "LunarCalendar";
rev = "885418ea1a2a90b7e0bbe758919af9987fb2863b";
hash = "sha256-AhxCWWqCjlOroqs4pOSZTWoIQT8a1l/D2Rxuw1XUoU8=";
};
propagatedBuildInputs = [
python-dateutil
ephem
pytz
];
nativeCheckInputs = [ pytestCheckHook ];
pythonImportsCheck = [ "lunarcalendar" ];
meta = {
homepage = "https://github.com/wolfhong/LunarCalendar";
description = "A Lunar-Solar Converter, containing a number of lunar and solar festivals in China";
license = lib.licenses.mit;
maintainers = with lib.maintainers; [ tomasajt ];
};
}

View file

@ -0,0 +1,84 @@
{ lib
, buildPythonPackage
, pythonOlder
, fetchFromGitHub
, fetchpatch
, setuptools
, cmdstanpy
, numpy
, matplotlib
, pandas
, lunarcalendar
, convertdate
, holidays
, python-dateutil
, tqdm
, importlib-resources
, pytestCheckHook
}:
buildPythonPackage rec {
pname = "prophet";
version = "1.1.4";
format = "pyproject";
disabled = pythonOlder "3.7";
src = fetchFromGitHub {
owner = "facebook";
repo = "prophet";
rev = "refs/tags/v${version}";
hash = "sha256-pbJ0xL5wDZ+rKgtQQTJPsB1Mu2QXo3S9MMpiYkURsz0=";
};
patches = [
# TODO: remove when bumping version from 1.1.4
(fetchpatch {
name = "fix-stan-file-temp-dest.patch";
url = "https://github.com/facebook/prophet/commit/374676500795aec9d5cbc7fe5f7a96bf00489809.patch";
hash = "sha256-sfiQ2V3ZEF0WM9oM1FkL/fhZesQJ1i2EUPYJMdDA2UM=";
relative = "python";
})
];
sourceRoot = "source/python";
env.PROPHET_REPACKAGE_CMDSTAN = "false";
nativeBuildInputs = [ setuptools ];
# TODO: update when bumping version from 1.1.4
propagatedBuildInputs = [
cmdstanpy
numpy
matplotlib
pandas
lunarcalendar
convertdate
holidays
python-dateutil
tqdm
importlib-resources
];
preCheck = ''
# the generated stan_model directory only exists in build/lib*
cd build/lib*
'';
nativeCheckInputs = [ pytestCheckHook ];
pythonImportsCheck = [ "prophet" ];
meta = {
homepage = "https://facebook.github.io/prophet/";
description = "A tool for producing high quality forecasts for time series data that has multiple seasonality with linear or non-linear growth";
changelog = "https://github.com/facebook/prophet/releases/tag/v${version}";
license = lib.licenses.mit;
platforms = lib.platforms.linux;
maintainers = with lib.maintainers; [ tomasajt ];
};
}

View file

@ -2041,6 +2041,8 @@ self: super: with self; {
cmdline = callPackage ../development/python-modules/cmdline { };
cmdstanpy = callPackage ../development/python-modules/cmdstanpy { };
cmigemo = callPackage ../development/python-modules/cmigemo {
inherit (pkgs) cmigemo;
};
@ -6167,6 +6169,8 @@ self: super: with self; {
luhn = callPackage ../development/python-modules/luhn { };
lunarcalendar = callPackage ../development/python-modules/lunarcalendar { };
luqum = callPackage ../development/python-modules/luqum { };
luxor = callPackage ../development/python-modules/luxor { };
@ -8026,6 +8030,8 @@ self: super: with self; {
prodict = callPackage ../development/python-modules/prodict { };
prophet = callPackage ../development/python-modules/prophet { };
propka = callPackage ../development/python-modules/propka { };
proxy_tools = callPackage ../development/python-modules/proxy_tools { };