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

Add version validation during resolve's graph analysis #3887

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

carlobaldassi
Copy link
Member

@carlobaldassi carlobaldassi commented May 2, 2024

This fixes #3878 by adding an extra step during graph simplification, which I'm calling "version validation".

The validation consists in going through each version of each package (including the "uninstalled" pseudo-version), temporarily pinning it, and checking whether constraint propagation would lead to impossible scenarios. Versions which do that can be disabled to further simplify the graph. But most importantly it may turn out that all versions of a package are invalid, in which case the resolver has proved that the problem is unsatisfiable and it stops with an error.

In order to make this a little faster, I'm using a heuristic in which we don't really check all versions of a package, we stop as soon as a valid version is found (a proper one, not "uninstalled"), starting from higher versions and going down. This retains the property that impossible packages may be detected.

In my experiments, the overhead seems acceptable (nearly unnoticeable most of the times, sometimes it even makes things faster by passing a simpler graph to the solver). However, I would urge other people to give this a try, especially if someone has projects involving many dependencies.

The main commit is the last one, the others are largely independent (please don't squash them); I may create a separate PR for each if deemed necessary. It's all stuff that came out while I was working on the main issue.

Besides speed concerns, there are two more minor issues:

  1. I haven't added new tests specific to the problem in Resolving takes hours #3878. The problem is that in order to trigger the issue we need such a big graph that just parsing it takes minutes (locally, I have been using a 15Mb text data file). (now there are tests)
  2. Logging is a bit opaque (even more than usual). Basically, the best I could come up with is this: if some versions of a package are removed by the validation procedure, we just say so without further details (e.g. "Optimization [7f7a1694]: restricted by version validation to versions: 3.5.0 - 3.19.3 (7/22 versions removed)"). If all versions of a package are removed, then we say so, and trigger a failure by providing an example log of what would happen if installing one of the versions (example below).

Advice/comments about these points would also be welcome.

Below is an example of the validator catching an impossible situation (the same described here) before the actual optimizer runs (this is on julia master, resolving takes 2 or 3 seconds on my laptop). Here it was found that RigidBodyDynamics cannot be installed. So, for the sake of providing a log, its version was pinned at 2.4.0 and then propagating the constraints triggered an issue with ModelingToolkit. If you look closely, you'll see that in the RigidBodyDynamics sub-tree there is the sentence "pinned to version 2.4.0 during version validation".

(jl_cSJTVk) pkg> add ModelingToolkit MeshCatMechanisms Symbolics@5
    Updating registry at `~/.julia/registries/General.toml`
   Resolving package versions...
ERROR: Package RigidBodyDynamics [366cf18f] has no possible versions; here is the log when trying to validate the highest version left until this point, 2.4.0):
Unsatisfiable requirements detected for package ModelingToolkit [961ee093]:
 ModelingToolkit [961ee093] log:
 ├─possible versions are: 0.0.1 - 9.12.2 or uninstalled
 ├─restricted to versions * by an explicit requirement, leaving only versions: 0.0.1 - 9.12.2
 ├─restricted by compatibility requirements with Symbolics [0c5d862f] to versions: [0.0.1 - 5.9.1, 8.47.0 - 9.12.2] or uninstalled, leaving only versions: [0.0.1 - 5.9.1, 8.47.0 - 9.12.2]
 │ └─Symbolics [0c5d862f] log:
 │   ├─possible versions are: 0.1.0 - 5.28.0 or uninstalled
 │   ├─restricted to versions 5 by an explicit requirement, leaving only versions: 5.0.0 - 5.28.0
 │   ├─versions reduced by equivalence to: 5.0.3 - 5.28.0
 │   └─restricted by compatibility requirements with DocStringExtensions [ffbed154] to versions: 5.0.3 - 5.14.1 or uninstalled, leaving only versions: 5.0.3 - 5.14.1
 │     └─DocStringExtensions [ffbed154] log:
 │       ├─possible versions are: 0.4.6 - 0.9.3 or uninstalled
 │       ├─restricted by compatibility requirements with Symbolics [0c5d862f] to versions: 0.7.0 - 0.9.3
 │       │ └─Symbolics [0c5d862f] log: see above
 │       ├─restricted by compatibility requirements with SymbolicUtils [d1185830] to versions: 0.8.0 - 0.9.3
 │       │ └─SymbolicUtils [d1185830] log:
 │       │   ├─possible versions are: 0.1.0 - 1.5.1 or uninstalled
 │       │   ├─restricted by compatibility requirements with Symbolics [0c5d862f] to versions: 1.0.1 - 1.5.1
 │       │   │ └─Symbolics [0c5d862f] log: see above
 │       │   └─versions reduced by equivalence to: 1.1.0 - 1.5.1
 │       ├─restricted by compatibility requirements with JumpProcesses [ccbc3e58] to versions: 0.8.6 - 0.9.3
 │       │ └─JumpProcesses [ccbc3e58] log:
 │       │   ├─possible versions are: 9.0.0 - 9.11.1 or uninstalled
 │       │   ├─restricted by compatibility requirements with ModelingToolkit [961ee093] to versions: 9.1.0 - 9.11.1
 │       │   │ └─ModelingToolkit [961ee093] log: see above
 │       │   ├─versions reduced by equivalence to: 9.1.3 - 9.11.1
 │       │   ├─restricted by compatibility requirements with DocStringExtensions [ffbed154] to versions: 9.1.3 - 9.10.1 or uninstalled, leaving only versions: 9.1.3 - 9.10.1
 │       │   │ └─DocStringExtensions [ffbed154] log: see above
 │       │   └─restricted by compatibility requirements with DiffEqBase [2b5f629d] to versions: 9.1.3 - 9.5.1 or uninstalled, leaving only versions: 9.1.3 - 9.5.1
 │       │     └─DiffEqBase [2b5f629d] log:
 │       │       ├─possible versions are: 3.13.2 - 6.149.1 or uninstalled
 │       │       ├─required (without additional version restrictions) by ModelingToolkit [961ee093]
 │       │       │ └─ModelingToolkit [961ee093] log: see above
 │       │       ├─restricted by compatibility requirements with DataStructures [864edb3b] to versions: [3.13.2 - 5.20.1, 6.44.0 - 6.149.1] or uninstalled, leaving only versions: [3.13.2 - 5.20.1, 6.44.0 - 6.149.1]
 │       │       │ └─DataStructures [864edb3b] log:
 │       │       │   ├─possible versions are: 0.9.0 - 0.18.20 or uninstalled
 │       │       │   ├─restricted by compatibility requirements with Symbolics [0c5d862f] to versions: 0.18.0 - 0.18.20
 │       │       │   │ └─Symbolics [0c5d862f] log: see above
 │       │       │   └─versions reduced by equivalence to: 0.18.8 - 0.18.20
 │       │       ├─restricted by compatibility requirements with StaticArrays [90137ffa] to versions: [3.13.2 - 4.23.4, 6.50.0 - 6.149.1] or uninstalled, leaving only versions: [3.13.2 - 4.23.4, 6.50.0 - 6.149.1]
 │       │       │ └─StaticArrays [90137ffa] log:
 │       │       │   ├─possible versions are: 0.8.0 - 1.9.3 or uninstalled
 │       │       │   ├─restricted by compatibility requirements with Symbolics [0c5d862f] to versions: 1.1.0 - 1.9.3
 │       │       │   │ └─Symbolics [0c5d862f] log: see above
 │       │       │   ├─restricted by julia compatibility requirements to versions: [0.12.0 - 0.12.6, 1.5.0 - 1.9.3] or uninstalled, leaving only versions: 1.5.0 - 1.9.3
 │       │       │   └─versions reduced by equivalence to: 1.5.3 - 1.9.3
 │       │       ├─restricted by compatibility requirements with Compat [34da2185] to versions: 5.7.0 - 6.149.1 or uninstalled, leaving only versions: 6.50.0 - 6.149.1
 │       │       │ └─Compat [34da2185] log:
 │       │       │   ├─possible versions are: 1.0.0 - 4.14.0 or uninstalled
 │       │       │   ├─restricted by julia compatibility requirements to versions: 2.0.0 - 4.14.0 or uninstalled
 │       │       │   ├─restricted by compatibility requirements with DataStructures [864edb3b] to versions: 3.0.0 - 4.14.0
 │       │       │   │ └─DataStructures [864edb3b] log: see above
 │       │       │   ├─restricted by compatibility requirements with ModelingToolkit [961ee093] to versions: 3.42.0 - 4.14.0
 │       │       │   │ └─ModelingToolkit [961ee093] log: see above
 │       │       │   └─versions reduced by equivalence to: 3.45.0 - 4.14.0
 │       │       ├─restricted by compatibility requirements with ChainRulesCore [d360d2e6] to versions: [3.13.2 - 6.10.0, 6.59.1, 6.69.0 - 6.149.1] or uninstalled, leaving only versions: [6.59.1, 6.69.0 - 6.149.1]
 │       │       │ └─ChainRulesCore [d360d2e6] log:
 │       │       │   ├─possible versions are: 0.1.0 - 1.23.0 or uninstalled
 │       │       │   ├─restricted by compatibility requirements with SymbolicUtils [d1185830] to versions: 1.0.0 - 1.23.0
 │       │       │   │ └─SymbolicUtils [d1185830] log: see above
 │       │       │   └─versions reduced by equivalence to: 1.0.0 - 1.23.0
 │       │       ├─restricted by compatibility requirements with ModelingToolkit [961ee093] to versions: 6.103.0 - 6.149.1
 │       │       │ └─ModelingToolkit [961ee093] log: see above
 │       │       ├─versions reduced by equivalence to: 6.103.2 - 6.149.1
 │       │       └─restricted by compatibility requirements with DocStringExtensions [ffbed154] to versions: 6.103.2 - 6.108.0 or uninstalled, leaving only versions: 6.103.2 - 6.108.0
 │       │         └─DocStringExtensions [ffbed154] log: see above
 │       ├─versions reduced by equivalence to: 0.8.6 - 0.9.3
 │       └─restricted by compatibility requirements with MeshCat [283c5d60] to versions: 0.8.6
 │         └─MeshCat [283c5d60] log:
 │           ├─possible versions are: 0.1.0 - 0.16.2 or uninstalled
 │           ├─restricted by compatibility requirements with MeshCatMechanisms [6ad125db] to versions: [0.1.0 - 0.11.3, 0.13.0 - 0.16.2]
 │           │ └─MeshCatMechanisms [6ad125db] log:
 │           │   ├─possible versions are: 0.0.1 - 0.9.0 or uninstalled
 │           │   ├─restricted to versions * by an explicit requirement, leaving only versions: 0.0.1 - 0.9.0
 │           │   ├─restricted by compatibility requirements with Compat [34da2185] to versions: [0.0.1 - 0.1.0, 0.2.0 - 0.9.0] or uninstalled, leaving only versions: [0.0.1 - 0.1.0, 0.2.0 - 0.9.0]
 │           │   │ └─Compat [34da2185] log: see above
 │           │   ├─restricted by compatibility requirements with MechanismGeometries [931e9471] to versions: [0.0.1, 0.8.0 - 0.9.0] or uninstalled, leaving only versions: [0.0.1, 0.8.0 - 0.9.0]
 │           │   │ └─MechanismGeometries [931e9471] log:
 │           │   │   ├─possible versions are: 0.1.0 - 0.7.1 or uninstalled
 │           │   │   ├─restricted by compatibility requirements with StaticArrays [90137ffa] to versions: 0.6.0 - 0.7.1 or uninstalled
 │           │   │   │ └─StaticArrays [90137ffa] log: see above
 │           │   │   ├─restricted by compatibility requirements with MeshCatMechanisms [6ad125db] to versions: 0.7.0 - 0.7.1
 │           │   │   │ └─MeshCatMechanisms [6ad125db] log: see above
 │           │   │   └─versions reduced by equivalence to: 0.7.0 - 0.7.1
 │           │   ├─restricted by compatibility requirements with RigidBodyDynamics [366cf18f] to versions: 0.5.0 - 0.9.0 or uninstalled, leaving only versions: 0.8.0 - 0.9.0
 │           │   │ └─RigidBodyDynamics [366cf18f] log:
 │           │   │   ├─possible versions are: 0.0.1 - 2.4.0 or uninstalled
 │           │   │   ├─restricted by compatibility requirements with MeshCatMechanisms [6ad125db] to versions: 0.4.0 - 2.4.0
 │           │   │   │ └─MeshCatMechanisms [6ad125db] log: see above
 │           │   │   ├─restricted by compatibility requirements with StaticArrays [90137ffa] to versions: 2.3.1 - 2.4.0 or uninstalled, leaving only versions: 2.3.1 - 2.4.0
 │           │   │   │ └─StaticArrays [90137ffa] log: see above
 │           │   │   ├─versions reduced by equivalence to: 2.3.2 - 2.4.0
 │           │   │   └─pinned to version 2.4.0 during version validation
 │           │   ├─restricted by compatibility requirements with Interpolations [a98d9a8b] to versions: 0.8.1 - 0.9.0 or uninstalled, leaving only versions: 0.8.1 - 0.9.0
 │           │   │ └─Interpolations [a98d9a8b] log:
 │           │   │   ├─possible versions are: 0.3.6 - 0.15.1 or uninstalled
 │           │   │   ├─restricted by compatibility requirements with MeshCatMechanisms [6ad125db] to versions: 0.3.6 - 0.14.7
 │           │   │   │ └─MeshCatMechanisms [6ad125db] log: see above
 │           │   │   ├─restricted by compatibility requirements with StaticArrays [90137ffa] to versions: [0.3.6 - 0.4.0, 0.13.1 - 0.15.1] or uninstalled, leaving only versions: [0.3.6 - 0.4.0, 0.13.1 - 0.14.7]
 │           │   │   │ └─StaticArrays [90137ffa] log: see above
 │           │   │   ├─restricted by compatibility requirements with Compat [34da2185] to versions: 0.9.0 - 0.15.1 or uninstalled, leaving only versions: 0.13.1 - 0.14.7
 │           │   │   │ └─Compat [34da2185] log: see above
 │           │   │   ├─restricted by compatibility requirements with ChainRulesCore [d360d2e6] to versions: [0.3.6 - 0.13.2, 0.13.4 - 0.15.1] or uninstalled, leaving only versions: [0.13.1 - 0.13.2, 0.13.4 - 0.14.7]
 │           │   │   │ └─ChainRulesCore [d360d2e6] log: see above
 │           │   │   └─versions reduced by equivalence to: [0.13.1 - 0.13.2, 0.13.6 - 0.14.7]
 │           │   └─versions reduced by equivalence to: 0.8.1 - 0.9.0
 │           ├─restricted by compatibility requirements with StaticArrays [90137ffa] to versions: 0.13.1 - 0.16.2 or uninstalled, leaving only versions: 0.13.1 - 0.16.2
 │           │ └─StaticArrays [90137ffa] log: see above
 │           ├─versions reduced by equivalence to: 0.13.2 - 0.16.2
 │           └─restricted by compatibility requirements with Rotations [6038ab10] to versions: 0.13.2 - 0.14.2 or uninstalled, leaving only versions: 0.13.2 - 0.14.2
 │             └─Rotations [6038ab10] log:
 │               ├─possible versions are: 0.7.2 - 1.7.0 or uninstalled
 │               ├─required (without additional version restrictions) by MeshCat [283c5d60]
 │               │ └─MeshCat [283c5d60] log: see above
 │               ├─restricted by compatibility requirements with StaticArrays [90137ffa] to versions: 1.0.2 - 1.7.0 or uninstalled, leaving only versions: 1.0.2 - 1.7.0
 │               │ └─StaticArrays [90137ffa] log: see above
 │               ├─versions reduced by equivalence to: 1.0.2 - 1.7.0
 │               └─restricted by compatibility requirements with RigidBodyDynamics [366cf18f] to versions: 1.2.0
 │                 └─RigidBodyDynamics [366cf18f] log: see above
 ├─restricted by compatibility requirements with RuntimeGeneratedFunctions [7e49a35a] to versions: [0.0.1 - 3.21.0, 4.5.0 - 9.12.2] or uninstalled, leaving only versions: [0.0.1 - 3.21.0, 4.5.0 - 5.9.1, 8.47.0 - 9.12.2]
 │ └─RuntimeGeneratedFunctions [7e49a35a] log:
 │   ├─possible versions are: 0.1.0 - 0.5.13 or uninstalled
 │   ├─restricted by compatibility requirements with Symbolics [0c5d862f] to versions: 0.5.0 - 0.5.13
 │   │ └─Symbolics [0c5d862f] log: see above
 │   └─versions reduced by equivalence to: 0.5.0 - 0.5.13
 ├─restricted by compatibility requirements with SymbolicUtils [d1185830] to versions: [0.0.1 - 3.1.1, 8.47.0 - 9.12.2] or uninstalled, leaving only versions: [0.0.1 - 3.1.1, 8.47.0 - 9.12.2]
 │ └─SymbolicUtils [d1185830] log: see above
 ├─restricted by compatibility requirements with SpecialFunctions [276daf66] to versions: 1.1.3 - 9.12.2 or uninstalled, leaving only versions: [1.1.3 - 3.1.1, 8.47.0 - 9.12.2]
 │ └─SpecialFunctions [276daf66] log:
 │   ├─possible versions are: 0.7.0 - 2.3.1 or uninstalled
 │   ├─required (without additional version restrictions) by Symbolics [0c5d862f]
 │   │ └─Symbolics [0c5d862f] log: see above
 │   ├─restricted by compatibility requirements with SymbolicUtils [d1185830] to versions: 0.10.0 - 2.3.1
 │   │ └─SymbolicUtils [d1185830] log: see above
 │   ├─restricted by compatibility requirements with ChainRulesCore [d360d2e6] to versions: [0.7.0 - 1.1.0, 1.6.0 - 2.3.1] or uninstalled, leaving only versions: [0.10.0 - 1.1.0, 1.6.0 - 2.3.1]
 │   │ └─ChainRulesCore [d360d2e6] log: see above
 │   ├─restricted by compatibility requirements with LogExpFunctions [2ab3a3ac] to versions: [0.7.0 - 1.3.0, 1.6.1 - 2.3.1] or uninstalled, leaving only versions: [0.10.0 - 1.1.0, 1.6.1 - 2.3.1]
 │   │ └─LogExpFunctions [2ab3a3ac] log:
 │   │   ├─possible versions are: 0.2.0 - 0.3.27 or uninstalled
 │   │   ├─restricted by compatibility requirements with DiffRules [b552c78f] to versions: 0.3.0 - 0.3.27
 │   │   │ └─DiffRules [b552c78f] log:
 │   │   │   ├─possible versions are: 0.0.8 - 1.15.1 or uninstalled
 │   │   │   ├─restricted by compatibility requirements with Symbolics [0c5d862f] to versions: 1.4.0 - 1.15.1
 │   │   │   │ └─Symbolics [0c5d862f] log: see above
 │   │   │   └─versions reduced by equivalence to: 1.4.0 - 1.15.1
 │   │   ├─restricted by compatibility requirements with StatsFuns [4c63d2b9] to versions: 0.3.2 - 0.3.27
 │   │   │ └─StatsFuns [4c63d2b9] log:
 │   │   │   ├─possible versions are: 0.7.0 - 1.3.1 or uninstalled
 │   │   │   ├─restricted by compatibility requirements with SpecialFunctions [276daf66] to versions: 0.9.4 - 1.3.1 or uninstalled
 │   │   │   │ └─SpecialFunctions [276daf66] log: see above
 │   │   │   ├─restricted by compatibility requirements with Distributions [31c24e10] to versions: 0.8.0 - 1.3.1, leaving only versions: 0.9.4 - 1.3.1
 │   │   │   │ └─Distributions [31c24e10] log:
 │   │   │   │   ├─possible versions are: 0.16.0 - 0.25.108 or uninstalled
 │   │   │   │   ├─restricted by compatibility requirements with Symbolics [0c5d862f] to versions: 0.23.0 - 0.25.108
 │   │   │   │   │ └─Symbolics [0c5d862f] log: see above
 │   │   │   │   ├─restricted by compatibility requirements with StatsBase [2913bbd2] to versions: 0.23.2 - 0.25.108 or uninstalled, leaving only versions: 0.23.2 - 0.25.108
 │   │   │   │   │ └─StatsBase [2913bbd2] log:
 │   │   │   │   │   ├─possible versions are: 0.24.0 - 0.34.3 or uninstalled
 │   │   │   │   │   ├─restricted by compatibility requirements with DataStructures [864edb3b] to versions: 0.33.1 - 0.34.3 or uninstalled
 │   │   │   │   │   │ └─DataStructures [864edb3b] log: see above
 │   │   │   │   │   ├─restricted by compatibility requirements with Distributions [31c24e10] to versions: 0.32.0 - 0.34.3, leaving only versions: 0.33.1 - 0.34.3
 │   │   │   │   │   │ └─Distributions [31c24e10] log: see above
 │   │   │   │   │   └─versions reduced by equivalence to: 0.33.4 - 0.34.3
 │   │   │   │   ├─restricted by compatibility requirements with StaticArrays [90137ffa] to versions: [0.16.0 - 0.23.11, 0.24.5 - 0.25.108] or uninstalled, leaving only versions: [0.23.2 - 0.23.11, 0.24.5 - 0.25.108]
 │   │   │   │   │ └─StaticArrays [90137ffa] log: see above
 │   │   │   │   ├─restricted by compatibility requirements with FillArrays [1a297f60] to versions: [0.16.0 - 0.21.9, 0.25.49 - 0.25.108] or uninstalled, leaving only versions: 0.25.49 - 0.25.108
 │   │   │   │   │ └─FillArrays [1a297f60] log:
 │   │   │   │   │   ├─possible versions are: 0.2.0 - 1.10.2 or uninstalled
 │   │   │   │   │   ├─restricted by julia compatibility requirements to versions: 0.13.0 - 1.10.2 or uninstalled
 │   │   │   │   │   ├─restricted by compatibility requirements with Distributions [31c24e10] to versions: 0.8.0 - 1.10.2, leaving only versions: 0.13.0 - 1.10.2
 │   │   │   │   │   │ └─Distributions [31c24e10] log: see above
 │   │   │   │   │   └─versions reduced by equivalence to: 0.13.0 - 1.10.2
 │   │   │   │   └─versions reduced by equivalence to: 0.25.56 - 0.25.108
 │   │   │   ├─restricted by compatibility requirements with LogExpFunctions [2ab3a3ac] to versions: [0.7.0 - 0.9.7, 0.9.9 - 1.3.1] or uninstalled, leaving only versions: [0.9.4 - 0.9.7, 0.9.9 - 1.3.1]
 │   │   │   │ └─LogExpFunctions [2ab3a3ac] log: see above
 │   │   │   ├─restricted by compatibility requirements with Distributions [31c24e10] to versions: 0.9.15 - 1.3.1
 │   │   │   │ └─Distributions [31c24e10] log: see above
 │   │   │   └─versions reduced by equivalence to: 0.9.17 - 1.3.1
 │   │   └─versions reduced by equivalence to: 0.3.3 - 0.3.27
 │   ├─restricted by compatibility requirements with Distributions [31c24e10] to versions: 1.2.0 - 2.3.1, leaving only versions: 1.6.1 - 2.3.1
 │   │ └─Distributions [31c24e10] log: see above
 │   └─versions reduced by equivalence to: 1.6.1 - 2.3.1
 ├─restricted by compatibility requirements with StaticArrays [90137ffa] to versions: 4.0.7 - 9.12.2 or uninstalled, leaving only versions: 8.47.0 - 9.12.2
 │ └─StaticArrays [90137ffa] log: see above
 ├─versions reduced by equivalence to: 8.47.0 - 9.12.2
 ├─restricted by compatibility requirements with SciMLBase [0bca4576] to versions: 8.47.0 - 8.70.0 or uninstalled, leaving only versions: 8.47.0 - 8.70.0
 │ └─SciMLBase [0bca4576] log:
 │   ├─possible versions are: 1.0.0 - 2.36.0 or uninstalled
 │   ├─restricted by compatibility requirements with Symbolics [0c5d862f] to versions: 1.8.0 - 2.36.0
 │   │ └─Symbolics [0c5d862f] log: see above
 │   ├─restricted by compatibility requirements with DiffEqBase [2b5f629d] to versions: [1.10.0 - 1.98.1, 2.0.1 - 2.36.0]
 │   │ └─DiffEqBase [2b5f629d] log: see above
 │   ├─restricted by compatibility requirements with ModelingToolkit [961ee093] to versions: [1.76.1 - 1.98.1, 2.0.1 - 2.36.0]
 │   │ └─ModelingToolkit [961ee093] log: see above
 │   ├─versions reduced by equivalence to: [1.81.0 - 1.98.1, 2.0.6 - 2.36.0]
 │   ├─restricted by compatibility requirements with DocStringExtensions [ffbed154] to versions: 1.81.0 - 2.10.0 or uninstalled, leaving only versions: 1.81.0 - 2.10.0
 │   │ └─DocStringExtensions [ffbed154] log: see above
 │   ├─restricted by compatibility requirements with DiffEqBase [2b5f629d] to versions: 1.81.0 - 1.98.1
 │   │ └─DiffEqBase [2b5f629d] log: see above
 │   └─restricted by compatibility requirements with SymbolicIndexingInterface [2efcf032] to versions: [1.81.0, 2.11.0 - 2.36.0] or uninstalled, leaving only versions: 1.81.0
 │     └─SymbolicIndexingInterface [2efcf032] log:
 │       ├─possible versions are: 0.1.0 - 0.3.20 or uninstalled
 │       ├─required (without additional version restrictions) by ModelingToolkit [961ee093]
 │       │ └─ModelingToolkit [961ee093] log: see above
 │       ├─versions reduced by equivalence to: 0.1.1 - 0.3.20
 │       └─restricted by compatibility requirements with DocStringExtensions [ffbed154] to versions: 0.3.0 - 0.3.20 or uninstalled, leaving only versions: 0.3.0 - 0.3.20
 │         └─DocStringExtensions [ffbed154] log: see above
 └─restricted by compatibility requirements with SymbolicIndexingInterface [2efcf032] to versions: 8.74.1 - 9.12.2 or uninstalled — no versions left
   └─SymbolicIndexingInterface [2efcf032] log: see above

