Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make lupa an optional dependency. #14

Merged
merged 1 commit into from
Mar 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion kurobako/problem.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,21 @@
import copy
import enum
import json
from lupa import LuaRuntime
import numpy as np
from typing import Any
from typing import Dict
from typing import List
from typing import Optional
from typing import Union

try:
from lupa import LuaRuntime

_lupa_available = True
except ImportError:
_lupa_available = False


Self = Any


Expand Down Expand Up @@ -150,6 +157,11 @@ def is_constraint_satisfied(self, vars: List[Self], vals: List[Optional[float]])
if self.constraint is None:
return True

if not _lupa_available:
raise RuntimeError(
"Please install `lupa` to handle problems containing conditional search space."
)

lua = LuaRuntime()
for var, val in zip(vars, vals):
if val is None:
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ def get_long_description() -> str:
url="https://github.com/sile/kurobako-py",
license="MIT",
packages=find_packages(),
install_requires=["lupa", "numpy"],
install_requires=["numpy"],
extras_require={"checking": ["hacking", "mypy", "black"]},
)