Closed Alex-K37 closed 5 days ago
Thanks for reporting, @Alex-K37! We'll take a look when time permits.
Caused by the issue this fixes: https://github.com/TimefoldAI/timefold-solver-python/pull/101 ; The gist of it is because Python datetime classes are C-Native, we need to implement our own to avoid FFI calls (that is, Python calling Java or Java calling Python). The datetime classes were missing a few methods that deal with formatting. The hello-world
and school-timetabling
examples used said unimplemented method in their __str__
function. The __str__
function is only called when DEBUG logging or lower is used.
If you modified the __str__
function of Timeslot
to not call strftime
, no exception would occur.
Describe the bug
Turning on DEBUG logging causes exceptions with the hello-world example.
Expected behavior More detailed log messages.
Actual behavior
The following error is shown (only first few lines):
Traceback (most recent call last): File "DefaultSolver.java", line 200, in ai.timefold.solver.core.impl.solver.DefaultSolver.solve Exception: Java Exception
The above exception was the direct cause of the following exception:
Traceback (most recent call last): File "/home/***/.virtualenvs/timefold/lib/python3.11/site-packages/timefold/solver/_solver.py", line 109, in solve java_solution = self._delegate.solve(java_problem) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ai.timefold.jpyinterpreter.types.errors.ai.timefold.jpyinterpreter.types.errors.AttributeError: ai.timefold.jpyinterpreter.types.errors.AttributeError: object '08:30' does not have attribute 'strftime'
To Reproduce
diff --git a/python/hello-world/src/hello_world/main.py b/python/hello-world/src/hello_world/main.py index 660f7430..4b60fade 100644 --- a/python/hello-world/src/hello_world/main.py +++ b/python/hello-world/src/hello_world/main.py @@ -10,7 +10,7 @@ from .domain import * from .constraints import define_constraints
-logging.basicConfig(level=logging.INFO) +logging.basicConfig(level=logging.DEBUG) LOGGER = logging.getLogger('app')
Environment
Timefold Solver Version or Git ref:
1.11.0b0
Output of
java -version
: openjdk version "17.0.11" 2024-04-16 OpenJDK Runtime Environment (build 17.0.11+9-suse-150400.3.42.1-x8664) OpenJDK 64-Bit Server VM (build 17.0.11+9-suse-150400.3.42.1-x8664, mixed mode, sharing)Output of
uname -a
orver
: Linux think14 5.14.21-150500.55.65-default TimefoldAI/timefold-solver#1 SMP PREEMPT_DYNAMIC Thu May 23 04:57:11 UTC 2024 (a46829d) x86_64 x86_64 x86_64 GNU/Linux