Skip to content

Commit

Permalink
Merge pull request #1811 from borglab/fix/python_wrapper
Browse files Browse the repository at this point in the history
Fix warnings and add M1 runner
  • Loading branch information
dellaert committed Aug 26, 2024
2 parents 74b149f + b5c998a commit 69a64ff
Show file tree
Hide file tree
Showing 10 changed files with 47 additions and 25 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Install Dependencies
run: |
Expand Down
8 changes: 7 additions & 1 deletion .github/workflows/build-macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ jobs:
# See https://help.github.com/en/articles/workflow-syntax-for-github-actions.
name: [
macos-12-xcode-14.2,
macos-14-xcode-15.4,
]

build_type: [Debug, Release]
Expand All @@ -36,9 +37,14 @@ jobs:
compiler: xcode
version: "14.2"

- name: macos-14-xcode-15.4
os: macos-14
compiler: xcode
version: "15.4"

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Install Dependencies
run: |
Expand Down
16 changes: 15 additions & 1 deletion .github/workflows/build-python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ jobs:
ubuntu-20.04-gcc-9-tbb,
ubuntu-20.04-clang-9,
macos-12-xcode-14.2,
macos-14-xcode-15.4,
windows-2022-msbuild,
]

Expand Down Expand Up @@ -59,13 +60,18 @@ jobs:
compiler: xcode
version: "14.2"

- name: macos-14-xcode-15.4
os: macos-14
compiler: xcode
version: "15.4"

- name: windows-2022-msbuild
os: windows-2022
platform: 64

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Install (Linux)
if: runner.os == 'Linux'
Expand Down Expand Up @@ -162,6 +168,14 @@ jobs:
run: |
bash .github/scripts/python.sh -d
- name: Create virtual on MacOS
if: runner.os == 'macOS'
run: |
python$PYTHON_VERSION -m venv venv
source venv/bin/activate
echo "PATH=$(pwd)/venv/bin:$PATH" >> $GITHUB_ENV
python -m pip install --upgrade pip
- name: Install Python Dependencies
shell: bash
run: python$PYTHON_VERSION -m pip install -r python/dev_requirements.txt
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build-special.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Install (Linux)
if: runner.os == 'Linux'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup msbuild
uses: ilammy/msvc-dev-cmd@v1
Expand Down
2 changes: 0 additions & 2 deletions gtsam/3rdparty/Eigen/Eigen/src/SparseCore/TriangularSolver.h
Original file line number Diff line number Diff line change
Expand Up @@ -270,11 +270,9 @@ struct sparse_solve_triangular_sparse_selector<Lhs,Rhs,Mode,UpLo,ColMajor>
}


