fiftysevendegreesofrad / sdna_plus

Fully open release with all advanced sDNA+ features
Other
10 stars 1 forks source link

sDNA+: Spatial Design Network Analysis plus

This is the open source fork of the formerly proprietary sDNA+ software - all the sDNA features plus hybrid metrics.

sDNA+ was created by Crispin Cooper on behalf of Cardiff University. Alain Chiaradia was responsible for the initial idea, and Chris Webster for the initial funding and project mentoring. We are grateful to various parties for financial contributions towards development: in no particular order, Hong Kong University, Tongji University, the UK Economic and Social Research Council, BRE, Wedderburn Transport Planning. Also research contributions in kind from Arup Ltd, WSP Global Engineering, BuroHappold and Sustrans. Also to James Parrott both for developing the sDNA for Grasshopper plugin, and for assistance in updating the sDNA build process during 2023. And Jeffrey Morgan for updating sDNA to Python 3.

If you are interested in sponsoring changes to sDNA, please get in touch with Crispin cooperch@cardiff.ac.uk.

Copyright rests with Cardiff University and the code is released under GPL Affero version 3.

For Users

Installation

Use the software via any of the following means:

The experimental Cross Platform branch (that runs on Linux, as well as Windows) can be installed from PyPi.

Documentation

Hosted on readthedocs.

Support

Please see the original project support page.

If filing a bug, please file to the database here on github.

For Developers

See BUILD.md for notes regarding the impact of switching to CMake from sdna_vs2008.vcxproj

Experimental Linux build

Requires the Cross_platform branch. The GCC builds are prioritised, but the 'Clang' builds (using zig c++) have been invaluable. There are a handful of open regressions (compared to the Windows build), which may or may not be important.

Installation

Local build requirements:

Fire up the Visual Studio Developer Command Prompt.

CI build and test requirements:

CMake build requirements:

CMake's Visual Studio Generator is a multi-config generator. This would be handy for creating a Release build in parallel with a Debug build. Unfortunately it is not a multi-platform generator (sDNA's installer contains Release Win32 and Release x64 DLLs). CMakeLists.txt needs to be invoked and built from twice therefore, to produce a Windows installer.

Running (in a normal cmd.exe, not the VS Developer Command Prompt):

Dependencies

Boost

It is not immediately visible, but Boost 1.83 is used currently. Vcpkg manifest mode uses hashes of git commits of its own repo to define baselines from which dependencies are drawn. These are in sDNA\sdna_vs2008\vcpkg-configuration.json. For example 61f610845fb206298a69f708104a51d651872877 refers to https://github.com/microsoft/vcpkg/commit/61f610845fb206298a69f708104a51d651872877 of Nov 11th 2023, on which date the latest version of Boost in vcpkg was 1.83 https://learn.microsoft.com/en-gb/vcpkg/consume/boost-versions

It is possible to use an override mechanism to pin deps instead, but this would make sDNA\sdna_vs2008\vcpkg.json much longer. https://learn.microsoft.com/en-gb/vcpkg/consume/lock-package-versions?tabs=inspect-powershell#5---force-a-specific-version

Geos

Geos is dynamically linked at run-time. A custom build step copies in the geos_c.dlls (from sDNA\geos\x64\src and sDNA\geos\x86\src), originally compiled for OSGEO4W available hereabouts: https://download.osgeo.org/osgeo4w/v2/x86_64/release/geos/

Muparser

A static copy of a slightly modified Rev 2.2.3: 22.12.2012. Changes:

Anyiterator

// Revision History
// ================
//
// 12 Jul 2010 

R-portable

TODO

Packaging

The Windows installer contains x64 and Win32 binaries (for both sdna_vs2008.dll and geos_c.dll)

Project Structure

Some key folders:

Tests

The test code needs updating (plan to do this with the port to Linux).

Continuous Integration Tests.

Currently, the CI tests are a subset of sDNA's regression tests, which diff the test output against that produced by a previous build (eight of the expected output files can be recreated using sDNA\sdna_vs2008\tests\approve_debug_output.bat, but correctout_learn.txt and correctout_table.txt require other means).

The CI test runner parses every .bat file in sDNA\sdna_vs2008\tests except the following which are filtered out: colourdiff.bat, mydiff.bat, awkward_test.bat, arc_script_test.bat,run_tests_windows.bat, sdnavars64.bat,quick_test.bat ( as it reruns debug_test.py which is already tested in pause_debug_test.bat) and run_benchmark.bat (to avoid issue 11, an unexplained "Access violation on Python 3").

To run the CI tests locally, something like the following commands are required:

cd your_venvs_directory
python -m venv sdna_testing_venv
.\sdna_testing_venv\Scripts\activate
pip install numpy pytest
cd path_to_sdna_plus_repo\sdna_plus\sDNA\sdna_vs2008\tests\pytest
set DONT_TEST_N_LINK_SUBSYSTEMS_ORDER=1 & set ALLOW_NEGATIVE_FORMULA_ERROR_ON_ANY_LINK_PRESENT=1 & pytest -rA

The CI test runner is designed to use Pytest, but can also run its tests only requiring pytest as an import (if run as a script). It is influenced by the following environment variables:

Various other quality of life adjustments are made, such as ignoring blank lines, and Progress bar percentage lines.

Old testing routine.

Currently the steps outlined below may not work, but what does work is setting appriate paths for python2exe, python3exe, and sdnadll (which should be 32 or 64 bit depending on the Python executable) then calling pause_debug_test.bat.

For testing the core network processing and numerical routines, fire up the sdna_vs2008.sln solution in sDNA\sDNA_vs2008. You will need the correct debug settings; unfortunately Visual Studio stores these with user information. Copy sdna\sdna_vs2008\sdna_vs2008.vcproj.octopi.Crispin.user.sample on top of your own sdna_vs2008.vcproj.yourmachine.yourusername.user file. Set build configuration to Debug Win32, and run. This calls scripts in sDNA\sDNA_vs2008\tests and diffs the output with correct outputs (the core of which are originally hand computed) in that directory. Any call to diff that shows differences is a test fail.

For test_parallel_results.py to work, you also need to build the parallel_debug Win32 configuration. When Debug Win32 is run as described above, serial and parallel results are compared to check they are identical.

Interfaces are not automatically tested, though arcscripts\sdna_environment.py can be tested by environment_test.py.

Future

The long term roadmap includes moving to reproducible builds (which will be nice when developers have to onboard or change machines), and porting to Linux. We think the path towards this is (1) replace MSBuild with cmake (there is a converter); (2) replace msvc with gcc; (3) the community profits!

License

The bulk of sDNA+ is licensed under GNU Affero v3, with various other Free licenses for various modules. For full details see licensing.