Skip to content

Commit 1013871

Browse files
authored
Merge pull request #381 from alphaville/fix/380-pkg-resources
Fix 378 and 380
2 parents 54a35b8 + 61abed5 commit 1013871

24 files changed

Lines changed: 496 additions & 129 deletions

CHANGELOG.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,19 @@ Note: This is the main Changelog file for the Rust solver. The Changelog file fo
99

1010

1111
<!-- ---------------------
12-
Unreleased
12+
v0.10.0
1313
--------------------- -->
14-
## [v0.9.2] - Unreleased
14+
## [v0.10.0] - 2026-03-10
15+
16+
### Added
17+
18+
- Custom implementation of Cholesky factorisation (and solver); this is used in `AffineSpace` now.
19+
- New function in `matrix_operations` to compute AA' given a matrix A
1520

1621
### Changed
1722

18-
- Update version of `rand`, `ndarray`, and `modcholesky` in `Cargo.toml`
23+
- Update version of `ndarray`, in `Cargo.toml`
24+
- Removed `modcholesky` because it was causing a bug (see issue #378)
1925

2026
<!-- ---------------------
2127
v0.9.0
@@ -302,7 +308,7 @@ This is a breaking API change.
302308
--------------------- -->
303309

304310
<!-- Releases -->
305-
[v0.9.2]: https://github.com/alphaville/optimization-engine/compare/v0.9.1...v0.9.2
311+
[v0.10.0]: https://github.com/alphaville/optimization-engine/compare/v0.9.1...v0.10.0
306312
[v0.9.1]: https://github.com/alphaville/optimization-engine/compare/v0.9.0...v0.9.1
307313
[v0.9.0]: https://github.com/alphaville/optimization-engine/compare/v0.8.1...v0.9.0
308314
[v0.8.1]: https://github.com/alphaville/optimization-engine/compare/v0.8.0...v0.8.1

Cargo.toml

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ homepage = "https://alphaville.github.io/optimization-engine/"
4242
repository = "https://github.com/alphaville/optimization-engine"
4343

4444
# Version of this crate (SemVer)
45-
version = "0.9.1"
45+
version = "0.10.0"
4646

4747
edition = "2018"
4848

@@ -80,7 +80,7 @@ rustdoc-args = ["--html-in-header", "katex-header.html"]
8080
num = "0.4"
8181

8282
# Our own stuff - L-BFGS: limited-memory BFGS directions
83-
lbfgs = "0.2"
83+
lbfgs = "0.3"
8484

8585
# Instant is a generic timer that works on Wasm (with wasm-bindgen)
8686
instant = { version = "0.1" }
@@ -98,10 +98,7 @@ rpmalloc = { version = "0.2", features = [
9898
# epigraph of the squared Euclidean norm
9999
roots = "0.0.8"
100100

101-
# Least squares solver (NOTE: ndarray must be version 0.15 - not 0.16)
102-
# Bug report: https://github.com/argmin-rs/modcholesky/issues/34
103-
ndarray = { version = "=0.16.1", features = ["approx"] }
104-
modcholesky = "0.2"
101+
ndarray = { version = "=0.17.2", features = ["approx"] }
105102

106103
# jemallocator is an optional feature; it will only be loaded if the feature
107104
# `jem` is used (i.e., if we compile with `cargo build --features jem`)
@@ -127,15 +124,15 @@ wasm = ["wasm-bindgen", "instant/wasm-bindgen", "instant/inaccurate"]
127124
# --------------------------------------------------------------------------
128125
# These dependencies are only used for testing
129126
[dev-dependencies]
130-
unit_test_utils = "0.1.3"
127+
unit_test_utils = "0.1.4"
131128
# Note: path dependencies (even dev-dependencies) cannot be local in order
132129
# to publish a crate, so the following line can only be used when
133130
# testing locally
134131
# icasadi_test = { path = "test/icasadi_test/" }
135132
# instead, use:
136-
icasadi_test = "0.0.2"
133+
icasadi_test = "0.0.3"
137134
# Random number generators for unit tests:
138-
rand = "0.9"
135+
rand = "0.10"
139136

140137

141138
# --------------------------------------------------------------------------

appveyor.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,5 @@ build: false
7070
test_script:
7171
- cargo add roots
7272
- cargo add ndarray --features approx
73-
- cargo add modcholesky
7473
- cargo build
7574
- cargo test --verbose %cargoflags%

open-codegen/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ Note: This is the Changelog file of `opengen` - the Python interface of OpEn
1111

1212
### Changed
1313

14+
- Removed dependence on `pkg_resources` (issue #380)
1415
- Additional unit tests: increased coverage to 92%
1516

1617
## [0.9.4] - 2025-05-08

open-codegen/VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.9.4
1+
0.9.5

open-codegen/opengen/builder/optimizer_builder.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
import os
1010
import jinja2
1111
import logging
12-
import pkg_resources
1312
import sys
1413

14+
from importlib.metadata import version
1515
from .ros_builder import RosBuilder
1616

1717
_AUTOGEN_COST_FNAME = 'auto_casadi_cost.c'
@@ -750,7 +750,7 @@ def __generate_yaml_data_file(self):
750750

751751
target_yaml_file_path = os.path.join(target_dir, "optimizer.yml")
752752

753-
opengen_version = pkg_resources.require("opengen")[0].version
753+
opengen_version = version("opengen")
754754

755755
tcp_details = None if tcp_config is None \
756756
else {'ip': tcp_config.bind_ip, 'port': tcp_config.bind_port}
Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
1-
import pkg_resources
1+
from importlib.resources import files, as_file
22

33

44
def templates_dir():
55
"""Directory where the templates are found (for internal use, mainly)"""
6-
return pkg_resources.resource_filename('opengen', 'templates/')
6+
return files("opengen") / "templates"
77

88

99
def templates_subdir(subdir=None):
1010
"""
1111
Directory where the templates are found and subfolder relative
12-
to that path(for internal use, mainly)
12+
to that path (for internal use, mainly)
1313
"""
14-
if subdir is None:
15-
return templates_dir()
16-
return pkg_resources.resource_filename('opengen', 'templates/%s/' % subdir)
14+
resource = files("opengen") / "templates"
15+
if subdir is not None:
16+
resource = resource / subdir
17+
return resource
1718

1819

1920
def original_icasadi_dir():
2021
"""Directory where the original icasadi files are found (for internal use)"""
21-
return pkg_resources.resource_filename('opengen', 'icasadi/')
22+
return files("opengen") / "icasadi"

open-codegen/opengen/tcp/optimizer_tcp_manager.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,10 @@
66
import logging
77
import time
88
import math
9-
import pkg_resources
109
from threading import Thread
1110
from retry import retry
1211
from .solver_response import SolverResponse
13-
12+
from importlib.metadata import version
1413

1514
class OptimizerTcpManager:
1615
"""Client for TCP interface of parametric optimizers
@@ -66,8 +65,7 @@ def __init__(self, optimizer_path=None, ip=None, port=None):
6665
# Check whether the optimizer was built with the current version of opengen
6766
# We can only check the optimizer version if the optimizer runs locally
6867
opengen_version = self.__optimizer_details['build']['opengen_version']
69-
current_opengen_version = pkg_resources.require("opengen")[
70-
0].version
68+
current_opengen_version = version("opengen")
7169
if current_opengen_version != opengen_version:
7270
logging.warn(
7371
'the target optimizer was build with a different version of opengen (%s)' % opengen_version)

open-codegen/test/test_raspberry_pi.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import os
12
import opengen as og
23
import unittest
34
import casadi.casadi as cs
@@ -7,6 +8,11 @@
78

89
class RaspberryPiTest(unittest.TestCase):
910

11+
@staticmethod
12+
def get_open_local_absolute_path():
13+
cwd = os.getcwd()
14+
return cwd.split('open-codegen')[0]
15+
1016
# -----------------------------------------------------------------------
1117
# Cross-compile to Raspberry Pi
1218
# -----------------------------------------------------------------------
@@ -25,6 +31,7 @@ def test_compile_rpi(self):
2531
meta = og.config.OptimizerMeta()\
2632
.with_optimizer_name(optimizer_name)
2733
build_config = og.config.BuildConfiguration() \
34+
.with_open_version(local_path=RaspberryPiTest.get_open_local_absolute_path()) \
2835
.with_build_directory(optimizers_dir) \
2936
.with_build_mode(og.config.BuildConfiguration.DEBUG_MODE) \
3037
.with_tcp_interface_config() \

src/alm/alm_cache.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ impl AlmCache {
5151
/// # Arguments
5252
///
5353
/// - `panoc_cache`: an instance of `PANOCCache` that will be used by
54-
/// the inner problem
54+
/// the inner problem
5555
/// - `n1`, `n2`: range dimensions of mappings `F1` and `F2` respectively
5656
///
5757
/// # Panics
@@ -77,9 +77,9 @@ impl AlmCache {
7777
w_pm: if n2 > 0 { Some(vec![0.0; n2]) } else { None },
7878
iteration: 0,
7979
delta_y_norm: 0.0,
80-
delta_y_norm_plus: std::f64::INFINITY,
80+
delta_y_norm_plus: f64::INFINITY,
8181
f2_norm: 0.0,
82-
f2_norm_plus: std::f64::INFINITY,
82+
f2_norm_plus: f64::INFINITY,
8383
inner_iteration_count: 0,
8484
last_inner_problem_norm_fpr: -1.0,
8585
available_time: None,

0 commit comments

Comments
 (0)