@IanButterworth
Copy link
Sponsor Member

Just a couple of passing comments:

  1. Should we add the reproducer as a test? Maybe we need to check out General at a fixed commit to do so? or do we have a smaller MWE?
  2. Some of these changes feel adjacent to Initialy display of possible versions doesn't take into account yanked versions #3817 just in case the fix to that is obvious in the context of this

With this the VersionSpec shows a string that can be parsed to
reconstruct the same object.
Avoids issues with disjoint VersionRanges, e.g.
VersionSpec("[0-1, 3-5]")  # before
VersionSepc(["0-1", "3-5") # after
A leftover from the change String->UUID in packages representation.
This was discarding relevant info from the log.
Don't count color directives when computing the padding (this also
affects the builtin rpad function)
The new tests are based on a timer. So this also adds a `yield` call in
the backtracking part of the resolver's code to give the scheduler an
opportunity to interrupt it.
@carlobaldassi
Copy link
Member Author

@IanButterworth

  1. Should we add the reproducer as a test? Maybe we need to check out General at a fixed commit to do so? or do we have a smaller MWE?

I have now added tests in a new commit, but I had to work around the difficulties in finding a MWE that I was mentioning in the OP. So the tests are based on a reduced version, which however would work fine even before this patch, only it would take a couple of minutes or so. With the patch, it takes less than a second. So the test uses a timeout with a limit of 10 seconds, after which it interrupts the resolver.

In order to do this, I had to implement a timeout macro and add an explicit yield call in the middle of the resolver code (here) to make it interruptible. From what I think I understood, this is basically unavoidable, but I am not expert and thus I'm not very confident that my approach is entirely correct or the best one. I also don't know if it has drawbacks. Probably someone more familiar with scheduling, tasks, async calls etc should have a look.

  1. Some of these changes feel adjacent to Initialy display of possible versions doesn't take into account yanked versions #3817 just in case the fix to that is obvious in the context of this

I don't think that issue can be addressed in this context.

@IanButterworth
Copy link
Sponsor Member

For the timeout stuff, what about instead of yield and throwto (which AFAIK wouldn't be robust) replace the yield with a check for the elapsed time since the resolve started, against a global timeout variable that's high for normal usage and tests could reduce for test speed?

@KristofferC
Copy link
Sponsor Member

Is this good to go?

@carlobaldassi
Copy link
Member Author

carlobaldassi commented May 13, 2024

Is this good to go?

It might be good to go, but then there was @IanButterworth's comment about setting a timeout in the resolver itself. I have been thinking about how to do it but didn't get around to give it a try due to lack of time, sorry. I'll give it a go as soon as I can.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Resolving takes hours
4 participants