Index count = 0;
// FIXME compute a reference value to filter zeros
for (typename AmbiVector<Scalar,StorageIndex>::Iterator it(tempVector/*,1e-12*/); it; ++it)
{
++ count;
// std::cerr << "fill " << it.index() << ", " << col << "\n";
// std::cout << it.value() << " ";
// FIXME use insertBack
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,6 @@ void SparseLUImpl<Scalar,StorageIndex>::heap_relax_snode (const Index n, IndexVe
// Identify the relaxed supernodes by postorder traversal of the etree
Index snode_start; // beginning of a snode
StorageIndex k;
Index nsuper_et_post = 0; // Number of relaxed snodes in postordered etree
Index nsuper_et = 0; // Number of relaxed snodes in the original etree
StorageIndex l;
for (j = 0; j < n; )
{
Expand All @@ -88,7 +86,6 @@ void SparseLUImpl<Scalar,StorageIndex>::heap_relax_snode (const Index n, IndexVe
parent = et(j);
}
// Found a supernode in postordered etree, j is the last column
++nsuper_et_post;
k = StorageIndex(n);
for (Index i = snode_start; i <= j; ++i)
k = (std::min)(k, inv_post(i));
Expand All @@ -97,7 +94,6 @@ void SparseLUImpl<Scalar,StorageIndex>::heap_relax_snode (const Index n, IndexVe
{
// This is also a supernode in the original etree
relax_end(k) = l; // Record last column
++nsuper_et;
}
else
{
Expand All @@ -107,7 +103,6 @@ void SparseLUImpl<Scalar,StorageIndex>::heap_relax_snode (const Index n, IndexVe
if (descendants(i) == 0)
{
relax_end(l) = l;
++nsuper_et;
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion gtsam/3rdparty/metis/GKlib/pdb.c
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ that structure.
/************************************************************************/
pdbf *gk_readpdbfile(char *fname) { /* {{{ */
int i=0, res=0;
char linetype[6];
char linetype[7];
int aserial;
char aname[5] = " \0";
char altLoc = ' ';
Expand Down
2 changes: 1 addition & 1 deletion gtsam/discrete/tests/testDiscreteConditional.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ TEST(DiscreteConditional, choose) {
/* ************************************************************************* */
// Check argmax on P(C|D) and P(D), plus tie-breaking for P(B)
TEST(DiscreteConditional, Argmax) {
DiscreteKey B(2, 2), C(2, 2), D(4, 2);
DiscreteKey C(2, 2), D(4, 2);
DiscreteConditional B_prior(D, "1/1");
DiscreteConditional D_prior(D, "1/3");
DiscreteConditional C_given_D((C | D) = "1/4 1/1");
Expand Down
31 changes: 20 additions & 11 deletions python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -263,18 +263,27 @@ if(GTSAM_UNSTABLE_BUILD_PYTHON)
endif()

# Add custom target so we can install with `make python-install`
if (NOT WIN32) # WIN32=1 is target platform is Windows
add_custom_target(python-install
COMMAND stubgen -q -p gtsam -o ./stubs && cp -a stubs/gtsam/ gtsam && ${PYTHON_EXECUTABLE} -m pip install --user .
# Note below we make sure to install with --user iff not in a virtualenv
set(GTSAM_PYTHON_INSTALL_TARGET python-install)
add_custom_target(${GTSAM_PYTHON_INSTALL_TARGET}
COMMAND ${PYTHON_EXECUTABLE} -c "import sys, subprocess; cmd = [sys.executable, '-m', 'pip', 'install']; has_venv = hasattr(sys, 'real_prefix') or (hasattr(sys, 'base_prefix') and sys.base_prefix != sys.prefix); cmd.append('--user' if not has_venv else ''); cmd.append('.'); subprocess.check_call([c for c in cmd if c])"
DEPENDS ${GTSAM_PYTHON_DEPENDENCIES}
WORKING_DIRECTORY ${GTSAM_PYTHON_BUILD_DIRECTORY})
else()
#TODO(Varun) Find equivalent cp on Windows
add_custom_target(python-install
COMMAND ${PYTHON_EXECUTABLE} -m pip install --user .
DEPENDS ${GTSAM_PYTHON_DEPENDENCIES}
WORKING_DIRECTORY ${GTSAM_PYTHON_BUILD_DIRECTORY})
endif()
WORKING_DIRECTORY ${GTSAM_PYTHON_BUILD_DIRECTORY}
VERBATIM)

# if (NOT WIN32) # WIN32=1 is target platform is Windows
# add_custom_target(${GTSAM_PYTHON_INSTALL_TARGET}
# COMMAND stubgen -q -p gtsam -o ./stubs && cp -a stubs/gtsam/ gtsam && ${PYTHON_EXECUTABLE} -m pip install --user .
# DEPENDS ${GTSAM_PYTHON_DEPENDENCIES}
# WORKING_DIRECTORY ${GTSAM_PYTHON_BUILD_DIRECTORY})
# else()
# #TODO(Varun) Find equivalent cp on Windows
# add_custom_target(${GTSAM_PYTHON_INSTALL_TARGET}
# COMMAND ${PYTHON_EXECUTABLE} -m pip install --user .
# DEPENDS ${GTSAM_PYTHON_DEPENDENCIES}
# WORKING_DIRECTORY ${GTSAM_PYTHON_BUILD_DIRECTORY})
# endif()


# Custom make command to run all GTSAM Python tests
add_custom_target(
Expand Down

0 comments on commit 69a64ff

Please sign in to comment.