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

Error message for error in constraint provider must mention the line #969

Closed
ge0ffrey opened this issue Jun 18, 2024 · 1 comment · Fixed by #1082
Closed

Error message for error in constraint provider must mention the line #969

ge0ffrey opened this issue Jun 18, 2024 · 1 comment · Fixed by #1082
Assignees
Labels
enhancement New feature or request process/needs triage Requires initial assessment of validity, priority etc. python Is related to Python code.

Comments

@ge0ffrey
Copy link
Contributor

What line did this happen on?

Traceback (most recent call last):
  File "/home/ge0ffrey/projects/tf/tf-main/timefold-quickstarts/python/employee-scheduling/.venv/bin/run-app", line 5, in <module>
    from employee_scheduling import main
  File "/home/ge0ffrey/projects/tf/tf-main/timefold-quickstarts/python/employee-scheduling/src/employee_scheduling/__init__.py", line 3, in <module>
    from .routes import app
  File "/home/ge0ffrey/projects/tf/tf-main/timefold-quickstarts/python/employee-scheduling/src/employee_scheduling/routes.py", line 23, in <module>
    solver_manager = SolverManager.create(SolverFactory.create(solver_config))
                                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ge0ffrey/projects/tf/tf-main/timefold-quickstarts/python/employee-scheduling/.venv/lib64/python3.11/site-packages/timefold/solver/_solver_factory.py", line 52, in create
    delegate = JavaSolverFactory.create(solver_config)  # noqa
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
NameError: name 'Availability' is not defined

I suspect line 75 in constraints.py:

def unavailable_employee(constraint_factory: ConstraintFactory):
    return (constraint_factory.for_each(Shift)
            .join(Availability,

The error message dosn't mention "line 75" nor the filename.

@ge0ffrey ge0ffrey added enhancement New feature or request process/needs triage Requires initial assessment of validity, priority etc. labels Jun 18, 2024
@Christopher-Chianelli
Copy link
Contributor

I think this is related to jpype-project/jpype#1057

How a ConstraintProvider is constructed go through these steps:

  • Python calls Java SolverFactory to create a Solver
  • Java SolverFactory create an instance of the generated ConstraintProvider class and call its defineConstraints method
  • defineConstraints call into Python to compile the Python functions used in constraints and return to Java

The Python code in defineConstraints throws a name error since Availability is not in globals (missed import or removed class). This exception then goes to Java, which replaces its stack trace with its own.

@triceo triceo transferred this issue from TimefoldAI/timefold-solver-python Jul 17, 2024
@triceo triceo added java Is related to Java code. python Is related to Python code. and removed java Is related to Java code. labels Jul 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request process/needs triage Requires initial assessment of validity, priority etc. python Is related to Python code.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants